Fixed compiler warnings - unnecessary else

git-svn-id: https://svn.apache.org/repos/asf/poi/trunk@805492 13f79535-47bb-0310-9956-ffa450edef68
This commit is contained in:
Josh Micich 2009-08-18 16:50:24 +00:00
parent 95afcef9e6
commit a2cd9a942e
69 changed files with 2160 additions and 2334 deletions

View File

@ -136,9 +136,9 @@ public class ExtendableTreeCellRenderer implements TreeCellRenderer
/* The class has no renderer, try the superclass, if any. */
final Class superclass = c.getSuperclass();
if (superclass != null)
if (superclass != null) {
return findRenderer(superclass);
else
}
return null;
}

View File

@ -204,9 +204,7 @@ public class TreeReaderListener implements POIFSReaderListener
}
return n;
}
else
{
/* The path is somewhere down in the POI filesystem's
/* else - The path is somewhere down in the POI filesystem's
* hierarchy. We need the tree node of this path's parent
* and attach our new node to it. */
final String name = path.getComponent(path.length() - 1);
@ -219,5 +217,3 @@ public class TreeReaderListener implements POIFSReaderListener
return n;
}
}
}

View File

@ -196,7 +196,7 @@ public class SVFractionalFormat extends Format {
toAppendTo.append(format(((Number)obj).doubleValue()));
return toAppendTo;
}
else throw new IllegalArgumentException("Can only handle Numbers");
throw new IllegalArgumentException("Can only handle Numbers");
}
public Object parseObject(String source,

View File

@ -232,9 +232,9 @@ public class MutablePropertySet extends PropertySet
catch (HPSFRuntimeException ex)
{
final Throwable cause = ex.getReason();
if (cause instanceof UnsupportedEncodingException)
if (cause instanceof UnsupportedEncodingException) {
throw new IllegalPropertySetDataException(cause);
else
}
throw ex;
}
}

View File

@ -342,8 +342,9 @@ public class Property
*/
public boolean equals(final Object o)
{
if (!(o instanceof Property))
if (!(o instanceof Property)) {
return false;
}
final Property p = (Property) o;
final Object pValue = p.getValue();
final long pId = p.getID();
@ -355,8 +356,8 @@ public class Property
return false;
/* It's clear now that both values are non-null. */
final Class valueClass = value.getClass();
final Class pValueClass = pValue.getClass();
final Class<?> valueClass = value.getClass();
final Class<?> pValueClass = pValue.getClass();
if (!(valueClass.isAssignableFrom(pValueClass)) &&
!(pValueClass.isAssignableFrom(valueClass)))
return false;
@ -373,9 +374,9 @@ public class Property
{
if (t1 == t2 ||
(t1 == Variant.VT_LPSTR && t2 == Variant.VT_LPWSTR) ||
(t2 == Variant.VT_LPSTR && t1 == Variant.VT_LPWSTR))
(t2 == Variant.VT_LPSTR && t1 == Variant.VT_LPWSTR)) {
return true;
else
}
return false;
}

View File

@ -208,7 +208,7 @@ public class Section
/* Pass 1: Read the property list. */
int pass1Offset = o1;
final List propertyList = new ArrayList(propertyCount);
final List<PropertyListEntry> propertyList = new ArrayList<PropertyListEntry>(propertyCount);
PropertyListEntry ple;
for (int i = 0; i < properties.length; i++)
{
@ -232,15 +232,13 @@ public class Section
/* Calculate the properties' lengths. */
for (int i = 0; i < propertyCount - 1; i++)
{
final PropertyListEntry ple1 =
(PropertyListEntry) propertyList.get(i);
final PropertyListEntry ple2 =
(PropertyListEntry) propertyList.get(i + 1);
PropertyListEntry ple1 = propertyList.get(i);
PropertyListEntry ple2 = propertyList.get(i + 1);
ple1.length = ple2.offset - ple1.offset;
}
if (propertyCount > 0)
{
ple = (PropertyListEntry) propertyList.get(propertyCount - 1);
ple = propertyList.get(propertyCount - 1);
ple.length = size - ple.offset;
if (ple.length <= 0)
{
@ -412,11 +410,11 @@ public class Section
protected boolean getPropertyBooleanValue(final int id)
{
final Boolean b = (Boolean) getProperty(id);
if (b != null)
return b.booleanValue();
else
if (b == null) {
return false;
}
return b.booleanValue();
}
@ -559,11 +557,11 @@ public class Section
dictionaryEqual = p10.getValue().equals(p20.getValue());
else if (p10 != null || p20 != null)
dictionaryEqual = false;
if (!dictionaryEqual)
return false;
else
if (dictionaryEqual) {
return Util.equals(pa1, pa2);
}
return false;
}

View File

@ -29,8 +29,7 @@ import org.apache.poi.hpsf.wellknown.PropertyIDMap;
* href="mailto:klute@rainer-klute.de">&lt;klute@rainer-klute.de&gt;</a>
* @see DocumentSummaryInformation
*/
public class SummaryInformation extends SpecialPropertySet
{
public final class SummaryInformation extends SpecialPropertySet {
/**
* <p>The document name a summary information stream usually has in a POIFS
@ -361,9 +360,9 @@ public class SummaryInformation extends SpecialPropertySet
public long getEditTime()
{
final Date d = (Date) getProperty(PropertyIDMap.PID_EDITTIME);
if (d == null)
if (d == null) {
return 0;
else
}
return Util.dateToFileTime(d);
}

View File

@ -25,8 +25,7 @@ import org.apache.poi.util.LittleEndian;
* @author Drew Varner (Drew.Varner inOrAround sc.edu)
* @see SummaryInformation#getThumbnail()
*/
public class Thumbnail
{
public final class Thumbnail {
/**
* <p>Offset in bytes where the Clipboard Format Tag starts in the
@ -128,7 +127,7 @@ public class Thumbnail
* <p>A <code>byte[]</code> to hold a thumbnail image in ({@link
* Variant#VT_CF VT_CF}) format.</p>
*/
private byte[] thumbnailData = null;
private byte[] _thumbnailData = null;
@ -154,7 +153,7 @@ public class Thumbnail
*/
public Thumbnail(final byte[] thumbnailData)
{
this.thumbnailData = thumbnailData;
this._thumbnailData = thumbnailData;
}
@ -168,7 +167,7 @@ public class Thumbnail
*/
public byte[] getThumbnail()
{
return thumbnailData;
return _thumbnailData;
}
@ -182,7 +181,7 @@ public class Thumbnail
*/
public void setThumbnail(final byte[] thumbnail)
{
this.thumbnailData = thumbnail;
this._thumbnailData = thumbnail;
}
@ -261,11 +260,10 @@ public class Thumbnail
if (!(getClipboardFormatTag() == CFTAG_WINDOWS))
throw new HPSFException("Clipboard Format Tag of Thumbnail must " +
"be CFTAG_WINDOWS.");
if (!(getClipboardFormat() == CF_METAFILEPICT))
if (!(getClipboardFormat() == CF_METAFILEPICT)) {
throw new HPSFException("Clipboard Format of Thumbnail must " +
"be CF_METAFILEPICT.");
else
{
}
byte[] thumbnail = getThumbnail();
int wmfImageLength = thumbnail.length - OFFSET_WMFDATA;
byte[] wmfImage = new byte[wmfImageLength];
@ -277,5 +275,3 @@ public class Thumbnail
return wmfImage;
}
}
}

View File

@ -121,16 +121,14 @@ public class SectionIDMap extends HashMap {
final long pid)
{
final PropertyIDMap m = getInstance().get(sectionFormatID);
if (m == null)
if (m == null) {
return UNDEFINED;
else
{
}
final String s = (String) m.get(pid);
if (s == null)
return UNDEFINED;
return s;
}
}

View File

@ -71,12 +71,11 @@ public class ModelFactory implements ERFListener
}
//ERFListener
public boolean processRecord(Record rec)
{
public boolean processRecord(Record rec) {
if (rec.getSid() == BOFRecord.sid) {
if (lastEOF != true) {
throw new RuntimeException("Not yet handled embedded models");
} else {
}
BOFRecord bof = (BOFRecord)rec;
switch (bof.getType()) {
case BOFRecord.TYPE_WORKBOOK:
@ -88,8 +87,6 @@ public class ModelFactory implements ERFListener
default:
throw new RuntimeException("Unsupported model type "+bof.getType());
}
}
}
if (rec.getSid() == EOFRecord.sid) {
@ -98,8 +95,6 @@ public class ModelFactory implements ERFListener
} else {
lastEOF = false;
}
return true;
}
@ -115,6 +110,4 @@ public class ModelFactory implements ERFListener
mfl.process(model);
}
}
}

View File

@ -31,63 +31,63 @@ import org.apache.poi.hssf.usermodel.HSSFDataFormat;
import org.apache.poi.hssf.usermodel.HSSFDataFormatter;
/**
* A proxy HSSFListener that keeps track of the document
* formatting records, and provides an easy way to look
* up the format strings used by cells from their ids.
* A proxy HSSFListener that keeps track of the document formatting records, and
* provides an easy way to look up the format strings used by cells from their
* ids.
*/
public class FormatTrackingHSSFListener implements HSSFListener {
private HSSFListener childListener;
private HSSFDataFormatter formatter = new HSSFDataFormatter();
private Map customFormatRecords = new Hashtable();
private List xfRecords = new ArrayList();
private final HSSFListener _childListener;
private HSSFDataFormatter _formatter = new HSSFDataFormatter();
private final Map<Integer, FormatRecord> _customFormatRecords = new Hashtable<Integer, FormatRecord>();
private final List<ExtendedFormatRecord> _xfRecords = new ArrayList<ExtendedFormatRecord>();
public FormatTrackingHSSFListener(HSSFListener childListener) {
this.childListener = childListener;
_childListener = childListener;
}
protected int getNumberOfCustomFormats() {
return customFormatRecords.size();
return _customFormatRecords.size();
}
protected int getNumberOfExtendedFormats() {
return xfRecords.size();
return _xfRecords.size();
}
/**
* Process this record ourselves, and then
* pass it on to our child listener
* Process this record ourselves, and then pass it on to our child listener
*/
public void processRecord(Record record) {
// Handle it ourselves
processRecordInternally(record);
// Now pass on to our child
childListener.processRecord(record);
_childListener.processRecord(record);
}
/**
* Process the record ourselves, but do not
* pass it on to the child Listener.
* Process the record ourselves, but do not pass it on to the child
* Listener.
*
* @param record
*/
public void processRecordInternally(Record record) {
if (record instanceof FormatRecord) {
FormatRecord fr = (FormatRecord) record;
customFormatRecords.put(new Integer(fr.getIndexCode()), fr);
_customFormatRecords.put(new Integer(fr.getIndexCode()), fr);
}
if (record instanceof ExtendedFormatRecord) {
ExtendedFormatRecord xr = (ExtendedFormatRecord) record;
xfRecords.add(xr);
_xfRecords.add(xr);
}
}
/**
* Formats the given numeric of date Cell's contents
* as a String, in as close as we can to the way
* that Excel would do so.
* Uses the various format records to manage this.
* Formats the given numeric of date Cell's contents as a String, in as
* close as we can to the way that Excel would do so. Uses the various
* format records to manage this.
*
* TODO - move this to a central class in such a
* way that hssf.usermodel can make use of it too
* TODO - move this to a central class in such a way that hssf.usermodel can
* make use of it too
*/
public String formatNumberDateCell(CellValueRecordInterface cell) {
double value;
@ -105,23 +105,22 @@ public class FormatTrackingHSSFListener implements HSSFListener {
if (formatString == null) {
return Double.toString(value);
} else {
}
// Format, using the nice new
// HSSFDataFormatter to do the work for us
return formatter.formatRawCellContents(value, formatIndex, formatString);
}
return _formatter.formatRawCellContents(value, formatIndex, formatString);
}
/**
* Returns the format string, eg $##.##, for the
* given number format index.
* Returns the format string, eg $##.##, for the given number format index.
*/
public String getFormatString(int formatIndex) {
String format = null;
if (formatIndex >= HSSFDataFormat.getNumberOfBuiltinBuiltinFormats()) {
FormatRecord tfr = (FormatRecord)customFormatRecords.get(new Integer(formatIndex));
FormatRecord tfr = _customFormatRecords.get(new Integer(formatIndex));
if (tfr == null) {
System.err.println("Requested format at index " + formatIndex + ", but it wasn't found");
System.err.println("Requested format at index " + formatIndex
+ ", but it wasn't found");
} else {
format = tfr.getFormatString();
}
@ -132,8 +131,7 @@ public class FormatTrackingHSSFListener implements HSSFListener {
}
/**
* Returns the format string, eg $##.##, used
* by your cell
* Returns the format string, eg $##.##, used by your cell
*/
public String getFormatString(CellValueRecordInterface cell) {
int formatIndex = getFormatIndex(cell);
@ -145,14 +143,14 @@ public class FormatTrackingHSSFListener implements HSSFListener {
}
/**
* Returns the index of the format string, used by your cell,
* or -1 if none found
* Returns the index of the format string, used by your cell, or -1 if none
* found
*/
public int getFormatIndex(CellValueRecordInterface cell) {
ExtendedFormatRecord xfr = (ExtendedFormatRecord)
xfRecords.get(cell.getXFIndex());
ExtendedFormatRecord xfr = _xfRecords.get(cell.getXFIndex());
if (xfr == null) {
System.err.println("Cell " + cell.getRow() + "," + cell.getColumn() + " uses XF with index " + cell.getXFIndex() + ", but we don't have that");
System.err.println("Cell " + cell.getRow() + "," + cell.getColumn()
+ " uses XF with index " + cell.getXFIndex() + ", but we don't have that");
return -1;
}
return xfr.getFormatIndex();

View File

@ -65,13 +65,13 @@ import org.apache.poi.poifs.filesystem.POIFSFileSystem;
* http://svn.apache.org/repos/asf/poi/trunk/src/examples/src/org/apache/poi/hssf/eventusermodel/examples/XLS2CSVmra.java</link>
*/
public class EventBasedExcelExtractor extends POIOLE2TextExtractor {
private POIFSFileSystem fs;
private boolean includeSheetNames = true;
private boolean formulasNotResults = false;
private POIFSFileSystem _fs;
boolean _includeSheetNames = true;
boolean _formulasNotResults = false;
public EventBasedExcelExtractor(POIFSFileSystem fs) {
super(null);
this.fs = fs;
_fs = fs;
}
/**
@ -94,14 +94,14 @@ public class EventBasedExcelExtractor extends POIOLE2TextExtractor {
* Should sheet names be included? Default is true
*/
public void setIncludeSheetNames(boolean includeSheetNames) {
this.includeSheetNames = includeSheetNames;
_includeSheetNames = includeSheetNames;
}
/**
* Should we return the formula itself, and not
* the result it produces? Default is false
*/
public void setFormulasNotResults(boolean formulasNotResults) {
this.formulasNotResults = formulasNotResults;
_formulasNotResults = formulasNotResults;
}
@ -113,7 +113,7 @@ public class EventBasedExcelExtractor extends POIOLE2TextExtractor {
try {
TextListener tl = triggerExtraction();
text = tl.text.toString();
text = tl._text.toString();
if(! text.endsWith("\n")) {
text = text + "\n";
}
@ -127,30 +127,33 @@ public class EventBasedExcelExtractor extends POIOLE2TextExtractor {
private TextListener triggerExtraction() throws IOException {
TextListener tl = new TextListener();
FormatTrackingHSSFListener ft = new FormatTrackingHSSFListener(tl);
tl.ft = ft;
tl._ft = ft;
// Register and process
HSSFEventFactory factory = new HSSFEventFactory();
HSSFRequest request = new HSSFRequest();
request.addListenerForAllRecords(ft);
factory.processWorkbookEvents(request, fs);
factory.processWorkbookEvents(request, _fs);
return tl;
}
private class TextListener implements HSSFListener {
private FormatTrackingHSSFListener ft;
FormatTrackingHSSFListener _ft;
private SSTRecord sstRecord;
private List sheetNames = new ArrayList();
private StringBuffer text = new StringBuffer();
private final List<String> sheetNames;
final StringBuffer _text = new StringBuffer();
private int sheetNum = -1;
private int rowNum;
private boolean outputNextStringValue = false;
private int nextRow = -1;
public TextListener() {
sheetNames = new ArrayList<String>();
}
public void processRecord(Record record) {
String thisText = null;
int thisRow = -1;
@ -166,9 +169,9 @@ public class EventBasedExcelExtractor extends POIOLE2TextExtractor {
sheetNum++;
rowNum = -1;
if(includeSheetNames) {
if(text.length() > 0) text.append("\n");
text.append(sheetNames.get(sheetNum));
if(_includeSheetNames) {
if(_text.length() > 0) _text.append("\n");
_text.append(sheetNames.get(sheetNum));
}
}
break;
@ -180,7 +183,7 @@ public class EventBasedExcelExtractor extends POIOLE2TextExtractor {
FormulaRecord frec = (FormulaRecord) record;
thisRow = frec.getRow();
if(formulasNotResults) {
if(_formulasNotResults) {
thisText = HSSFFormulaParser.toFormulaString((HSSFWorkbook)null, frec.getParsedExpression());
} else {
if(frec.hasCachedResultString()) {
@ -232,12 +235,12 @@ public class EventBasedExcelExtractor extends POIOLE2TextExtractor {
if(thisText != null) {
if(thisRow != rowNum) {
rowNum = thisRow;
if(text.length() > 0)
text.append("\n");
if(_text.length() > 0)
_text.append("\n");
} else {
text.append("\t");
_text.append("\t");
}
text.append(thisText);
_text.append(thisText);
}
}
@ -247,12 +250,12 @@ public class EventBasedExcelExtractor extends POIOLE2TextExtractor {
*/
private String formatNumberDateCell(CellValueRecordInterface cell, double value) {
// Get the built in format, if there is one
int formatIndex = ft.getFormatIndex(cell);
String formatString = ft.getFormatString(cell);
int formatIndex = _ft.getFormatIndex(cell);
String formatString = _ft.getFormatString(cell);
if(formatString == null) {
return Double.toString(value);
} else {
}
// Is it a date?
if(HSSFDateUtil.isADateFormat(formatIndex,formatString) &&
HSSFDateUtil.isValidExcelDate(value)) {
@ -265,7 +268,7 @@ public class EventBasedExcelExtractor extends POIOLE2TextExtractor {
Date d = HSSFDateUtil.getJavaDate(value, false);
DateFormat df = new SimpleDateFormat(formatString);
return df.format(d);
} else {
}
if(formatString == "General") {
// Some sort of wierd default
return Double.toString(value);
@ -277,5 +280,3 @@ public class EventBasedExcelExtractor extends POIOLE2TextExtractor {
}
}
}
}
}

View File

@ -50,8 +50,6 @@ public class ConvertAnchor
anchor.setDy2( (short) a.getDy2() );
return anchor;
}
else
{
HSSFChildAnchor a = (HSSFChildAnchor) userAnchor;
EscherChildAnchorRecord anchor = new EscherChildAnchorRecord();
anchor.setRecordId( EscherChildAnchorRecord.RECORD_ID );
@ -63,5 +61,3 @@ public class ConvertAnchor
return anchor;
}
}
}

View File

@ -116,8 +116,6 @@ public abstract class AbstractEscherHolderRecord extends Record {
System.arraycopy( rawData, 0, data, 4 + offset, rawData.length);
return rawData.length + 4;
}
else
{
LittleEndian.putShort(data, 0 + offset, getSid());
LittleEndian.putShort(data, 2 + offset, (short)(getRecordSize() - 4));
@ -127,7 +125,6 @@ public abstract class AbstractEscherHolderRecord extends Record {
EscherRecord r = (EscherRecord) iterator.next();
pos += r.serialize( pos, data, new NullEscherSerializationListener() );
}
}
return getRecordSize();
}

View File

@ -95,11 +95,11 @@ public final class CFRuleRecord extends StandardRecord {
private short field_6_not_used;
private FontFormatting fontFormatting;
private FontFormatting _fontFormatting;
private BorderFormatting borderFormatting;
private BorderFormatting _borderFormatting;
private PatternFormatting patternFormatting;
private PatternFormatting _patternFormatting;
private Formula field_17_formula1;
private Formula field_18_formula2;
@ -117,9 +117,9 @@ public final class CFRuleRecord extends StandardRecord {
field_5_options = undocumented.clear(field_5_options);
field_6_not_used = (short)0x8002; // Excel seems to write this value, but it doesn't seem to care what it reads
fontFormatting=null;
borderFormatting=null;
patternFormatting=null;
_fontFormatting=null;
_borderFormatting=null;
_patternFormatting=null;
field_17_formula1=Formula.create(Ptg.EMPTY_PTG_ARRAY);
field_18_formula2=Formula.create(Ptg.EMPTY_PTG_ARRAY);
}
@ -157,15 +157,15 @@ public final class CFRuleRecord extends StandardRecord {
field_6_not_used = in.readShort();
if (containsFontFormattingBlock()) {
fontFormatting = new FontFormatting(in);
_fontFormatting = new FontFormatting(in);
}
if (containsBorderFormattingBlock()) {
borderFormatting = new BorderFormatting(in);
_borderFormatting = new BorderFormatting(in);
}
if (containsPatternFormattingBlock()) {
patternFormatting = new PatternFormatting(in);
_patternFormatting = new PatternFormatting(in);
}
// "You may not use unions, intersections or array constants in Conditional Formatting criteria"
@ -184,20 +184,17 @@ public final class CFRuleRecord extends StandardRecord {
}
public void setFontFormatting(FontFormatting fontFormatting)
{
this.fontFormatting = fontFormatting;
_fontFormatting = fontFormatting;
setOptionFlag(fontFormatting != null, font);
}
public FontFormatting getFontFormatting()
{
if( containsFontFormattingBlock())
{
return fontFormatting;
return _fontFormatting;
}
else
{
return null;
}
}
public boolean containsAlignFormattingBlock()
{
@ -214,20 +211,17 @@ public final class CFRuleRecord extends StandardRecord {
}
public void setBorderFormatting(BorderFormatting borderFormatting)
{
this.borderFormatting = borderFormatting;
_borderFormatting = borderFormatting;
setOptionFlag(borderFormatting != null, bord);
}
public BorderFormatting getBorderFormatting()
{
if( containsBorderFormattingBlock())
{
return borderFormatting;
return _borderFormatting;
}
else
{
return null;
}
}
public boolean containsPatternFormattingBlock()
{
@ -235,20 +229,17 @@ public final class CFRuleRecord extends StandardRecord {
}
public void setPatternFormatting(PatternFormatting patternFormatting)
{
this.patternFormatting = patternFormatting;
_patternFormatting = patternFormatting;
setOptionFlag(patternFormatting!=null, patt);
}
public PatternFormatting getPatternFormatting()
{
if( containsPatternFormattingBlock())
{
return patternFormatting;
return _patternFormatting;
}
else
{
return null;
}
}
public boolean containsProtectionFormattingBlock()
{
@ -452,16 +443,16 @@ public final class CFRuleRecord extends StandardRecord {
out.writeShort(field_6_not_used);
if (containsFontFormattingBlock()) {
byte[] fontFormattingRawRecord = fontFormatting.getRawRecord();
byte[] fontFormattingRawRecord = _fontFormatting.getRawRecord();
out.write(fontFormattingRawRecord);
}
if (containsBorderFormattingBlock()) {
borderFormatting.serialize(out);
_borderFormatting.serialize(out);
}
if (containsPatternFormattingBlock()) {
patternFormatting.serialize(out);
_patternFormatting.serialize(out);
}
field_17_formula1.serializeTokens(out);
@ -470,7 +461,7 @@ public final class CFRuleRecord extends StandardRecord {
protected int getDataSize() {
return 12 +
(containsFontFormattingBlock()?fontFormatting.getRawRecord().length:0)+
(containsFontFormattingBlock()?_fontFormatting.getRawRecord().length:0)+
(containsBorderFormattingBlock()?8:0)+
(containsPatternFormattingBlock()?4:0)+
getFormulaSize(field_17_formula1)+
@ -486,13 +477,13 @@ public final class CFRuleRecord extends StandardRecord {
buffer.append(" OPTION FLAGS=0x"+Integer.toHexString(getOptions()));
if (false) {
if (containsFontFormattingBlock()) {
buffer.append(fontFormatting.toString());
buffer.append(_fontFormatting.toString());
}
if (containsBorderFormattingBlock()) {
buffer.append(borderFormatting.toString());
buffer.append(_borderFormatting.toString());
}
if (containsPatternFormattingBlock()) {
buffer.append(patternFormatting.toString());
buffer.append(_patternFormatting.toString());
}
buffer.append("[/CFRULE]\n");
}
@ -504,13 +495,13 @@ public final class CFRuleRecord extends StandardRecord {
rec.field_5_options = field_5_options;
rec.field_6_not_used = field_6_not_used;
if (containsFontFormattingBlock()) {
rec.fontFormatting = (FontFormatting) fontFormatting.clone();
rec._fontFormatting = (FontFormatting) _fontFormatting.clone();
}
if (containsBorderFormattingBlock()) {
rec.borderFormatting = (BorderFormatting) borderFormatting.clone();
rec._borderFormatting = (BorderFormatting) _borderFormatting.clone();
}
if (containsPatternFormattingBlock()) {
rec.patternFormatting = (PatternFormatting) patternFormatting.clone();
rec._patternFormatting = (PatternFormatting) _patternFormatting.clone();
}
rec.field_17_formula1 = field_17_formula1.copy();
rec.field_18_formula2 = field_17_formula1.copy();

View File

@ -58,8 +58,6 @@ public final class DrawingGroupRecord extends AbstractEscherHolderRecord {
{
return writeData( offset, data, rawData );
}
else
{
byte[] buffer = new byte[getRawDataSize()];
int pos = 0;
for ( Iterator iterator = getEscherRecords().iterator(); iterator.hasNext(); )
@ -70,7 +68,6 @@ public final class DrawingGroupRecord extends AbstractEscherHolderRecord {
return writeData( offset, data, buffer );
}
}
/**
* Process the bytes into escher records.
@ -140,5 +137,4 @@ public final class DrawingGroupRecord extends AbstractEscherHolderRecord {
LittleEndian.putShort(data, 0 + offset, ContinueRecord.sid);
LittleEndian.putShort(data, 2 + offset, (short) sizeExcludingHeader);
}
}

View File

@ -38,23 +38,23 @@ import org.apache.poi.util.LittleEndianOutput;
* @author Marc Johnson (mjohnson at apache dot org)
* @author Glen Stampoultzis (glens at apache.org)
*/
public final class UnicodeString implements Comparable {
public final class UnicodeString implements Comparable<UnicodeString> {
private short field_1_charCount;
private byte field_2_optionflags;
private String field_3_string;
private List field_4_format_runs;
private List<FormatRun> field_4_format_runs;
private byte[] field_5_ext_rst;
private static final BitField highByte = BitFieldFactory.getInstance(0x1);
private static final BitField extBit = BitFieldFactory.getInstance(0x4);
private static final BitField richText = BitFieldFactory.getInstance(0x8);
public static class FormatRun implements Comparable {
short character;
short fontIndex;
public static class FormatRun implements Comparable<FormatRun> {
final short _character;
short _fontIndex;
public FormatRun(short character, short fontIndex) {
this.character = character;
this.fontIndex = fontIndex;
this._character = character;
this._fontIndex = fontIndex;
}
public FormatRun(LittleEndianInput in) {
@ -62,11 +62,11 @@ public final class UnicodeString implements Comparable {
}
public short getCharacterPos() {
return character;
return _character;
}
public short getFontIndex() {
return fontIndex;
return _fontIndex;
}
public boolean equals(Object o) {
@ -75,25 +75,26 @@ public final class UnicodeString implements Comparable {
}
FormatRun other = ( FormatRun ) o;
return character == other.character && fontIndex == other.fontIndex;
return _character == other._character && _fontIndex == other._fontIndex;
}
public int compareTo(Object obj) {
FormatRun r = (FormatRun)obj;
if ((character == r.character) && (fontIndex == r.fontIndex))
public int compareTo(FormatRun r) {
if (_character == r._character && _fontIndex == r._fontIndex) {
return 0;
if (character == r.character)
return fontIndex - r.fontIndex;
else return character - r.character;
}
if (_character == r._character) {
return _fontIndex - r._fontIndex;
}
return _character - r._character;
}
public String toString() {
return "character="+character+",fontIndex="+fontIndex;
return "character="+_character+",fontIndex="+_fontIndex;
}
public void serialize(LittleEndianOutput out) {
out.writeShort(character);
out.writeShort(fontIndex);
out.writeShort(_character);
out.writeShort(_fontIndex);
}
}
@ -151,8 +152,8 @@ public final class UnicodeString implements Comparable {
return false;
for (int i=0;i<size;i++) {
FormatRun run1 = (FormatRun)field_4_format_runs.get(i);
FormatRun run2 = (FormatRun)other.field_4_format_runs.get(i);
FormatRun run1 = field_4_format_runs.get(i);
FormatRun run2 = other.field_4_format_runs.get(i);
if (!run1.equals(run2))
return false;
@ -209,7 +210,7 @@ public final class UnicodeString implements Comparable {
if (isRichText() && (runCount > 0)) {
field_4_format_runs = new ArrayList(runCount);
field_4_format_runs = new ArrayList<FormatRun>(runCount);
for (int i=0;i<runCount;i++) {
field_4_format_runs.add(new FormatRun(in));
}
@ -328,20 +329,22 @@ public final class UnicodeString implements Comparable {
}
public FormatRun getFormatRun(int index) {
if (field_4_format_runs == null)
if (field_4_format_runs == null) {
return null;
if ((index < 0) || (index >= field_4_format_runs.size()))
}
if (index < 0 || index >= field_4_format_runs.size()) {
return null;
return (FormatRun)field_4_format_runs.get(index);
}
return field_4_format_runs.get(index);
}
private int findFormatRunAt(int characterPos) {
int size = field_4_format_runs.size();
for (int i=0;i<size;i++) {
FormatRun r = (FormatRun)field_4_format_runs.get(i);
if (r.character == characterPos)
FormatRun r = field_4_format_runs.get(i);
if (r._character == characterPos)
return i;
else if (r.character > characterPos)
else if (r._character > characterPos)
return -1;
}
return -1;
@ -353,10 +356,11 @@ public final class UnicodeString implements Comparable {
* replaced with the font run to be added.
*/
public void addFormatRun(FormatRun r) {
if (field_4_format_runs == null)
field_4_format_runs = new ArrayList();
if (field_4_format_runs == null) {
field_4_format_runs = new ArrayList<FormatRun>();
}
int index = findFormatRunAt(r.character);
int index = findFormatRunAt(r._character);
if (index != -1)
field_4_format_runs.remove(index);
@ -369,9 +373,10 @@ public final class UnicodeString implements Comparable {
field_2_optionflags = richText.setByte(field_2_optionflags);
}
public Iterator formatIterator() {
if (field_4_format_runs != null)
public Iterator<FormatRun> formatIterator() {
if (field_4_format_runs != null) {
return field_4_format_runs.iterator();
}
return null;
}
@ -404,11 +409,9 @@ public final class UnicodeString implements Comparable {
* removed / re-ordered
*/
public void swapFontUse(short oldFontIndex, short newFontIndex) {
Iterator i = field_4_format_runs.iterator();
while(i.hasNext()) {
FormatRun run = (FormatRun)i.next();
if(run.fontIndex == oldFontIndex) {
run.fontIndex = newFontIndex;
for (FormatRun run : field_4_format_runs) {
if(run._fontIndex == oldFontIndex) {
run._fontIndex = newFontIndex;
}
}
}
@ -431,7 +434,6 @@ public final class UnicodeString implements Comparable {
* @return String of output for biffviewer etc.
*
*/
public String getDebugInfo()
{
StringBuffer buffer = new StringBuffer();
@ -444,7 +446,7 @@ public final class UnicodeString implements Comparable {
buffer.append(" .string = ").append(getString()).append("\n");
if (field_4_format_runs != null) {
for (int i = 0; i < field_4_format_runs.size();i++) {
FormatRun r = (FormatRun)field_4_format_runs.get(i);
FormatRun r = field_4_format_runs.get(i);
buffer.append(" .format_run"+i+" = ").append(r.toString()).append("\n");
}
}
@ -474,7 +476,7 @@ public final class UnicodeString implements Comparable {
if (out.getAvailableSpace() < 4) {
out.writeContinue();
}
FormatRun r = (FormatRun)field_4_format_runs.get(i);
FormatRun r = field_4_format_runs.get(i);
r.serialize(out);
}
}
@ -496,9 +498,7 @@ public final class UnicodeString implements Comparable {
}
}
public int compareTo(Object obj)
{
UnicodeString str = ( UnicodeString ) obj;
public int compareTo(UnicodeString str) {
int result = getString().compareTo(str.getString());
@ -524,8 +524,8 @@ public final class UnicodeString implements Comparable {
return size - str.field_4_format_runs.size();
for (int i=0;i<size;i++) {
FormatRun run1 = (FormatRun)field_4_format_runs.get(i);
FormatRun run2 = (FormatRun)str.field_4_format_runs.get(i);
FormatRun run1 = field_4_format_runs.get(i);
FormatRun run2 = str.field_4_format_runs.get(i);
result = run1.compareTo(run2);
if (result != 0)
@ -571,11 +571,9 @@ public final class UnicodeString implements Comparable {
str.field_2_optionflags = field_2_optionflags;
str.field_3_string = field_3_string;
if (field_4_format_runs != null) {
str.field_4_format_runs = new ArrayList();
int size = field_4_format_runs.size();
for (int i = 0; i < size; i++) {
FormatRun r = (FormatRun) field_4_format_runs.get(i);
str.field_4_format_runs.add(new FormatRun(r.character, r.fontIndex));
str.field_4_format_runs = new ArrayList<FormatRun>();
for (FormatRun r : field_4_format_runs) {
str.field_4_format_runs.add(new FormatRun(r._character, r._fontIndex));
}
}
if (field_5_ext_rst != null) {

View File

@ -29,9 +29,9 @@ import java.util.StringTokenizer;
*/
public class FontDetails
{
private String fontName;
private int height;
private Map charWidths = new HashMap();
private String _fontName;
private int _height;
private final Map<Character, Integer> charWidths = new HashMap<Character, Integer>();
/**
* Construct the font details with the given name and height.
@ -41,18 +41,18 @@ public class FontDetails
*/
public FontDetails( String fontName, int height )
{
this.fontName = fontName;
this.height = height;
_fontName = fontName;
_height = height;
}
public String getFontName()
{
return fontName;
return _fontName;
}
public int getHeight()
{
return height;
return _height;
}
public void addChar( char c, int width )
@ -68,9 +68,9 @@ public class FontDetails
public int getCharWidth( char c )
{
Integer widthInteger = (Integer)(charWidths.get(new Character(c)));
if (widthInteger == null && c != 'W')
if (widthInteger == null && c != 'W') {
return getCharWidth('W');
else
}
return widthInteger.intValue();
}
@ -173,6 +173,4 @@ public class FontDetails
return list;
}
}

View File

@ -29,20 +29,16 @@ import org.apache.poi.ss.usermodel.Font;
/**
* High level representation of the style of a cell in a sheet of a workbook.
*
* @version 1.0-pre
*
* @author Andrew C. Oliver (acoliver at apache dot org)
* @author Jason Height (jheight at chariot dot net dot au)
* @see org.apache.poi.hssf.usermodel.HSSFWorkbook#createCellStyle()
* @see org.apache.poi.hssf.usermodel.HSSFWorkbook#getCellStyleAt(short)
* @see org.apache.poi.hssf.usermodel.HSSFCell#setCellStyle(HSSFCellStyle)
*/
public class HSSFCellStyle implements CellStyle
{
private ExtendedFormatRecord format = null;
private short index = 0;
private Workbook workbook = null;
public final class HSSFCellStyle implements CellStyle {
private ExtendedFormatRecord _format = null;
private short _index = 0;
private Workbook _workbook = null;
/** Creates new HSSFCellStyle why would you want to do this?? */
@ -52,9 +48,9 @@ public class HSSFCellStyle implements CellStyle
}
protected HSSFCellStyle(short index, ExtendedFormatRecord rec, Workbook workbook)
{
this.workbook = workbook;
this.index = index;
format = rec;
_workbook = workbook;
_index = index;
_format = rec;
}
/**
@ -62,10 +58,9 @@ public class HSSFCellStyle implements CellStyle
* @return unique index number of the underlying record this style represents (probably you don't care
* unless you're comparing which one is which)
*/
public short getIndex()
{
return index;
return _index;
}
/**
@ -74,13 +69,13 @@ public class HSSFCellStyle implements CellStyle
* cases there'll be a fully defined parent.
*/
public HSSFCellStyle getParentStyle() {
if(format.getParentIndex() == 0) {
if(_format.getParentIndex() == 0) {
return null;
}
return new HSSFCellStyle(
format.getParentIndex(),
workbook.getExFormatAt(format.getParentIndex()),
workbook
_format.getParentIndex(),
_workbook.getExFormatAt(_format.getParentIndex()),
_workbook
);
}
@ -88,10 +83,9 @@ public class HSSFCellStyle implements CellStyle
* set the data format (must be a valid format)
* @see org.apache.poi.hssf.usermodel.HSSFDataFormat
*/
public void setDataFormat(short fmt)
{
format.setFormatIndex(fmt);
_format.setFormatIndex(fmt);
}
/**
@ -101,7 +95,7 @@ public class HSSFCellStyle implements CellStyle
public short getDataFormat()
{
return format.getFormatIndex();
return _format.getFormatIndex();
}
/**
@ -111,7 +105,7 @@ public class HSSFCellStyle implements CellStyle
* @return the format string or "General" if not found
*/
public String getDataFormatString() {
return getDataFormatString(workbook);
return getDataFormatString(_workbook);
}
/**
* Get the contents of the format string, by looking up
@ -147,9 +141,9 @@ public class HSSFCellStyle implements CellStyle
setFont((HSSFFont)font);
}
public void setFont(HSSFFont font) {
format.setIndentNotParentFont(true);
_format.setIndentNotParentFont(true);
short fontindex = font.getIndex();
format.setFontIndex(fontindex);
_format.setFontIndex(fontindex);
}
/**
@ -158,7 +152,7 @@ public class HSSFCellStyle implements CellStyle
*/
public short getFontIndex()
{
return format.getFontIndex();
return _format.getFontIndex();
}
/**
@ -175,42 +169,38 @@ public class HSSFCellStyle implements CellStyle
* set the cell's using this style to be hidden
* @param hidden - whether the cell using this style should be hidden
*/
public void setHidden(boolean hidden)
{
format.setIndentNotParentCellOptions(true);
format.setHidden(hidden);
_format.setIndentNotParentCellOptions(true);
_format.setHidden(hidden);
}
/**
* get whether the cell's using this style are to be hidden
* @return hidden - whether the cell using this style should be hidden
*/
public boolean getHidden()
{
return format.isHidden();
return _format.isHidden();
}
/**
* set the cell's using this style to be locked
* @param locked - whether the cell using this style should be locked
*/
public void setLocked(boolean locked)
{
format.setIndentNotParentCellOptions(true);
format.setLocked(locked);
_format.setIndentNotParentCellOptions(true);
_format.setLocked(locked);
}
/**
* get whether the cell's using this style are to be locked
* @return hidden - whether the cell using this style should be locked
*/
public boolean getLocked()
{
return format.isLocked();
return _format.isLocked();
}
/**
@ -224,11 +214,10 @@ public class HSSFCellStyle implements CellStyle
* @see #ALIGN_JUSTIFY
* @see #ALIGN_CENTER_SELECTION
*/
public void setAlignment(short align)
{
format.setIndentNotParentAlignment(true);
format.setAlignment(align);
_format.setIndentNotParentAlignment(true);
_format.setAlignment(align);
}
/**
@ -242,31 +231,28 @@ public class HSSFCellStyle implements CellStyle
* @see #ALIGN_JUSTIFY
* @see #ALIGN_CENTER_SELECTION
*/
public short getAlignment()
{
return format.getAlignment();
return _format.getAlignment();
}
/**
* set whether the text should be wrapped
* @param wrapped wrap text or not
*/
public void setWrapText(boolean wrapped)
{
format.setIndentNotParentAlignment(true);
format.setWrapText(wrapped);
_format.setIndentNotParentAlignment(true);
_format.setWrapText(wrapped);
}
/**
* get whether the text should be wrapped
* @return wrap text or not
*/
public boolean getWrapText()
{
return format.getWrapText();
return _format.getWrapText();
}
/**
@ -277,10 +263,9 @@ public class HSSFCellStyle implements CellStyle
* @see #VERTICAL_BOTTOM
* @see #VERTICAL_JUSTIFY
*/
public void setVerticalAlignment(short align)
{
format.setVerticalAlignment(align);
_format.setVerticalAlignment(align);
}
/**
@ -291,17 +276,15 @@ public class HSSFCellStyle implements CellStyle
* @see #VERTICAL_BOTTOM
* @see #VERTICAL_JUSTIFY
*/
public short getVerticalAlignment()
{
return format.getVerticalAlignment();
return _format.getVerticalAlignment();
}
/**
* set the degree of rotation for the text in the cell
* @param rotation degrees (between -90 and 90 degrees)
*/
public void setRotation(short rotation)
{
if ((rotation < 0)&&(rotation >= -90)) {
@ -312,17 +295,16 @@ public class HSSFCellStyle implements CellStyle
else if ((rotation < -90) ||(rotation > 90))
//Do not allow an incorrect rotation to be set
throw new IllegalArgumentException("The rotation must be between -90 and 90 degrees");
format.setRotation(rotation);
_format.setRotation(rotation);
}
/**
* get the degree of rotation for the text in the cell
* @return rotation degrees (between -90 and 90 degrees)
*/
public short getRotation()
{
short rotation = format.getRotation();
short rotation = _format.getRotation();
if (rotation > 90)
//This is actually the 4th quadrant
rotation = (short)(90-rotation);
@ -333,20 +315,18 @@ public class HSSFCellStyle implements CellStyle
* set the number of spaces to indent the text in the cell
* @param indent - number of spaces
*/
public void setIndention(short indent)
{
format.setIndent(indent);
_format.setIndent(indent);
}
/**
* get the number of spaces to indent the text in the cell
* @return indent - number of spaces
*/
public short getIndention()
{
return format.getIndent();
return _format.getIndent();
}
/**
@ -367,11 +347,10 @@ public class HSSFCellStyle implements CellStyle
* @see #BORDER_MEDIUM_DASH_DOT_DOT
* @see #BORDER_SLANTED_DASH_DOT
*/
public void setBorderLeft(short border)
{
format.setIndentNotParentBorder(true);
format.setBorderLeft(border);
_format.setIndentNotParentBorder(true);
_format.setBorderLeft(border);
}
/**
@ -392,10 +371,9 @@ public class HSSFCellStyle implements CellStyle
* @see #BORDER_MEDIUM_DASH_DOT_DOT
* @see #BORDER_SLANTED_DASH_DOT
*/
public short getBorderLeft()
{
return format.getBorderLeft();
return _format.getBorderLeft();
}
/**
@ -416,11 +394,10 @@ public class HSSFCellStyle implements CellStyle
* @see #BORDER_MEDIUM_DASH_DOT_DOT
* @see #BORDER_SLANTED_DASH_DOT
*/
public void setBorderRight(short border)
{
format.setIndentNotParentBorder(true);
format.setBorderRight(border);
_format.setIndentNotParentBorder(true);
_format.setBorderRight(border);
}
/**
@ -441,10 +418,9 @@ public class HSSFCellStyle implements CellStyle
* @see #BORDER_MEDIUM_DASH_DOT_DOT
* @see #BORDER_SLANTED_DASH_DOT
*/
public short getBorderRight()
{
return format.getBorderRight();
return _format.getBorderRight();
}
/**
@ -465,11 +441,10 @@ public class HSSFCellStyle implements CellStyle
* @see #BORDER_MEDIUM_DASH_DOT_DOT
* @see #BORDER_SLANTED_DASH_DOT
*/
public void setBorderTop(short border)
{
format.setIndentNotParentBorder(true);
format.setBorderTop(border);
_format.setIndentNotParentBorder(true);
_format.setBorderTop(border);
}
/**
@ -490,10 +465,9 @@ public class HSSFCellStyle implements CellStyle
* @see #BORDER_MEDIUM_DASH_DOT_DOT
* @see #BORDER_SLANTED_DASH_DOT
*/
public short getBorderTop()
{
return format.getBorderTop();
return _format.getBorderTop();
}
/**
@ -514,11 +488,10 @@ public class HSSFCellStyle implements CellStyle
* @see #BORDER_MEDIUM_DASH_DOT_DOT
* @see #BORDER_SLANTED_DASH_DOT
*/
public void setBorderBottom(short border)
{
format.setIndentNotParentBorder(true);
format.setBorderBottom(border);
_format.setIndentNotParentBorder(true);
_format.setBorderBottom(border);
}
/**
@ -541,7 +514,7 @@ public class HSSFCellStyle implements CellStyle
*/
public short getBorderBottom()
{
return format.getBorderBottom();
return _format.getBorderBottom();
}
/**
@ -550,7 +523,7 @@ public class HSSFCellStyle implements CellStyle
*/
public void setLeftBorderColor(short color)
{
format.setLeftBorderPaletteIdx(color);
_format.setLeftBorderPaletteIdx(color);
}
/**
@ -560,7 +533,7 @@ public class HSSFCellStyle implements CellStyle
*/
public short getLeftBorderColor()
{
return format.getLeftBorderPaletteIdx();
return _format.getLeftBorderPaletteIdx();
}
/**
@ -569,7 +542,7 @@ public class HSSFCellStyle implements CellStyle
*/
public void setRightBorderColor(short color)
{
format.setRightBorderPaletteIdx(color);
_format.setRightBorderPaletteIdx(color);
}
/**
@ -579,7 +552,7 @@ public class HSSFCellStyle implements CellStyle
*/
public short getRightBorderColor()
{
return format.getRightBorderPaletteIdx();
return _format.getRightBorderPaletteIdx();
}
/**
@ -588,7 +561,7 @@ public class HSSFCellStyle implements CellStyle
*/
public void setTopBorderColor(short color)
{
format.setTopBorderPaletteIdx(color);
_format.setTopBorderPaletteIdx(color);
}
/**
@ -598,7 +571,7 @@ public class HSSFCellStyle implements CellStyle
*/
public short getTopBorderColor()
{
return format.getTopBorderPaletteIdx();
return _format.getTopBorderPaletteIdx();
}
/**
@ -607,7 +580,7 @@ public class HSSFCellStyle implements CellStyle
*/
public void setBottomBorderColor(short color)
{
format.setBottomBorderPaletteIdx(color);
_format.setBottomBorderPaletteIdx(color);
}
/**
@ -617,7 +590,7 @@ public class HSSFCellStyle implements CellStyle
*/
public short getBottomBorderColor()
{
return format.getBottomBorderPaletteIdx();
return _format.getBottomBorderPaletteIdx();
}
/**
@ -646,17 +619,16 @@ public class HSSFCellStyle implements CellStyle
*/
public void setFillPattern(short fp)
{
format.setAdtlFillPattern(fp);
_format.setAdtlFillPattern(fp);
}
/**
* get the fill pattern (??) - set to 1 to fill with foreground color
* @return fill pattern
*/
public short getFillPattern()
{
return format.getAdtlFillPattern();
return _format.getAdtlFillPattern();
}
/**
@ -670,15 +642,15 @@ public class HSSFCellStyle implements CellStyle
* <p>0x40 0xSOMETHING</p>
*/
private void checkDefaultBackgroundFills() {
if (format.getFillForeground() == org.apache.poi.hssf.util.HSSFColor.AUTOMATIC.index) {
if (_format.getFillForeground() == org.apache.poi.hssf.util.HSSFColor.AUTOMATIC.index) {
//JMH: Why +1, hell why not. I guess it made some sense to someone at the time. Doesnt
//to me now.... But experience has shown that when the fore is set to AUTOMATIC then the
//background needs to be incremented......
if (format.getFillBackground() != (org.apache.poi.hssf.util.HSSFColor.AUTOMATIC.index+1))
if (_format.getFillBackground() != (org.apache.poi.hssf.util.HSSFColor.AUTOMATIC.index+1))
setFillBackgroundColor((short)(org.apache.poi.hssf.util.HSSFColor.AUTOMATIC.index+1));
} else if (format.getFillBackground() == org.apache.poi.hssf.util.HSSFColor.AUTOMATIC.index+1)
} else if (_format.getFillBackground() == org.apache.poi.hssf.util.HSSFColor.AUTOMATIC.index+1)
//Now if the forground changes to a non-AUTOMATIC color the background resets itself!!!
if (format.getFillForeground() != org.apache.poi.hssf.util.HSSFColor.AUTOMATIC.index)
if (_format.getFillForeground() != org.apache.poi.hssf.util.HSSFColor.AUTOMATIC.index)
setFillBackgroundColor(org.apache.poi.hssf.util.HSSFColor.AUTOMATIC.index);
}
@ -707,10 +679,9 @@ public class HSSFCellStyle implements CellStyle
*
* @param bg color
*/
public void setFillBackgroundColor(short bg)
{
format.setFillBackground(bg);
_format.setFillBackground(bg);
checkDefaultBackgroundFills();
}
@ -723,12 +694,13 @@ public class HSSFCellStyle implements CellStyle
*/
public short getFillBackgroundColor()
{
short result = format.getFillBackground();
short result = _format.getFillBackground();
//JMH: Do this ridiculous conversion, and let HSSFCellStyle
//internally migrate back and forth
if (result == (HSSFColor.AUTOMATIC.index+1))
if (result == (HSSFColor.AUTOMATIC.index+1)) {
return HSSFColor.AUTOMATIC.index;
else return result;
}
return result;
}
/**
@ -738,7 +710,7 @@ public class HSSFCellStyle implements CellStyle
*/
public void setFillForegroundColor(short bg)
{
format.setFillForeground(bg);
_format.setFillForeground(bg);
checkDefaultBackgroundFills();
}
@ -751,7 +723,7 @@ public class HSSFCellStyle implements CellStyle
*/
public short getFillForegroundColor()
{
return format.getFillForeground();
return _format.getFillForeground();
}
/**
@ -760,7 +732,7 @@ public class HSSFCellStyle implements CellStyle
* styles where no name has been defined
*/
public String getUserStyleName() {
StyleRecord sr = workbook.getStyleRecord(index);
StyleRecord sr = _workbook.getStyleRecord(_index);
if(sr == null) {
return null;
}
@ -775,9 +747,9 @@ public class HSSFCellStyle implements CellStyle
* Will complain if you try this on a built in style.
*/
public void setUserStyleName(String styleName) {
StyleRecord sr = workbook.getStyleRecord(index);
StyleRecord sr = _workbook.getStyleRecord(_index);
if(sr == null) {
sr = workbook.createStyleRecord(index);
sr = _workbook.createStyleRecord(_index);
}
if(sr.isBuiltin()) {
throw new IllegalArgumentException("Unable to set user specified style names for built in styles!");
@ -794,7 +766,7 @@ public class HSSFCellStyle implements CellStyle
* @throws IllegalArgumentException if there's a workbook mis-match
*/
public void verifyBelongsToWorkbook(HSSFWorkbook wb) {
if(wb.getWorkbook() != workbook) {
if(wb.getWorkbook() != _workbook) {
throw new IllegalArgumentException("This Style does not belong to the supplied Workbook. Are you trying to assign a style from one workbook to the cell of a differnt workbook?");
}
}
@ -821,26 +793,26 @@ public class HSSFCellStyle implements CellStyle
public void cloneStyleFrom(HSSFCellStyle source) {
// First we need to clone the extended format
// record
format.cloneStyleFrom(source.format);
_format.cloneStyleFrom(source._format);
// Handle matching things if we cross workbooks
if(workbook != source.workbook) {
if(_workbook != source._workbook) {
// Then we need to clone the format string,
// and update the format record for this
short fmt = (short)workbook.createFormat(source.getDataFormatString() );
short fmt = (short)_workbook.createFormat(source.getDataFormatString() );
setDataFormat(fmt);
// Finally we need to clone the font,
// and update the format record for this
FontRecord fr = workbook.createNewFont();
FontRecord fr = _workbook.createNewFont();
fr.cloneStyleFrom(
source.workbook.getFontRecordAt(
source._workbook.getFontRecordAt(
source.getFontIndex()
)
);
HSSFFont font = new HSSFFont(
(short)workbook.getFontIndex(fr), fr
(short)_workbook.getFontIndex(fr), fr
);
setFont(font);
}
@ -850,8 +822,8 @@ public class HSSFCellStyle implements CellStyle
public int hashCode() {
final int prime = 31;
int result = 1;
result = prime * result + ((format == null) ? 0 : format.hashCode());
result = prime * result + index;
result = prime * result + ((_format == null) ? 0 : _format.hashCode());
result = prime * result + _index;
return result;
}
@ -860,12 +832,12 @@ public class HSSFCellStyle implements CellStyle
if (obj == null) return false;
if (obj instanceof HSSFCellStyle) {
final HSSFCellStyle other = (HSSFCellStyle) obj;
if (format == null) {
if (other.format != null)
if (_format == null) {
if (other._format != null)
return false;
} else if (!format.equals(other.format))
} else if (!_format.equals(other._format))
return false;
if (index != other.index)
if (_index != other._index)
return false;
return true;
}

View File

@ -26,9 +26,7 @@ import org.apache.poi.ss.usermodel.ClientAnchor;
*
* @author Glen Stampoultzis (glens at apache.org)
*/
public class HSSFClientAnchor
extends HSSFAnchor implements ClientAnchor
{
public final class HSSFClientAnchor extends HSSFAnchor implements ClientAnchor {
short col1;
int row1;
short col2;
@ -108,9 +106,9 @@ public class HSSFClientAnchor
private float getRowHeightInPoints(HSSFSheet sheet, int rowNum)
{
HSSFRow row = sheet.getRow(rowNum);
if (row == null)
if (row == null) {
return sheet.getDefaultRowHeightInPoints();
else
}
return row.getHeightInPoints();
}
@ -204,9 +202,9 @@ public class HSSFClientAnchor
*/
public boolean isHorizontallyFlipped()
{
if (col1 == col2)
if (col1 == col2) {
return dx1 > dx2;
else
}
return col1 > col2;
}
@ -215,9 +213,9 @@ public class HSSFClientAnchor
*/
public boolean isVerticallyFlipped()
{
if (row1 == row2)
if (row1 == row2) {
return dy1 > dy2;
else
}
return row1 > row2;
}

View File

@ -23,6 +23,7 @@ import java.util.Iterator;
import org.apache.poi.hssf.record.EmbeddedObjectRefSubRecord;
import org.apache.poi.hssf.record.ObjRecord;
import org.apache.poi.hssf.record.SubRecord;
import org.apache.poi.poifs.filesystem.DirectoryEntry;
import org.apache.poi.poifs.filesystem.Entry;
import org.apache.poi.poifs.filesystem.POIFSFileSystem;
@ -33,17 +34,16 @@ import org.apache.poi.util.HexDump;
*
* @author Daniel Noll
*/
public final class HSSFObjectData
{
public final class HSSFObjectData {
/**
* Underlying object record ultimately containing a reference to the object.
*/
private ObjRecord record;
private final ObjRecord _record;
/**
* Reference to the filesystem, required for retrieving the object data.
*/
private POIFSFileSystem poifs;
private final POIFSFileSystem _poifs;
/**
* Constructs object data by wrapping a lower level object record.
@ -53,8 +53,8 @@ public final class HSSFObjectData
*/
public HSSFObjectData(ObjRecord record, POIFSFileSystem poifs)
{
this.record = record;
this.poifs = poifs;
_record = record;
_poifs = poifs;
}
/**
@ -77,12 +77,11 @@ public final class HSSFObjectData
int streamId = subRecord.getStreamId().intValue();
String streamName = "MBD" + HexDump.toHex(streamId);
Entry entry = poifs.getRoot().getEntry(streamName);
Entry entry = _poifs.getRoot().getEntry(streamName);
if (entry instanceof DirectoryEntry) {
return (DirectoryEntry) entry;
} else {
throw new IOException("Stream " + streamName + " was not an OLE2 directory");
}
throw new IOException("Stream " + streamName + " was not an OLE2 directory");
}
/**
@ -112,7 +111,7 @@ public final class HSSFObjectData
* Exception if there wasn't one
*/
protected EmbeddedObjectRefSubRecord findObjectRecord() {
Iterator subRecordIter = record.getSubRecords().iterator();
Iterator<SubRecord> subRecordIter = _record.getSubRecords().iterator();
while (subRecordIter.hasNext()) {
Object subRecord = subRecordIter.next();

View File

@ -31,40 +31,39 @@ import org.apache.poi.ss.usermodel.RichTextString;
* @author Glen Stampoultzis (glens at apache.org)
* @author Jason Height (jheight at apache.org)
*/
public class HSSFRichTextString
implements Comparable, RichTextString
{
public final class HSSFRichTextString implements Comparable<HSSFRichTextString>, RichTextString {
/** Place holder for indicating that NO_FONT has been applied here */
public static final short NO_FONT = 0;
private UnicodeString string;
private Workbook book;
private LabelSSTRecord record;
private UnicodeString _string;
private Workbook _book;
private LabelSSTRecord _record;
public HSSFRichTextString()
{
this("");
}
public HSSFRichTextString( String string )
{
if (string == null)
string = "";
this.string = new UnicodeString(string);
public HSSFRichTextString(String string) {
if (string == null) {
_string = new UnicodeString("");
} else {
_string = new UnicodeString(string);
}
}
HSSFRichTextString(Workbook book, LabelSSTRecord record) {
setWorkbookReferences(book, record);
this.string = book.getSSTString(record.getSSTIndex());
_string = book.getSSTString(record.getSSTIndex());
}
/** This must be called to setup the internal work book references whenever
* a RichTextString is added to a cell
*/
void setWorkbookReferences(Workbook book, LabelSSTRecord record) {
this.book = book;
this.record = record;
_book = book;
_record = record;
}
/** Called whenever the unicode string is modified. When it is modified
@ -72,19 +71,19 @@ public class HSSFRichTextString
* be affected by changes that we make to this string.
*/
private UnicodeString cloneStringIfRequired() {
if (book == null)
return string;
UnicodeString s = (UnicodeString)string.clone();
if (_book == null)
return _string;
UnicodeString s = (UnicodeString)_string.clone();
return s;
}
private void addToSSTIfRequired() {
if (book != null) {
int index = book.addSSTString(string);
record.setSSTIndex(index);
if (_book != null) {
int index = _book.addSSTString(_string);
_record.setSSTIndex(index);
//The act of adding the string to the SST record may have meant that
//a extsing string was returned for the index, so update our local version
string = book.getSSTString(index);
//an existing string was returned for the index, so update our local version
_string = _book.getSSTString(index);
}
}
@ -113,8 +112,8 @@ public class HSSFRichTextString
}
//Need to clear the current formatting between the startIndex and endIndex
string = cloneStringIfRequired();
Iterator formatting = string.formatIterator();
_string = cloneStringIfRequired();
Iterator formatting = _string.formatIterator();
if (formatting != null) {
while (formatting.hasNext()) {
UnicodeString.FormatRun r = (UnicodeString.FormatRun)formatting.next();
@ -124,9 +123,9 @@ public class HSSFRichTextString
}
string.addFormatRun(new UnicodeString.FormatRun((short)startIndex, fontIndex));
_string.addFormatRun(new UnicodeString.FormatRun((short)startIndex, fontIndex));
if (endIndex != length())
string.addFormatRun(new UnicodeString.FormatRun((short)endIndex, currentFont));
_string.addFormatRun(new UnicodeString.FormatRun((short)endIndex, currentFont));
addToSSTIfRequired();
}
@ -149,15 +148,15 @@ public class HSSFRichTextString
*/
public void applyFont(Font font)
{
applyFont(0, string.getCharCount(), font);
applyFont(0, _string.getCharCount(), font);
}
/**
* Removes any formatting that may have been applied to the string.
*/
public void clearFormatting() {
string = cloneStringIfRequired();
string.clearFormatting();
_string = cloneStringIfRequired();
_string.clearFormatting();
addToSSTIfRequired();
}
@ -166,7 +165,7 @@ public class HSSFRichTextString
*/
public String getString()
{
return string.getString();
return _string.getString();
}
/**
@ -186,12 +185,12 @@ public class HSSFRichTextString
* other RichTextStrings too!
*/
UnicodeString getRawUnicodeString() {
return string;
return _string;
}
/** Used internally by the HSSFCell to set the internal string value*/
void setUnicodeString(UnicodeString str) {
this.string = str;
this._string = str;
}
@ -199,7 +198,7 @@ public class HSSFRichTextString
* @return the number of characters in the text.
*/
public int length() {
return string.getCharCount();
return _string.getCharCount();
}
/**
@ -212,17 +211,19 @@ public class HSSFRichTextString
*/
public short getFontAtIndex( int index )
{
int size = string.getFormatRunCount();
int size = _string.getFormatRunCount();
UnicodeString.FormatRun currentRun = null;
for (int i=0;i<size;i++) {
UnicodeString.FormatRun r = string.getFormatRun(i);
if (r.getCharacterPos() > index)
UnicodeString.FormatRun r = _string.getFormatRun(i);
if (r.getCharacterPos() > index) {
break;
else currentRun = r;
}
if (currentRun == null)
currentRun = r;
}
if (currentRun == null) {
return NO_FONT;
else return currentRun.getFontIndex();
}
return currentRun.getFontIndex();
}
/**
@ -233,7 +234,7 @@ public class HSSFRichTextString
*/
public int numFormattingRuns()
{
return string.getFormatRunCount();
return _string.getFormatRunCount();
}
/**
@ -243,7 +244,7 @@ public class HSSFRichTextString
*/
public int getIndexOfFormattingRun(int index)
{
UnicodeString.FormatRun r = string.getFormatRun(index);
UnicodeString.FormatRun r = _string.getFormatRun(index);
return r.getCharacterPos();
}
@ -255,22 +256,20 @@ public class HSSFRichTextString
*/
public short getFontOfFormattingRun(int index)
{
UnicodeString.FormatRun r = string.getFormatRun(index);
UnicodeString.FormatRun r = _string.getFormatRun(index);
return r.getFontIndex();
}
/**
* Compares one rich text string to another.
*/
public int compareTo( Object o )
{
HSSFRichTextString r = (HSSFRichTextString)o;
return string.compareTo(r.string);
public int compareTo(HSSFRichTextString r) {
return _string.compareTo(r._string);
}
public boolean equals(Object o) {
if (o instanceof HSSFRichTextString) {
return string.equals(((HSSFRichTextString)o).string);
return _string.equals(((HSSFRichTextString)o)._string);
}
return false;
@ -281,7 +280,7 @@ public class HSSFRichTextString
*/
public String toString()
{
return string.toString();
return _string.toString();
}
/**
@ -291,6 +290,6 @@ public class HSSFRichTextString
*/
public void applyFont( short fontIndex )
{
applyFont(0, string.getCharCount(), fontIndex);
applyFont(0, _string.getCharCount(), fontIndex);
}
}

View File

@ -17,40 +17,44 @@
package org.apache.poi.hssf.usermodel;
import java.util.*;
import java.awt.*;
import java.io.*;
import java.awt.Font;
import java.io.File;
import java.io.FileInputStream;
import java.io.FileNotFoundException;
import java.io.IOException;
import java.io.InputStream;
import java.util.HashMap;
import java.util.Map;
import java.util.Properties;
/**
* Allows the user to lookup the font metrics for a particular font without
* actually having the font on the system. The font details are loaded
* as a resource from the POI jar file (or classpath) and should be contained
* in path "/font_metrics.properties". The font widths are for a 10 point
* version of the font. Use a multiplier for other sizes.
* actually having the font on the system. The font details are loaded as a
* resource from the POI jar file (or classpath) and should be contained in path
* "/font_metrics.properties". The font widths are for a 10 point version of the
* font. Use a multiplier for other sizes.
*
* @author Glen Stampoultzis (glens at apache.org)
*/
class StaticFontMetrics
{
final class StaticFontMetrics {
/** The font metrics property file we're using */
private static Properties fontMetricsProps;
/** Our cache of font details we've already looked up */
private static Map fontDetailsMap = new HashMap();
private static Map<String, FontDetails> fontDetailsMap = new HashMap<String, FontDetails>();
/**
* Retrieves the fake font details for a given font.
* @param font the font to lookup.
*
* @param font
* the font to lookup.
* @return the fake font.
*/
public static FontDetails getFontDetails(Font font)
{
public static FontDetails getFontDetails(Font font) {
// If we haven't already identified out font metrics file,
// figure out which one to use and load it
if (fontMetricsProps == null)
{
if (fontMetricsProps == null) {
InputStream metricsIn = null;
try
{
try {
fontMetricsProps = new Properties();
// Check to see if the font metric file was specified
@ -58,35 +62,32 @@ class StaticFontMetrics
String propFileName = null;
try {
propFileName = System.getProperty("font.metrics.filename");
} catch(SecurityException e) {}
} catch (SecurityException e) {
}
if (propFileName != null) {
File file = new File(propFileName);
if (!file.exists())
throw new FileNotFoundException("font_metrics.properties not found at path " + file.getAbsolutePath());
throw new FileNotFoundException(
"font_metrics.properties not found at path "
+ file.getAbsolutePath());
metricsIn = new FileInputStream(file);
}
else {
} else {
// Use the built-in font metrics file off the classpath
metricsIn = FontDetails.class.getResourceAsStream("/font_metrics.properties");
if (metricsIn == null)
throw new FileNotFoundException("font_metrics.properties not found in classpath");
throw new FileNotFoundException(
"font_metrics.properties not found in classpath");
}
fontMetricsProps.load(metricsIn);
}
catch ( IOException e )
{
} catch (IOException e) {
throw new RuntimeException("Could not load font metrics: " + e.getMessage());
}
finally
{
if (metricsIn != null)
{
try
{
} finally {
if (metricsIn != null) {
try {
metricsIn.close();
} catch (IOException ignore) {
}
catch ( IOException ignore ) { }
}
}
}
@ -98,14 +99,18 @@ class StaticFontMetrics
// Others have different font instances for bold etc
// (eg font.dialog.plain.* vs font.Californian FB Bold.*)
String fontStyle = "";
if(font.isPlain()) fontStyle += "plain";
if(font.isBold()) fontStyle += "bold";
if(font.isItalic()) fontStyle += "italic";
if (font.isPlain())
fontStyle += "plain";
if (font.isBold())
fontStyle += "bold";
if (font.isItalic())
fontStyle += "italic";
// Do we have a definition for this font with just the name?
// If not, check with the font style added
if(fontMetricsProps.get(FontDetails.buildFontHeightProperty(fontName)) == null &&
fontMetricsProps.get(FontDetails.buildFontHeightProperty(fontName+"."+fontStyle)) != null) {
if (fontMetricsProps.get(FontDetails.buildFontHeightProperty(fontName)) == null
&& fontMetricsProps.get(FontDetails.buildFontHeightProperty(fontName + "."
+ fontStyle)) != null) {
// Need to add on the style to the font name
fontName += "." + fontStyle;
}
@ -115,9 +120,7 @@ class StaticFontMetrics
FontDetails fontDetails = FontDetails.create(fontName, fontMetricsProps);
fontDetailsMap.put(fontName, fontDetails);
return fontDetails;
} else {
return (FontDetails) fontDetailsMap.get(fontName);
}
return fontDetailsMap.get(fontName);
}
}

View File

@ -563,11 +563,8 @@ public class POIFSFileSystem
{
return (( POIFSViewable ) getRoot()).getViewableArray();
}
else
{
return new Object[ 0 ];
}
}
/**
* Get an Iterator of objects, some of which may implement
@ -583,11 +580,8 @@ public class POIFSFileSystem
{
return (( POIFSViewable ) getRoot()).getViewableIterator();
}
else
{
return Collections.EMPTY_LIST.iterator();
}
}
/**
* Give viewers a hint as to whether to call getViewableArray or

View File

@ -399,9 +399,9 @@ public class HexDump {
while (bytesRemaining-- > 0)
{
int c = in.read();
if (c == -1)
if (c == -1) {
break;
else
}
buf.write(c);
}
}

View File

@ -1,4 +1,3 @@
/* ====================================================================
Licensed to the Apache Software Foundation (ASF) under one or more
contributor license agreements. See the NOTICE file distributed with
@ -16,7 +15,6 @@
limitations under the License.
==================================================================== */
package org.apache.poi.util;
import java.io.ByteArrayOutputStream;
@ -24,15 +22,13 @@ import java.io.IOException;
import java.io.InputStream;
import java.io.OutputStream;
public class IOUtils
{
private IOUtils()
{
public final class IOUtils {
private IOUtils() {
// no instances of this class
}
/**
* Reads all the data from the input stream, and returns
* the bytes read.
* Reads all the data from the input stream, and returns the bytes read.
*/
public static byte[] toByteArray(InputStream stream) throws IOException {
ByteArrayOutputStream baos = new ByteArrayOutputStream();
@ -52,44 +48,36 @@ public class IOUtils
/**
* Helper method, just calls <tt>readFully(in, b, 0, b.length)</tt>
*/
public static int readFully(InputStream in, byte[] b)
throws IOException
{
public static int readFully(InputStream in, byte[] b) throws IOException {
return readFully(in, b, 0, b.length);
}
/**
* Same as the normal <tt>in.read(b, off, len)</tt>, but
* tries to ensure that the entire len number of bytes
* is read.
* Same as the normal <tt>in.read(b, off, len)</tt>, but tries to ensure
* that the entire len number of bytes is read.
* <p>
* If the end of file is reached before any bytes
* are read, returns -1.
* If the end of the file is reached after some bytes are
* read, returns the number of bytes read.
* If the end of the file isn't reached before len
* If the end of file is reached before any bytes are read, returns -1. If
* the end of the file is reached after some bytes are read, returns the
* number of bytes read. If the end of the file isn't reached before len
* bytes have been read, will return len bytes.
*/
public static int readFully(InputStream in, byte[] b, int off, int len)
throws IOException
{
public static int readFully(InputStream in, byte[] b, int off, int len) throws IOException {
int total = 0;
for (;;) {
while (true) {
int got = in.read(b, off + total, len - total);
if (got < 0) {
return (total == 0) ? -1 : total;
} else {
}
total += got;
if (total == len)
if (total == len) {
return total;
}
}
}
/**
* Copies all the data from the given InputStream to the
* OutputStream. It leaves both streams open, so you
* will still need to close them once done.
* Copies all the data from the given InputStream to the OutputStream. It
* leaves both streams open, so you will still need to close them once done.
*/
public static void copy(InputStream inp, OutputStream out) throws IOException {
byte[] buff = new byte[4096];

View File

@ -1,4 +1,3 @@
/* ====================================================================
Licensed to the Apache Software Foundation (ASF) under one or more
contributor license agreements. See the NOTICE file distributed with
@ -16,7 +15,6 @@
limitations under the License.
==================================================================== */
package org.apache.poi.util;
@ -33,11 +31,11 @@ package org.apache.poi.util;
*/
public class SystemOutLogger extends POILogger
{
private String cat;
private String _cat;
public void initialize(final String cat)
{
this.cat=cat;
this._cat=cat;
}
/**
@ -62,7 +60,7 @@ public class SystemOutLogger extends POILogger
public void log(final int level, final Object obj1,
final Throwable exception) {
if (check(level)) {
System.out.println("["+cat+"] "+obj1);
System.out.println("["+_cat+"] "+obj1);
if(exception != null) {
exception.printStackTrace(System.out);
}
@ -88,9 +86,9 @@ public class SystemOutLogger extends POILogger
currentLevel = POILogger.DEBUG;
}
if (level >= currentLevel)
if (level >= currentLevel) {
return true;
else
}
return false;
}

View File

@ -37,9 +37,8 @@ import org.apache.poi.openxml4j.util.Nullable;
* Represents the core properties part of a package.
*
* @author Julien Chable
* @version 1.0
*/
public class PackagePropertiesPart extends PackagePart implements
public final class PackagePropertiesPart extends PackagePart implements
PackageProperties {
public final static String NAMESPACE_DC_URI = "http://purl.org/dc/elements/1.1/";
@ -310,11 +309,11 @@ public class PackagePropertiesPart extends PackagePart implements
* @return A string representation of the modified date.
*/
public String getModifiedPropertyString() {
if (!modified.hasValue())
return getDateValue(new Nullable<Date>(new Date()));
else
if (modified.hasValue()) {
return getDateValue(modified);
}
return getDateValue(new Nullable<Date>(new Date()));
}
/**
* Get revision.
@ -545,9 +544,9 @@ public class PackagePropertiesPart extends PackagePart implements
* Convert a strig value into a Nullable<String>
*/
private Nullable<String> setStringValue(String s) {
if (s == null || s.equals(""))
if (s == null || s.equals("")) {
return new Nullable<String>();
else
}
return new Nullable<String>(s);
}
@ -558,16 +557,16 @@ public class PackagePropertiesPart extends PackagePart implements
* Throws if the date format isnot valid.
*/
private Nullable<Date> setDateValue(String s) throws InvalidFormatException {
if (s == null || s.equals(""))
if (s == null || s.equals("")) {
return new Nullable<Date>();
else {
}
SimpleDateFormat df = new SimpleDateFormat(
"yyyy-MM-dd'T'HH:mm:ss'Z'");
Date d = df.parse(s, new ParsePosition(0));
if (d == null)
if (d == null) {
throw new InvalidFormatException("Date not well formated");
return new Nullable<Date>(d);
}
return new Nullable<Date>(d);
}
/**
@ -579,14 +578,13 @@ public class PackagePropertiesPart extends PackagePart implements
* @see java.util.SimpleDateFormat
*/
private String getDateValue(Nullable<Date> d) {
if (d == null || d.equals(""))
if (d == null || d.equals("")) {
return "";
else {
}
SimpleDateFormat df = new SimpleDateFormat(
"yyyy-MM-dd'T'HH:mm:ss'Z'");
return df.format(d.getValue());
}
}
@Override
protected InputStream getInputStreamImpl() {
@ -600,12 +598,12 @@ public class PackagePropertiesPart extends PackagePart implements
}
@Override
public boolean save(OutputStream zos) throws OpenXML4JException {
public boolean save(OutputStream zos) {
throw new InvalidOperationException("Operation not authorized");
}
@Override
public boolean load(InputStream ios) throws InvalidFormatException {
public boolean load(InputStream ios) {
throw new InvalidOperationException("Operation not authorized");
}

View File

@ -78,9 +78,8 @@ public class ZipContentTypeManager extends ContentTypeManager {
if (resultRead == -1) {
// end of file reached
break;
} else {
zos.write(buff, 0, resultRead);
}
zos.write(buff, 0, resultRead);
}
zos.closeEntry();
} catch (IOException ioe) {

View File

@ -58,8 +58,7 @@ public final class ZipHelper {
* @throws OpenXML4JException
* Throws if internal error occurs.
*/
public static ZipEntry getCorePropertiesZipEntry(ZipPackage pkg)
throws OpenXML4JException {
public static ZipEntry getCorePropertiesZipEntry(ZipPackage pkg) {
PackageRelationship corePropsRel = pkg.getRelationshipsByType(
PackageRelationshipTypes.CORE_PROPERTIES).getRelationship(0);
@ -96,9 +95,9 @@ public final class ZipHelper {
public static String getOPCNameFromZipItemName(String zipItemName) {
if (zipItemName == null)
throw new IllegalArgumentException("zipItemName");
if (zipItemName.startsWith(FORWARD_SLASH))
if (zipItemName.startsWith(FORWARD_SLASH)) {
return zipItemName;
else
}
return FORWARD_SLASH + zipItemName;
}

View File

@ -31,7 +31,6 @@ import org.dom4j.Namespace;
import org.dom4j.QName;
import org.dom4j.io.SAXReader;
import org.apache.poi.openxml4j.exceptions.InvalidFormatException;
import org.apache.poi.openxml4j.exceptions.OpenXML4JException;
import org.apache.poi.openxml4j.opc.PackageNamespaces;
import org.apache.poi.openxml4j.opc.PackagePart;
import org.apache.poi.openxml4j.opc.PackageProperties;
@ -44,7 +43,6 @@ import org.apache.poi.openxml4j.opc.internal.ZipHelper;
* Package properties unmarshaller.
*
* @author Julien Chable
* @version 1.0
*/
public final class PackagePropertiesUnmarshaller implements PartUnmarshaller {
@ -110,15 +108,9 @@ public final class PackagePropertiesUnmarshaller implements PartUnmarshaller {
.getInputStream(context.getZipEntry());
} else if (context.getPackage() != null) {
// Try to retrieve the part inputstream from the URI
ZipEntry zipEntry;
try {
zipEntry = ZipHelper
ZipEntry zipEntry = ZipHelper
.getCorePropertiesZipEntry((ZipPackage) context
.getPackage());
} catch (OpenXML4JException e) {
throw new IOException(
"Error while trying to get the part input stream.");
}
in = ((ZipPackage) context.getPackage()).getZipArchive()
.getInputStream(zipEntry);
} else

View File

@ -14,6 +14,7 @@
See the License for the specific language governing permissions and
limitations under the License.
==================================================================== */
package org.apache.poi.util;
import org.apache.poi.openxml4j.opc.*;
@ -31,7 +32,7 @@ import java.net.URI;
*
* @author Yegor Kozlov
*/
public class PackageHelper {
public final class PackageHelper {
/**
* Clone the specified package.
@ -74,10 +75,9 @@ public class PackageHelper {
if (rel.getRelationshipType().equals(PackageRelationshipTypes.CORE_PROPERTIES)) {
copyProperties(pkg.getPackageProperties(), dest.getPackageProperties());
continue;
} else {
}
dest.addRelationship(part.getPartName(), rel.getTargetMode(), rel.getRelationshipType());
part_tgt = dest.createPart(part.getPartName(), part.getContentType());
}
OutputStream out = part_tgt.getOutputStream();
IOUtils.copy(part.getInputStream(), out);
@ -117,18 +117,18 @@ public class PackageHelper {
part_tgt.addExternalRelationship(rel.getTargetURI().toString(), rel.getRelationshipType(), rel.getId());
//external relations don't have associated package parts
continue;
} else {
}
URI uri = rel.getTargetURI();
if(uri.getRawFragment() != null) {
part_tgt.addRelationship(uri, rel.getTargetMode(), rel.getRelationshipType(), rel.getId());
continue;
} else {
}
PackagePartName relName = PackagingURIHelper.createPartName(rel.getTargetURI());
p = pkg.getPart(relName);
part_tgt.addRelationship(p.getPartName(), rel.getTargetMode(), rel.getRelationshipType(), rel.getId());
}
}
PackagePart dest;

View File

@ -440,9 +440,9 @@ public class StylesTable extends POIXMLDocumentPart {
}
protected CTDxf getDxf(int idx) {
if(dxfs.size()==0)
if (dxfs.size()==0) {
return CTDxf.Factory.newInstance();
else
}
return dxfs.get(idx);
}

View File

@ -33,8 +33,6 @@ import org.apache.poi.ss.formula.FormulaRenderer;
import org.apache.poi.ss.SpreadsheetVersion;
import org.apache.poi.xssf.model.StylesTable;
import org.apache.poi.xssf.model.SharedStringsTable;
import org.apache.poi.util.POILogger;
import org.apache.poi.util.POILogFactory;
import org.openxmlformats.schemas.spreadsheetml.x2006.main.CTCell;
import org.openxmlformats.schemas.spreadsheetml.x2006.main.CTCellFormula;
import org.openxmlformats.schemas.spreadsheetml.x2006.main.STCellType;
@ -55,7 +53,6 @@ import org.openxmlformats.schemas.spreadsheetml.x2006.main.STCellFormulaType;
* </p>
*/
public final class XSSFCell implements Cell {
private static POILogger logger = POILogFactory.getLogger(XSSFCell.class);
private static final String FALSE_AS_STRING = "0";
private static final String TRUE_AS_STRING = "1";
@ -64,28 +61,28 @@ public final class XSSFCell implements Cell {
* the xml bean containing information about the cell's location, value,
* data type, formatting, and formula
*/
private final CTCell cell;
private final CTCell _cell;
/**
* the XSSFRow this cell belongs to
*/
private final XSSFRow row;
private final XSSFRow _row;
/**
* 0-based column index
*/
private int cellNum;
private int _cellNum;
/**
* Table of strings shared across this workbook.
* If two cells contain the same string, then the cell value is the same index into SharedStringsTable
*/
private SharedStringsTable sharedStringSource;
private SharedStringsTable _sharedStringSource;
/**
* Table of cell styles shared across all cells in a workbook.
*/
private StylesTable stylesSource;
private StylesTable _stylesSource;
/**
* Construct a XSSFCell.
@ -94,27 +91,27 @@ public final class XSSFCell implements Cell {
* @param cell the xml bean containing information about the cell.
*/
protected XSSFCell(XSSFRow row, CTCell cell) {
this.cell = cell;
this.row = row;
_cell = cell;
_row = row;
if (cell.getR() != null) {
this.cellNum = new CellReference(cell.getR()).getCol();
_cellNum = new CellReference(cell.getR()).getCol();
}
this.sharedStringSource = row.getSheet().getWorkbook().getSharedStringSource();
this.stylesSource = row.getSheet().getWorkbook().getStylesSource();
_sharedStringSource = row.getSheet().getWorkbook().getSharedStringSource();
_stylesSource = row.getSheet().getWorkbook().getStylesSource();
}
/**
* @return table of strings shared across this workbook
*/
protected SharedStringsTable getSharedStringSource() {
return sharedStringSource;
return _sharedStringSource;
}
/**
* @return table of cell styles shared across this workbook
*/
protected StylesTable getStylesSource() {
return stylesSource;
return _stylesSource;
}
/**
@ -132,7 +129,7 @@ public final class XSSFCell implements Cell {
* @return the row this cell belongs to
*/
public XSSFRow getRow() {
return row;
return _row;
}
/**
@ -150,10 +147,10 @@ public final class XSSFCell implements Cell {
case CELL_TYPE_BLANK:
return false;
case CELL_TYPE_BOOLEAN:
return cell.isSetV() && TRUE_AS_STRING.equals(cell.getV());
return _cell.isSetV() && TRUE_AS_STRING.equals(_cell.getV());
case CELL_TYPE_FORMULA:
//YK: should throw an exception if requesting boolean value from a non-boolean formula
return cell.isSetV() && TRUE_AS_STRING.equals(cell.getV());
return _cell.isSetV() && TRUE_AS_STRING.equals(_cell.getV());
default:
throw typeMismatch(CELL_TYPE_BOOLEAN, cellType, false);
}
@ -167,8 +164,8 @@ public final class XSSFCell implements Cell {
* will change the cell to a boolean cell and set its value.
*/
public void setCellValue(boolean value) {
cell.setT(STCellType.B);
cell.setV(value ? TRUE_AS_STRING : FALSE_AS_STRING);
_cell.setT(STCellType.B);
_cell.setV(value ? TRUE_AS_STRING : FALSE_AS_STRING);
}
/**
@ -189,7 +186,7 @@ public final class XSSFCell implements Cell {
return 0.0;
case CELL_TYPE_FORMULA:
case CELL_TYPE_NUMERIC:
return cell.isSetV() ? Double.parseDouble(cell.getV()) : 0.0;
return _cell.isSetV() ? Double.parseDouble(_cell.getV()) : 0.0;
default:
throw typeMismatch(CELL_TYPE_NUMERIC, cellType, false);
}
@ -205,11 +202,11 @@ public final class XSSFCell implements Cell {
*/
public void setCellValue(double value) {
if(Double.isInfinite(value) || Double.isNaN(value)) {
cell.setT(STCellType.E);
cell.setV(FormulaError.NUM.getString());
_cell.setT(STCellType.E);
_cell.setV(FormulaError.NUM.getString());
} else {
cell.setT(STCellType.N);
cell.setV(String.valueOf(value));
_cell.setT(STCellType.N);
_cell.setV(String.valueOf(value));
}
}
@ -242,20 +239,20 @@ public final class XSSFCell implements Cell {
rt = new XSSFRichTextString("");
break;
case CELL_TYPE_STRING:
if (cell.getT() == STCellType.INLINE_STR) {
if(cell.isSetIs()) {
if (_cell.getT() == STCellType.INLINE_STR) {
if(_cell.isSetIs()) {
//string is expressed directly in the cell definition instead of implementing the shared string table.
rt = new XSSFRichTextString(cell.getIs());
} else if (cell.isSetV()) {
rt = new XSSFRichTextString(_cell.getIs());
} else if (_cell.isSetV()) {
//cached result of a formula
rt = new XSSFRichTextString(cell.getV());
rt = new XSSFRichTextString(_cell.getV());
} else {
rt = new XSSFRichTextString("");
}
} else {
if (cell.isSetV()) {
int idx = Integer.parseInt(cell.getV());
rt = new XSSFRichTextString(sharedStringSource.getEntryAt(idx));
if (_cell.isSetV()) {
int idx = Integer.parseInt(_cell.getV());
rt = new XSSFRichTextString(_sharedStringSource.getEntryAt(idx));
}
else {
rt = new XSSFRichTextString("");
@ -263,12 +260,12 @@ public final class XSSFCell implements Cell {
}
break;
case CELL_TYPE_FORMULA:
rt = new XSSFRichTextString(cell.isSetV() ? cell.getV() : "");
rt = new XSSFRichTextString(_cell.isSetV() ? _cell.getV() : "");
break;
default:
throw typeMismatch(CELL_TYPE_STRING, cellType, false);
}
rt.setStylesTableReference(stylesSource);
rt.setStylesTableReference(_stylesSource);
return rt;
}
@ -300,19 +297,19 @@ public final class XSSFCell implements Cell {
int cellType = getCellType();
switch(cellType){
case Cell.CELL_TYPE_FORMULA:
cell.setV(str.getString());
cell.setT(STCellType.STR);
_cell.setV(str.getString());
_cell.setT(STCellType.STR);
break;
default:
if(cell.getT() == STCellType.INLINE_STR) {
if(_cell.getT() == STCellType.INLINE_STR) {
//set the 'pre-evaluated result
cell.setV(str.getString());
_cell.setV(str.getString());
} else {
cell.setT(STCellType.S);
_cell.setT(STCellType.S);
XSSFRichTextString rt = (XSSFRichTextString)str;
rt.setStylesTableReference(stylesSource);
int sRef = sharedStringSource.addEntry(rt.getCTRst());
cell.setV(Integer.toString(sRef));
rt.setStylesTableReference(_stylesSource);
int sRef = _sharedStringSource.addEntry(rt.getCTRst());
_cell.setV(Integer.toString(sRef));
}
break;
}
@ -328,12 +325,11 @@ public final class XSSFCell implements Cell {
int cellType = getCellType();
if(cellType != CELL_TYPE_FORMULA) throw typeMismatch(CELL_TYPE_FORMULA, cellType, false);
CTCellFormula f = cell.getF();
CTCellFormula f = _cell.getF();
if(f.getT() == STCellFormulaType.SHARED){
return convertSharedFormula((int)f.getSi());
} else {
return f.getStringValue();
}
return f.getStringValue();
}
/**
@ -368,10 +364,10 @@ public final class XSSFCell implements Cell {
* @throws IllegalArgumentException if the formula is invalid
*/
public void setCellFormula(String formula) {
XSSFWorkbook wb = row.getSheet().getWorkbook();
XSSFWorkbook wb = _row.getSheet().getWorkbook();
if (formula == null) {
wb.onDeleteFormula(this);
if(cell.isSetF()) cell.unsetF();
if(_cell.isSetF()) _cell.unsetF();
return;
}
@ -381,8 +377,8 @@ public final class XSSFCell implements Cell {
CTCellFormula f = CTCellFormula.Factory.newInstance();
f.setStringValue(formula);
cell.setF(f);
if(cell.isSetV()) cell.unsetV();
_cell.setF(f);
if(_cell.isSetV()) _cell.unsetV();
}
/**
@ -391,7 +387,7 @@ public final class XSSFCell implements Cell {
* @return zero-based column index of a column in a sheet.
*/
public int getColumnIndex() {
return this.cellNum;
return this._cellNum;
}
/**
@ -400,7 +396,7 @@ public final class XSSFCell implements Cell {
* @return zero-based row index of a row in the sheet that contains this cell
*/
public int getRowIndex() {
return row.getRowNum();
return _row.getRowNum();
}
/**
@ -409,7 +405,7 @@ public final class XSSFCell implements Cell {
* @return A1 style reference to the location of this cell
*/
public String getReference() {
return cell.getR();
return _cell.getR();
}
/**
@ -419,8 +415,8 @@ public final class XSSFCell implements Cell {
* <code>workbook.getCellStyleAt(0)</code>
*/
public XSSFCellStyle getCellStyle() {
long idx = cell.isSetS() ? cell.getS() : 0;
return stylesSource.getStyleAt((int)idx);
long idx = _cell.isSetS() ? _cell.getS() : 0;
return _stylesSource.getStyleAt((int)idx);
}
/**
@ -432,13 +428,13 @@ public final class XSSFCell implements Cell {
*/
public void setCellStyle(CellStyle style) {
if(style == null) {
if(cell.isSetS()) cell.unsetS();
if(_cell.isSetS()) _cell.unsetS();
} else {
XSSFCellStyle xStyle = (XSSFCellStyle)style;
xStyle.verifyBelongsToStylesSource(stylesSource);
xStyle.verifyBelongsToStylesSource(_stylesSource);
long idx = stylesSource.putStyle(xStyle);
cell.setS(idx);
long idx = _stylesSource.putStyle(xStyle);
_cell.setS(idx);
}
}
@ -455,7 +451,7 @@ public final class XSSFCell implements Cell {
*/
public int getCellType() {
if (cell.getF() != null) {
if (_cell.getF() != null) {
return CELL_TYPE_FORMULA;
}
@ -469,7 +465,7 @@ public final class XSSFCell implements Cell {
* on the cached value of the formula
*/
public int getCachedFormulaResultType() {
if (cell.getF() == null) {
if (_cell.getF() == null) {
throw new IllegalStateException("Only formula cells have cached results");
}
@ -480,11 +476,11 @@ public final class XSSFCell implements Cell {
* Detect cell type based on the "t" attribute of the CTCell bean
*/
private int getBaseCellType(boolean blankCells) {
switch (cell.getT().intValue()) {
switch (_cell.getT().intValue()) {
case STCellType.INT_B:
return CELL_TYPE_BOOLEAN;
case STCellType.INT_N:
if (!cell.isSetV() && blankCells) {
if (!_cell.isSetV() && blankCells) {
// ooxml does have a separate cell type of 'blank'. A blank cell gets encoded as
// (either not present or) a numeric cell with no value set.
// The formula evaluator (and perhaps other clients of this interface) needs to
@ -500,7 +496,7 @@ public final class XSSFCell implements Cell {
case STCellType.INT_STR:
return CELL_TYPE_STRING;
default:
throw new IllegalStateException("Illegal cell type: " + this.cell.getT());
throw new IllegalStateException("Illegal cell type: " + this._cell.getT());
}
}
@ -570,7 +566,7 @@ public final class XSSFCell implements Cell {
int cellType = getCellType();
if(cellType != CELL_TYPE_ERROR) throw typeMismatch(CELL_TYPE_ERROR, cellType, false);
return cell.getV();
return _cell.getV();
}
/**
* Get the value of the cell as an error code.
@ -615,15 +611,15 @@ public final class XSSFCell implements Cell {
* cell and set its value.
*/
public void setCellErrorValue(FormulaError error) {
cell.setT(STCellType.E);
cell.setV(error.getString());
_cell.setT(STCellType.E);
_cell.setV(error.getString());
}
/**
* Sets this cell as the active cell for the worksheet.
*/
public void setAsActiveCell() {
getSheet().setActiveCell(cell.getR());
getSheet().setActiveCell(_cell.getR());
}
/**
@ -632,9 +628,9 @@ public final class XSSFCell implements Cell {
*/
private void setBlank(){
CTCell blank = CTCell.Factory.newInstance();
blank.setR(cell.getR());
blank.setS(cell.getS());
cell.set(blank);
blank.setR(_cell.getR());
blank.setS(_cell.getS());
_cell.set(blank);
}
/**
@ -644,9 +640,9 @@ public final class XSSFCell implements Cell {
*/
protected void setCellNum(int num) {
checkBounds(num);
cellNum = num;
_cellNum = num;
String ref = new CellReference(getRowIndex(), getColumnIndex()).formatAsString();
cell.setR(ref);
_cell.setR(ref);
}
/**
@ -668,31 +664,31 @@ public final class XSSFCell implements Cell {
break;
case CELL_TYPE_BOOLEAN:
String newVal = convertCellValueToBoolean() ? TRUE_AS_STRING : FALSE_AS_STRING;
cell.setT(STCellType.B);
cell.setV(newVal);
_cell.setT(STCellType.B);
_cell.setV(newVal);
break;
case CELL_TYPE_NUMERIC:
cell.setT(STCellType.N);
_cell.setT(STCellType.N);
break;
case CELL_TYPE_ERROR:
cell.setT(STCellType.E);
_cell.setT(STCellType.E);
break;
case CELL_TYPE_STRING:
if(prevType != CELL_TYPE_STRING){
String str = convertCellValueToString();
XSSFRichTextString rt = new XSSFRichTextString(str);
rt.setStylesTableReference(stylesSource);
int sRef = sharedStringSource.addEntry(rt.getCTRst());
cell.setV(Integer.toString(sRef));
rt.setStylesTableReference(_stylesSource);
int sRef = _sharedStringSource.addEntry(rt.getCTRst());
_cell.setV(Integer.toString(sRef));
}
cell.setT(STCellType.S);
_cell.setT(STCellType.S);
break;
case CELL_TYPE_FORMULA:
if(!cell.isSetF()){
if(!_cell.isSetF()){
CTCellFormula f = CTCellFormula.Factory.newInstance();
f.setStringValue("0");
cell.setF(f);
if(cell.isSetT()) cell.unsetT();
_cell.setF(f);
if(_cell.isSetT()) _cell.unsetT();
}
break;
default:
@ -722,9 +718,8 @@ public final class XSSFCell implements Cell {
if (DateUtil.isCellDateFormatted(this)) {
DateFormat sdf = new SimpleDateFormat("dd-MMM-yyyy");
return sdf.format(getDateCellValue());
} else {
return getNumericCellValue() + "";
}
return getNumericCellValue() + "";
case CELL_TYPE_STRING:
return getRichStringCellValue().toString();
default:
@ -745,7 +740,7 @@ public final class XSSFCell implements Cell {
* <code>null</code> for blank cells.
*/
public String getRawValue() {
return cell.getV();
return _cell.getV();
}
/**
@ -792,7 +787,7 @@ public final class XSSFCell implements Cell {
* @return the cell comment associated with this cell or <code>null</code>
*/
public XSSFComment getCellComment() {
return getSheet().getCellComment(row.getRowNum(), getColumnIndex());
return getSheet().getCellComment(_row.getRowNum(), getColumnIndex());
}
/**
@ -802,7 +797,7 @@ public final class XSSFCell implements Cell {
* @param comment comment associated with this cell
*/
public void setCellComment(Comment comment) {
String cellRef = new CellReference(row.getRowNum(), getColumnIndex()).formatAsString();
String cellRef = new CellReference(_row.getRowNum(), getColumnIndex()).formatAsString();
getSheet().setCellComment(cellRef, (XSSFComment)comment);
}
@ -812,7 +807,7 @@ public final class XSSFCell implements Cell {
* @return hyperlink associated with this cell or <code>null</code> if not found
*/
public XSSFHyperlink getHyperlink() {
return getSheet().getHyperlink(row.getRowNum(), cellNum);
return getSheet().getHyperlink(_row.getRowNum(), _cellNum);
}
/**
@ -824,7 +819,7 @@ public final class XSSFCell implements Cell {
XSSFHyperlink link = (XSSFHyperlink)hyperlink;
// Assign to us
link.setCellReference( new CellReference(row.getRowNum(), cellNum).formatAsString() );
link.setCellReference( new CellReference(_row.getRowNum(), _cellNum).formatAsString() );
// Add to the lists
getSheet().setCellHyperlink(link);
@ -837,7 +832,7 @@ public final class XSSFCell implements Cell {
* @return the xml bean containing information about this cell
*/
public CTCell getCTCell(){
return cell;
return _cell;
}
/**
@ -857,14 +852,14 @@ public final class XSSFCell implements Cell {
switch (cellType) {
case CELL_TYPE_BOOLEAN:
return TRUE_AS_STRING.equals(cell.getV());
return TRUE_AS_STRING.equals(_cell.getV());
case CELL_TYPE_STRING:
int sstIndex = Integer.parseInt(cell.getV());
XSSFRichTextString rt = new XSSFRichTextString(sharedStringSource.getEntryAt(sstIndex));
int sstIndex = Integer.parseInt(_cell.getV());
XSSFRichTextString rt = new XSSFRichTextString(_sharedStringSource.getEntryAt(sstIndex));
String text = rt.getString();
return Boolean.valueOf(text);
return Boolean.valueOf(text).booleanValue();
case CELL_TYPE_NUMERIC:
return Double.parseDouble(cell.getV()) != 0;
return Double.parseDouble(_cell.getV()) != 0;
case CELL_TYPE_ERROR:
case CELL_TYPE_BLANK:
@ -880,15 +875,15 @@ public final class XSSFCell implements Cell {
case CELL_TYPE_BLANK:
return "";
case CELL_TYPE_BOOLEAN:
return TRUE_AS_STRING.equals(cell.getV()) ? "TRUE" : "FALSE";
return TRUE_AS_STRING.equals(_cell.getV()) ? "TRUE" : "FALSE";
case CELL_TYPE_STRING:
int sstIndex = Integer.parseInt(cell.getV());
XSSFRichTextString rt = new XSSFRichTextString(sharedStringSource.getEntryAt(sstIndex));
int sstIndex = Integer.parseInt(_cell.getV());
XSSFRichTextString rt = new XSSFRichTextString(_sharedStringSource.getEntryAt(sstIndex));
return rt.getString();
case CELL_TYPE_NUMERIC:
return String.valueOf(Double.parseDouble(cell.getV()));
return String.valueOf(Double.parseDouble(_cell.getV()));
case CELL_TYPE_ERROR:
return cell.getV();
return _cell.getV();
case CELL_TYPE_FORMULA:
// should really evaluate, but HSSFCell can't call HSSFFormulaEvaluator
return "";

View File

@ -37,12 +37,12 @@ import org.openxmlformats.schemas.spreadsheetml.x2006.main.*;
*/
public class XSSFCellStyle implements CellStyle {
private int cellXfId;
private StylesTable stylesSource;
private CTXf cellXf;
private CTXf cellStyleXf;
private XSSFFont font;
private XSSFCellAlignment cellAlignment;
private int _cellXfId;
private StylesTable _stylesSource;
private CTXf _cellXf;
private CTXf _cellStyleXf;
private XSSFFont _font;
private XSSFCellAlignment _cellAlignment;
/**
* Creates a Cell Style from the supplied parts
@ -51,35 +51,35 @@ public class XSSFCellStyle implements CellStyle {
* @param stylesSource Styles Source to work off
*/
public XSSFCellStyle(int cellXfId, int cellStyleXfId, StylesTable stylesSource) {
this.cellXfId = cellXfId;
this.stylesSource = stylesSource;
this.cellXf = stylesSource.getCellXfAt(this.cellXfId);
this.cellStyleXf = stylesSource.getCellStyleXfAt(cellStyleXfId);
_cellXfId = cellXfId;
_stylesSource = stylesSource;
_cellXf = stylesSource.getCellXfAt(this._cellXfId);
_cellStyleXf = stylesSource.getCellStyleXfAt(cellStyleXfId);
}
/**
* Used so that StylesSource can figure out our location
*/
public CTXf getCoreXf() {
return cellXf;
return _cellXf;
}
/**
* Used so that StylesSource can figure out our location
*/
public CTXf getStyleXf() {
return cellStyleXf;
return _cellStyleXf;
}
/**
* Creates an empty Cell Style
*/
public XSSFCellStyle(StylesTable stylesSource) {
this.stylesSource = stylesSource;
_stylesSource = stylesSource;
// We need a new CTXf for the main styles
// TODO decide on a style ctxf
cellXf = CTXf.Factory.newInstance();
cellStyleXf = null;
_cellXf = CTXf.Factory.newInstance();
_cellStyleXf = null;
}
/**
@ -92,7 +92,7 @@ public class XSSFCellStyle implements CellStyle {
* @throws IllegalArgumentException if there's a workbook mis-match
*/
public void verifyBelongsToStylesSource(StylesTable src) {
if(this.stylesSource != src) {
if(this._stylesSource != src) {
throw new IllegalArgumentException("This Style does not belong to the supplied Workbook Stlyes Source. Are you trying to assign a style from one workbook to the cell of a differnt workbook?");
}
}
@ -112,8 +112,8 @@ public class XSSFCellStyle implements CellStyle {
public void cloneStyleFrom(CellStyle source) {
if(source instanceof XSSFCellStyle) {
XSSFCellStyle src = (XSSFCellStyle)source;
cellXf.set(src.getCoreXf());
cellStyleXf.set(src.getStyleXf());
_cellXf.set(src.getCoreXf());
_cellStyleXf.set(src.getStyleXf());
} else {
throw new IllegalArgumentException("Can only clone from one XSSFCellStyle to another, not between HSSFCellStyle and XSSFCellStyle");
}
@ -142,7 +142,7 @@ public class XSSFCellStyle implements CellStyle {
* @see org.apache.poi.ss.usermodel.HorizontalAlignment
*/
public HorizontalAlignment getAlignmentEnum() {
CTCellAlignment align = cellXf.getAlignment();
CTCellAlignment align = _cellXf.getAlignment();
if(align != null && align.isSetHorizontal()) {
return HorizontalAlignment.values()[align.getHorizontal().intValue()-1];
}
@ -169,10 +169,10 @@ public class XSSFCellStyle implements CellStyle {
* @see org.apache.poi.ss.usermodel.CellStyle#BORDER_SLANTED_DASH_DOT
*/
public short getBorderBottom() {
if(!cellXf.getApplyBorder()) return BORDER_NONE;
if(!_cellXf.getApplyBorder()) return BORDER_NONE;
int idx = (int)cellXf.getBorderId();
CTBorder ct = stylesSource.getBorderAt(idx).getCTBorder();
int idx = (int)_cellXf.getBorderId();
CTBorder ct = _stylesSource.getBorderAt(idx).getCTBorder();
STBorderStyle.Enum ptrn = ct.isSetBottom() ? ct.getBottom().getStyle() : null;
return ptrn == null ? BORDER_NONE : (short)(ptrn.intValue() - 1);
}
@ -208,10 +208,10 @@ public class XSSFCellStyle implements CellStyle {
* @see org.apache.poi.ss.usermodel.CellStyle#BORDER_SLANTED_DASH_DOT
*/
public short getBorderLeft() {
if(!cellXf.getApplyBorder()) return BORDER_NONE;
if(!_cellXf.getApplyBorder()) return BORDER_NONE;
int idx = (int)cellXf.getBorderId();
CTBorder ct = stylesSource.getBorderAt(idx).getCTBorder();
int idx = (int)_cellXf.getBorderId();
CTBorder ct = _stylesSource.getBorderAt(idx).getCTBorder();
STBorderStyle.Enum ptrn = ct.isSetLeft() ? ct.getLeft().getStyle() : null;
return ptrn == null ? BORDER_NONE : (short)(ptrn.intValue() - 1);
}
@ -246,10 +246,10 @@ public class XSSFCellStyle implements CellStyle {
* @see org.apache.poi.ss.usermodel.CellStyle#BORDER_SLANTED_DASH_DOT
*/
public short getBorderRight() {
if(!cellXf.getApplyBorder()) return BORDER_NONE;
if(!_cellXf.getApplyBorder()) return BORDER_NONE;
int idx = (int)cellXf.getBorderId();
CTBorder ct = stylesSource.getBorderAt(idx).getCTBorder();
int idx = (int)_cellXf.getBorderId();
CTBorder ct = _stylesSource.getBorderAt(idx).getCTBorder();
STBorderStyle.Enum ptrn = ct.isSetRight() ? ct.getRight().getStyle() : null;
return ptrn == null ? BORDER_NONE : (short)(ptrn.intValue() - 1);
}
@ -284,10 +284,10 @@ public class XSSFCellStyle implements CellStyle {
* @see org.apache.poi.ss.usermodel.CellStyle#BORDER_SLANTED_DASH_DOT
*/
public short getBorderTop() {
if(!cellXf.getApplyBorder()) return BORDER_NONE;
if(!_cellXf.getApplyBorder()) return BORDER_NONE;
int idx = (int)cellXf.getBorderId();
CTBorder ct = stylesSource.getBorderAt(idx).getCTBorder();
int idx = (int)_cellXf.getBorderId();
CTBorder ct = _stylesSource.getBorderAt(idx).getCTBorder();
STBorderStyle.Enum ptrn = ct.isSetTop() ? ct.getTop().getStyle() : null;
return ptrn == null ? BORDER_NONE : (short)(ptrn.intValue() - 1);
}
@ -320,10 +320,10 @@ public class XSSFCellStyle implements CellStyle {
* @return the used color or <code>null</code> if not set
*/
public XSSFColor getBottomBorderXSSFColor() {
if(!cellXf.getApplyBorder()) return null;
if(!_cellXf.getApplyBorder()) return null;
int idx = (int)cellXf.getBorderId();
XSSFCellBorder border = stylesSource.getBorderAt(idx);
int idx = (int)_cellXf.getBorderId();
XSSFCellBorder border = _stylesSource.getBorderAt(idx);
return border.getBorderColor(BorderSide.BOTTOM);
}
@ -334,7 +334,7 @@ public class XSSFCellStyle implements CellStyle {
* @return the index of the number format
*/
public short getDataFormat() {
return (short)cellXf.getNumFmtId();
return (short)_cellXf.getNumFmtId();
}
/**
@ -345,7 +345,7 @@ public class XSSFCellStyle implements CellStyle {
*/
public String getDataFormatString() {
int idx = getDataFormat();
return new XSSFDataFormat(stylesSource).getFormat((short)idx);
return new XSSFDataFormat(_stylesSource).getFormat((short)idx);
}
/**
@ -372,10 +372,10 @@ public class XSSFCellStyle implements CellStyle {
* @return XSSFColor - fill color or <code>null</code> if not set
*/
public XSSFColor getFillBackgroundXSSFColor() {
if(!cellXf.getApplyFill()) return null;
if(!_cellXf.getApplyFill()) return null;
int fillIndex = (int)cellXf.getFillId();
XSSFCellFill fg = stylesSource.getFillAt(fillIndex);
int fillIndex = (int)_cellXf.getFillId();
XSSFCellFill fg = _stylesSource.getFillAt(fillIndex);
return fg.getFillBackgroundColor();
}
@ -400,10 +400,10 @@ public class XSSFCellStyle implements CellStyle {
* @return XSSFColor - fill color or <code>null</code> if not set
*/
public XSSFColor getFillForegroundXSSFColor() {
if(!cellXf.getApplyFill()) return null;
if(!_cellXf.getApplyFill()) return null;
int fillIndex = (int)cellXf.getFillId();
XSSFCellFill fg = stylesSource.getFillAt(fillIndex);
int fillIndex = (int)_cellXf.getFillId();
XSSFCellFill fg = _stylesSource.getFillAt(fillIndex);
return fg.getFillForegroundColor();
}
@ -431,10 +431,10 @@ public class XSSFCellStyle implements CellStyle {
* @see org.apache.poi.ss.usermodel.CellStyle#DIAMONDS
*/
public short getFillPattern() {
if(!cellXf.getApplyFill()) return 0;
if(!_cellXf.getApplyFill()) return 0;
int fillIndex = (int)cellXf.getFillId();
XSSFCellFill fill = stylesSource.getFillAt(fillIndex);
int fillIndex = (int)_cellXf.getFillId();
XSSFCellFill fill = _stylesSource.getFillAt(fillIndex);
STPatternType.Enum ptrn = fill.getPatternType();
if(ptrn == null) return CellStyle.NO_FILL;
@ -456,10 +456,10 @@ public class XSSFCellStyle implements CellStyle {
* @return Font - font
*/
public XSSFFont getFont() {
if (font == null) {
font = stylesSource.getFontAt(getFontId());
if (_font == null) {
_font = _stylesSource.getFontAt(getFontId());
}
return font;
return _font;
}
/**
@ -487,7 +487,7 @@ public class XSSFCellStyle implements CellStyle {
* @return indent - number of spaces
*/
public short getIndention() {
CTCellAlignment align = cellXf.getAlignment();
CTCellAlignment align = _cellXf.getAlignment();
return (short)(align == null ? 0 : align.getIndent());
}
@ -497,7 +497,7 @@ public class XSSFCellStyle implements CellStyle {
* @return unique index number of the underlying record this style represents
*/
public short getIndex() {
return (short)this.cellXfId;
return (short)this._cellXfId;
}
/**
@ -518,10 +518,10 @@ public class XSSFCellStyle implements CellStyle {
* @see org.apache.poi.ss.usermodel.IndexedColors
*/
public XSSFColor getLeftBorderXSSFColor() {
if(!cellXf.getApplyBorder()) return null;
if(!_cellXf.getApplyBorder()) return null;
int idx = (int)cellXf.getBorderId();
XSSFCellBorder border = stylesSource.getBorderAt(idx);
int idx = (int)_cellXf.getBorderId();
XSSFCellBorder border = _stylesSource.getBorderAt(idx);
return border.getBorderColor(BorderSide.LEFT);
}
@ -551,10 +551,10 @@ public class XSSFCellStyle implements CellStyle {
* @return the used color or <code>null</code> if not set
*/
public XSSFColor getRightBorderXSSFColor() {
if(!cellXf.getApplyBorder()) return null;
if(!_cellXf.getApplyBorder()) return null;
int idx = (int)cellXf.getBorderId();
XSSFCellBorder border = stylesSource.getBorderAt(idx);
int idx = (int)_cellXf.getBorderId();
XSSFCellBorder border = _stylesSource.getBorderAt(idx);
return border.getBorderColor(BorderSide.RIGHT);
}
@ -574,7 +574,7 @@ public class XSSFCellStyle implements CellStyle {
* @return rotation degrees (between 0 and 180 degrees)
*/
public short getRotation() {
CTCellAlignment align = cellXf.getAlignment();
CTCellAlignment align = _cellXf.getAlignment();
return (short)(align == null ? 0 : align.getTextRotation());
}
@ -595,10 +595,10 @@ public class XSSFCellStyle implements CellStyle {
* @return the used color or <code>null</code> if not set
*/
public XSSFColor getTopBorderXSSFColor() {
if(!cellXf.getApplyBorder()) return null;
if(!_cellXf.getApplyBorder()) return null;
int idx = (int)cellXf.getBorderId();
XSSFCellBorder border = stylesSource.getBorderAt(idx);
int idx = (int)_cellXf.getBorderId();
XSSFCellBorder border = _stylesSource.getBorderAt(idx);
return border.getBorderColor(BorderSide.TOP);
}
@ -623,12 +623,11 @@ public class XSSFCellStyle implements CellStyle {
* @see org.apache.poi.ss.usermodel.VerticalAlignment
*/
public VerticalAlignment getVerticalAlignmentEnum() {
CTCellAlignment align = cellXf.getAlignment();
CTCellAlignment align = _cellXf.getAlignment();
if(align != null && align.isSetVertical()) {
return VerticalAlignment.values()[align.getVertical().intValue()-1];
} else {
return VerticalAlignment.BOTTOM;
}
return VerticalAlignment.BOTTOM;
}
/**
@ -637,7 +636,7 @@ public class XSSFCellStyle implements CellStyle {
* @return a boolean value indicating if the text in a cell should be line-wrapped within the cell.
*/
public boolean getWrapText() {
CTCellAlignment align = cellXf.getAlignment();
CTCellAlignment align = _cellXf.getAlignment();
return align != null && align.getWrapText();
}
@ -692,10 +691,10 @@ public class XSSFCellStyle implements CellStyle {
if(border == BORDER_NONE) ct.unsetBottom();
else pr.setStyle(STBorderStyle.Enum.forInt(border + 1));
int idx = stylesSource.putBorder(new XSSFCellBorder(ct));
int idx = _stylesSource.putBorder(new XSSFCellBorder(ct));
cellXf.setBorderId(idx);
cellXf.setApplyBorder(true);
_cellXf.setBorderId(idx);
_cellXf.setApplyBorder(true);
}
/**
@ -732,10 +731,10 @@ public class XSSFCellStyle implements CellStyle {
if(border == BORDER_NONE) ct.unsetLeft();
else pr.setStyle(STBorderStyle.Enum.forInt(border + 1));
int idx = stylesSource.putBorder(new XSSFCellBorder(ct));
int idx = _stylesSource.putBorder(new XSSFCellBorder(ct));
cellXf.setBorderId(idx);
cellXf.setApplyBorder(true);
_cellXf.setBorderId(idx);
_cellXf.setApplyBorder(true);
}
/**
@ -772,10 +771,10 @@ public class XSSFCellStyle implements CellStyle {
if(border == BORDER_NONE) ct.unsetRight();
else pr.setStyle(STBorderStyle.Enum.forInt(border + 1));
int idx = stylesSource.putBorder(new XSSFCellBorder(ct));
int idx = _stylesSource.putBorder(new XSSFCellBorder(ct));
cellXf.setBorderId(idx);
cellXf.setApplyBorder(true);
_cellXf.setBorderId(idx);
_cellXf.setApplyBorder(true);
}
/**
@ -812,10 +811,10 @@ public class XSSFCellStyle implements CellStyle {
if(border == BORDER_NONE) ct.unsetTop();
else pr.setStyle(STBorderStyle.Enum.forInt(border + 1));
int idx = stylesSource.putBorder(new XSSFCellBorder(ct));
int idx = _stylesSource.putBorder(new XSSFCellBorder(ct));
cellXf.setBorderId(idx);
cellXf.setApplyBorder(true);
_cellXf.setBorderId(idx);
_cellXf.setApplyBorder(true);
}
/**
@ -851,10 +850,10 @@ public class XSSFCellStyle implements CellStyle {
if(color != null) pr.setColor(color.getCTColor());
else pr.unsetColor();
int idx = stylesSource.putBorder(new XSSFCellBorder(ct));
int idx = _stylesSource.putBorder(new XSSFCellBorder(ct));
cellXf.setBorderId(idx);
cellXf.setApplyBorder(true);
_cellXf.setBorderId(idx);
_cellXf.setApplyBorder(true);
}
/**
@ -863,8 +862,8 @@ public class XSSFCellStyle implements CellStyle {
* @param fmt the index of a data format
*/
public void setDataFormat(short fmt) {
cellXf.setApplyNumberFormat(true);
cellXf.setNumFmtId(fmt);
_cellXf.setApplyNumberFormat(true);
_cellXf.setNumFmtId(fmt);
}
/**
@ -902,10 +901,10 @@ public class XSSFCellStyle implements CellStyle {
ptrn.setBgColor(color.getCTColor());
}
int idx = stylesSource.putFill(new XSSFCellFill(ct));
int idx = _stylesSource.putFill(new XSSFCellFill(ct));
cellXf.setFillId(idx);
cellXf.setApplyFill(true);
_cellXf.setFillId(idx);
_cellXf.setApplyFill(true);
}
/**
@ -958,10 +957,10 @@ public class XSSFCellStyle implements CellStyle {
ptrn.setFgColor(color.getCTColor());
}
int idx = stylesSource.putFill(new XSSFCellFill(ct));
int idx = _stylesSource.putFill(new XSSFCellFill(ct));
cellXf.setFillId(idx);
cellXf.setApplyFill(true);
_cellXf.setFillId(idx);
_cellXf.setApplyFill(true);
}
/**
@ -982,9 +981,9 @@ public class XSSFCellStyle implements CellStyle {
*/
private CTFill getCTFill(){
CTFill ct;
if(cellXf.getApplyFill()) {
int fillIndex = (int)cellXf.getFillId();
XSSFCellFill cf = stylesSource.getFillAt(fillIndex);
if(_cellXf.getApplyFill()) {
int fillIndex = (int)_cellXf.getFillId();
XSSFCellFill cf = _stylesSource.getFillAt(fillIndex);
ct = (CTFill)cf.getCTFill().copy();
} else {
@ -998,9 +997,9 @@ public class XSSFCellStyle implements CellStyle {
*/
private CTBorder getCTBorder(){
CTBorder ct;
if(cellXf.getApplyBorder()) {
int idx = (int)cellXf.getBorderId();
XSSFCellBorder cf = stylesSource.getBorderAt(idx);
if(_cellXf.getApplyBorder()) {
int idx = (int)_cellXf.getBorderId();
XSSFCellBorder cf = _stylesSource.getBorderAt(idx);
ct = (CTBorder)cf.getCTBorder().copy();
} else {
@ -1041,10 +1040,10 @@ public class XSSFCellStyle implements CellStyle {
if(fp == NO_FILL && ptrn.isSetPatternType()) ptrn.unsetPatternType();
else ptrn.setPatternType(STPatternType.Enum.forInt(fp + 1));
int idx = stylesSource.putFill(new XSSFCellFill(ct));
int idx = _stylesSource.putFill(new XSSFCellFill(ct));
cellXf.setFillId(idx);
cellXf.setApplyFill(true);
_cellXf.setFillId(idx);
_cellXf.setApplyFill(true);
}
/**
@ -1070,10 +1069,10 @@ public class XSSFCellStyle implements CellStyle {
public void setFont(Font font) {
if(font != null){
long index = font.getIndex();
this.cellXf.setFontId(index);
this.cellXf.setApplyFont(true);
this._cellXf.setFontId(index);
this._cellXf.setApplyFont(true);
} else {
this.cellXf.setApplyFont(false);
this._cellXf.setApplyFont(false);
}
}
@ -1120,10 +1119,10 @@ public class XSSFCellStyle implements CellStyle {
if(color != null) pr.setColor(color.getCTColor());
else pr.unsetColor();
int idx = stylesSource.putBorder(new XSSFCellBorder(ct));
int idx = _stylesSource.putBorder(new XSSFCellBorder(ct));
cellXf.setBorderId(idx);
cellXf.setApplyBorder(true);
_cellXf.setBorderId(idx);
_cellXf.setApplyBorder(true);
}
/**
@ -1160,10 +1159,10 @@ public class XSSFCellStyle implements CellStyle {
if(color != null) pr.setColor(color.getCTColor());
else pr.unsetColor();
int idx = stylesSource.putBorder(new XSSFCellBorder(ct));
int idx = _stylesSource.putBorder(new XSSFCellBorder(ct));
cellXf.setBorderId(idx);
cellXf.setApplyBorder(true);
_cellXf.setBorderId(idx);
_cellXf.setApplyBorder(true);
}
/**
@ -1210,10 +1209,10 @@ public class XSSFCellStyle implements CellStyle {
if(color != null) pr.setColor(color.getCTColor());
else pr.unsetColor();
int idx = stylesSource.putBorder(new XSSFCellBorder(ct));
int idx = _stylesSource.putBorder(new XSSFCellBorder(ct));
cellXf.setBorderId(idx);
cellXf.setApplyBorder(true);
_cellXf.setBorderId(idx);
_cellXf.setApplyBorder(true);
}
/**
@ -1296,10 +1295,10 @@ public class XSSFCellStyle implements CellStyle {
}
}
private int getFontId() {
if (cellXf.isSetFontId()) {
return (int) cellXf.getFontId();
if (_cellXf.isSetFontId()) {
return (int) _cellXf.getFontId();
}
return (int) cellStyleXf.getFontId();
return (int) _cellStyleXf.getFontId();
}
/**
@ -1307,10 +1306,10 @@ public class XSSFCellStyle implements CellStyle {
* @return CTCellProtection
*/
private CTCellProtection getCellProtection() {
if (cellXf.getProtection() == null) {
cellXf.addNewProtection();
if (_cellXf.getProtection() == null) {
_cellXf.addNewProtection();
}
return cellXf.getProtection();
return _cellXf.getProtection();
}
/**
@ -1318,10 +1317,10 @@ public class XSSFCellStyle implements CellStyle {
* @return XSSFCellAlignment - cell alignment
*/
protected XSSFCellAlignment getCellAlignment() {
if (this.cellAlignment == null) {
this.cellAlignment = new XSSFCellAlignment(getCTCellAlignment());
if (this._cellAlignment == null) {
this._cellAlignment = new XSSFCellAlignment(getCTCellAlignment());
}
return this.cellAlignment;
return this._cellAlignment;
}
/**
@ -1330,10 +1329,10 @@ public class XSSFCellStyle implements CellStyle {
* @return CTCellAlignment
*/
private CTCellAlignment getCTCellAlignment() {
if (cellXf.getAlignment() == null) {
cellXf.setAlignment(CTCellAlignment.Factory.newInstance());
if (_cellXf.getAlignment() == null) {
_cellXf.setAlignment(CTCellAlignment.Factory.newInstance());
}
return cellXf.getAlignment();
return _cellXf.getAlignment();
}
/**
@ -1342,7 +1341,7 @@ public class XSSFCellStyle implements CellStyle {
* @return the hash code value for this style
*/
public int hashCode(){
return cellXf.toString().hashCode();
return _cellXf.toString().hashCode();
}
/**
@ -1355,7 +1354,7 @@ public class XSSFCellStyle implements CellStyle {
if(o == null || !(o instanceof XSSFCellStyle)) return false;
XSSFCellStyle cf = (XSSFCellStyle)o;
return cellXf.toString().equals(cf.getCoreXf().toString());
return _cellXf.toString().equals(cf.getCoreXf().toString());
}
/**
@ -1365,11 +1364,11 @@ public class XSSFCellStyle implements CellStyle {
* @return a copy of this style
*/
public Object clone(){
CTXf xf = (CTXf)cellXf.copy();
CTXf xf = (CTXf)_cellXf.copy();
int xfSize = stylesSource._getStyleXfsSize();
int indexXf = stylesSource.putCellXf(xf);
return new XSSFCellStyle(indexXf-1, xfSize-1, stylesSource);
int xfSize = _stylesSource._getStyleXfsSize();
int indexXf = _stylesSource.putCellXf(xf);
return new XSSFCellStyle(indexXf-1, xfSize-1, _stylesSource);
}
}

View File

@ -42,8 +42,8 @@ public class XSSFFont implements Font {
*/
public static final short DEFAULT_FONT_COLOR = IndexedColors.BLACK.getIndex();
private CTFont ctFont;
private short index;
private CTFont _ctFont;
private short _index;
/**
* Create a new XSSFFont
@ -51,20 +51,20 @@ public class XSSFFont implements Font {
* @param font the underlying CTFont bean
*/
public XSSFFont(CTFont font) {
this.ctFont = font;
this.index = 0;
_ctFont = font;
_index = 0;
}
public XSSFFont(CTFont font, int index) {
this.ctFont = font;
this.index = (short)index;
_ctFont = font;
_index = (short)index;
}
/**
* Create a new XSSFont. This method is protected to be used only by XSSFWorkbook
*/
protected XSSFFont() {
this.ctFont = CTFont.Factory.newInstance();
this._ctFont = CTFont.Factory.newInstance();
setFontName(DEFAULT_FONT_NAME);
setFontHeight((double)DEFAULT_FONT_SIZE);
}
@ -73,7 +73,7 @@ public class XSSFFont implements Font {
* get the underlying CTFont font
*/
public CTFont getCTFont() {
return ctFont;
return _ctFont;
}
/**
@ -82,7 +82,7 @@ public class XSSFFont implements Font {
* @return boolean - bold
*/
public boolean getBold() {
CTBooleanProperty bold = ctFont.sizeOfBArray() == 0 ? null : ctFont.getBArray(0);
CTBooleanProperty bold = _ctFont.sizeOfBArray() == 0 ? null : _ctFont.getBArray(0);
return (bold != null && bold.getVal());
}
@ -93,7 +93,7 @@ public class XSSFFont implements Font {
* @see org.apache.poi.ss.usermodel.FontCharset
*/
public byte getCharSet() {
CTIntProperty charset = ctFont.sizeOfCharsetArray() == 0 ? null : ctFont.getCharsetArray(0);
CTIntProperty charset = _ctFont.sizeOfCharsetArray() == 0 ? null : _ctFont.getCharsetArray(0);
int val = charset == null ? FontCharset.ANSI.getValue() : FontCharset.valueOf(charset.getVal()).getValue();
return (byte)val;
}
@ -107,7 +107,7 @@ public class XSSFFont implements Font {
* @see IndexedColors
*/
public short getColor() {
CTColor color = ctFont.sizeOfColorArray() == 0 ? null : ctFont.getColorArray(0);
CTColor color = _ctFont.sizeOfColorArray() == 0 ? null : _ctFont.getColorArray(0);
if (color == null) return IndexedColors.BLACK.getIndex();
long index = color.getIndexed();
@ -128,7 +128,7 @@ public class XSSFFont implements Font {
* @return XSSFColor - rgb color to use
*/
public XSSFColor getXSSFColor() {
CTColor ctColor = ctFont.sizeOfColorArray() == 0 ? null : ctFont.getColorArray(0);
CTColor ctColor = _ctFont.sizeOfColorArray() == 0 ? null : _ctFont.getColorArray(0);
return ctColor == null ? null : new XSSFColor(ctColor);
}
@ -140,7 +140,7 @@ public class XSSFFont implements Font {
* @return short - theme defined to use
*/
public short getThemeColor() {
CTColor color = ctFont.sizeOfColorArray() == 0 ? null : ctFont.getColorArray(0);
CTColor color = _ctFont.sizeOfColorArray() == 0 ? null : _ctFont.getColorArray(0);
long index = color == null ? 0 : color.getTheme();
return (short) index;
}
@ -151,11 +151,11 @@ public class XSSFFont implements Font {
* @return short - height in point
*/
public short getFontHeight() {
CTFontSize size = ctFont.sizeOfSzArray() == 0 ? null : ctFont.getSzArray(0);
CTFontSize size = _ctFont.sizeOfSzArray() == 0 ? null : _ctFont.getSzArray(0);
if (size != null) {
double fontHeight = size.getVal();
return (short)(fontHeight*20);
} else
}
return (short)(DEFAULT_FONT_SIZE*20);
}
@ -172,7 +172,7 @@ public class XSSFFont implements Font {
* @return String - a string representing the name of the font to use
*/
public String getFontName() {
CTFontName name = ctFont.sizeOfNameArray() == 0 ? null : ctFont.getNameArray(0);
CTFontName name = _ctFont.sizeOfNameArray() == 0 ? null : _ctFont.getNameArray(0);
return name == null ? DEFAULT_FONT_NAME : name.getVal();
}
@ -182,7 +182,7 @@ public class XSSFFont implements Font {
* @return boolean - value for italic
*/
public boolean getItalic() {
CTBooleanProperty italic = ctFont.sizeOfIArray() == 0 ? null : ctFont.getIArray(0);
CTBooleanProperty italic = _ctFont.sizeOfIArray() == 0 ? null : _ctFont.getIArray(0);
return italic != null && italic.getVal();
}
@ -192,7 +192,7 @@ public class XSSFFont implements Font {
* @return boolean - value for strikeout
*/
public boolean getStrikeout() {
CTBooleanProperty strike = ctFont.sizeOfStrikeArray() == 0 ? null : ctFont.getStrikeArray(0);
CTBooleanProperty strike = _ctFont.sizeOfStrikeArray() == 0 ? null : _ctFont.getStrikeArray(0);
return strike != null && strike.getVal();
}
@ -205,8 +205,10 @@ public class XSSFFont implements Font {
* @see Font#SS_SUB
*/
public short getTypeOffset() {
CTVerticalAlignFontProperty vAlign = ctFont.sizeOfVertAlignArray() == 0 ? null : ctFont.getVertAlignArray(0);
if (vAlign != null) {
CTVerticalAlignFontProperty vAlign = _ctFont.sizeOfVertAlignArray() == 0 ? null : _ctFont.getVertAlignArray(0);
if (vAlign == null) {
return Font.SS_NONE;
}
int val = vAlign.getVal().intValue();
switch (val) {
case STVerticalAlignRun.INT_BASELINE:
@ -218,8 +220,6 @@ public class XSSFFont implements Font {
default:
throw new POIXMLException("Wrong offset value " + val);
}
} else
return Font.SS_NONE;
}
/**
@ -229,7 +229,7 @@ public class XSSFFont implements Font {
* @see org.apache.poi.ss.usermodel.FontUnderline
*/
public byte getUnderline() {
CTUnderlineProperty underline = ctFont.sizeOfUArray() == 0 ? null : ctFont.getUArray(0);
CTUnderlineProperty underline = _ctFont.sizeOfUArray() == 0 ? null : _ctFont.getUArray(0);
if (underline != null) {
FontUnderline val = FontUnderline.valueOf(underline.getVal().intValue());
return val.getByteValue();
@ -244,10 +244,10 @@ public class XSSFFont implements Font {
*/
public void setBold(boolean bold) {
if(bold){
CTBooleanProperty ctBold = ctFont.sizeOfBArray() == 0 ? ctFont.addNewB() : ctFont.getBArray(0);
CTBooleanProperty ctBold = _ctFont.sizeOfBArray() == 0 ? _ctFont.addNewB() : _ctFont.getBArray(0);
ctBold.setVal(bold);
} else {
ctFont.setBArray(null);
_ctFont.setBArray(null);
}
}
@ -275,7 +275,7 @@ public class XSSFFont implements Font {
* @see FontCharset
*/
public void setCharSet(byte charset) {
CTIntProperty charsetProperty = ctFont.sizeOfCharsetArray() == 0 ? ctFont.addNewCharset() : ctFont.getCharsetArray(0);
CTIntProperty charsetProperty = _ctFont.sizeOfCharsetArray() == 0 ? _ctFont.addNewCharset() : _ctFont.getCharsetArray(0);
switch (charset) {
case Font.ANSI_CHARSET:
charsetProperty.setVal(FontCharset.ANSI.getValue());
@ -308,7 +308,7 @@ public class XSSFFont implements Font {
* @see IndexedColors
*/
public void setColor(short color) {
CTColor ctColor = ctFont.sizeOfColorArray() == 0 ? ctFont.addNewColor() : ctFont.getColorArray(0);
CTColor ctColor = _ctFont.sizeOfColorArray() == 0 ? _ctFont.addNewColor() : _ctFont.getColorArray(0);
switch (color) {
case Font.COLOR_NORMAL: {
ctColor.setIndexed(XSSFFont.DEFAULT_FONT_COLOR);
@ -329,9 +329,9 @@ public class XSSFFont implements Font {
* @param color - color to use
*/
public void setColor(XSSFColor color) {
if(color == null) ctFont.setColorArray(null);
if(color == null) _ctFont.setColorArray(null);
else {
CTColor ctColor = ctFont.sizeOfColorArray() == 0 ? ctFont.addNewColor() : ctFont.getColorArray(0);
CTColor ctColor = _ctFont.sizeOfColorArray() == 0 ? _ctFont.addNewColor() : _ctFont.getColorArray(0);
ctColor.setRgb(color.getRgb());
}
}
@ -351,7 +351,7 @@ public class XSSFFont implements Font {
* @param height - height in points
*/
public void setFontHeight(double height) {
CTFontSize fontSize = ctFont.sizeOfSzArray() == 0 ? ctFont.addNewSz() : ctFont.getSzArray(0);
CTFontSize fontSize = _ctFont.sizeOfSzArray() == 0 ? _ctFont.addNewSz() : _ctFont.getSzArray(0);
fontSize.setVal(height);
}
@ -370,7 +370,7 @@ public class XSSFFont implements Font {
* @param theme - theme color to use
*/
public void setThemeColor(short theme) {
CTColor ctColor = ctFont.sizeOfColorArray() == 0 ? ctFont.addNewColor() : ctFont.getColorArray(0);
CTColor ctColor = _ctFont.sizeOfColorArray() == 0 ? _ctFont.addNewColor() : _ctFont.getColorArray(0);
ctColor.setTheme(theme);
}
@ -386,7 +386,7 @@ public class XSSFFont implements Font {
* @see #DEFAULT_FONT_NAME
*/
public void setFontName(String name) {
CTFontName fontName = ctFont.sizeOfNameArray() == 0 ? ctFont.addNewName() : ctFont.getNameArray(0);
CTFontName fontName = _ctFont.sizeOfNameArray() == 0 ? _ctFont.addNewName() : _ctFont.getNameArray(0);
fontName.setVal(name == null ? DEFAULT_FONT_NAME : name);
}
@ -399,10 +399,10 @@ public class XSSFFont implements Font {
*/
public void setItalic(boolean italic) {
if(italic){
CTBooleanProperty bool = ctFont.sizeOfIArray() == 0 ? ctFont.addNewI() : ctFont.getIArray(0);
CTBooleanProperty bool = _ctFont.sizeOfIArray() == 0 ? _ctFont.addNewI() : _ctFont.getIArray(0);
bool.setVal(italic);
} else {
ctFont.setIArray(null);
_ctFont.setIArray(null);
}
}
@ -414,9 +414,9 @@ public class XSSFFont implements Font {
* @param strikeout - value for strikeout or not
*/
public void setStrikeout(boolean strikeout) {
if(!strikeout) ctFont.setStrikeArray(null);
if(!strikeout) _ctFont.setStrikeArray(null);
else {
CTBooleanProperty strike = ctFont.sizeOfStrikeArray() == 0 ? ctFont.addNewStrike() : ctFont.getStrikeArray(0);
CTBooleanProperty strike = _ctFont.sizeOfStrikeArray() == 0 ? _ctFont.addNewStrike() : _ctFont.getStrikeArray(0);
strike.setVal(strikeout);
}
}
@ -433,9 +433,9 @@ public class XSSFFont implements Font {
*/
public void setTypeOffset(short offset) {
if(offset == Font.SS_NONE){
ctFont.setVertAlignArray(null);
_ctFont.setVertAlignArray(null);
} else {
CTVerticalAlignFontProperty offsetProperty = ctFont.sizeOfVertAlignArray() == 0 ? ctFont.addNewVertAlign() : ctFont.getVertAlignArray(0);
CTVerticalAlignFontProperty offsetProperty = _ctFont.sizeOfVertAlignArray() == 0 ? _ctFont.addNewVertAlign() : _ctFont.getVertAlignArray(0);
switch (offset) {
case Font.SS_NONE:
offsetProperty.setVal(STVerticalAlignRun.BASELINE);
@ -469,10 +469,10 @@ public class XSSFFont implements Font {
* @param underline - FontUnderline enum value
*/
public void setUnderline(FontUnderline underline) {
if(underline == FontUnderline.NONE && ctFont.sizeOfUArray() > 0){
ctFont.setUArray(null);
if(underline == FontUnderline.NONE && _ctFont.sizeOfUArray() > 0){
_ctFont.setUArray(null);
} else {
CTUnderlineProperty ctUnderline = ctFont.sizeOfUArray() == 0 ? ctFont.addNewU() : ctFont.getUArray(0);
CTUnderlineProperty ctUnderline = _ctFont.sizeOfUArray() == 0 ? _ctFont.addNewU() : _ctFont.getUArray(0);
STUnderlineValues.Enum val = STUnderlineValues.Enum.forInt(underline.getValue());
ctUnderline.setVal(val);
}
@ -480,7 +480,7 @@ public class XSSFFont implements Font {
public String toString() {
return ctFont.toString();
return _ctFont.toString();
}
@ -489,7 +489,7 @@ public class XSSFFont implements Font {
*/
public long putFont(StylesTable styles) {
short idx = (short)styles.putFont(this);
this.index = idx;
this._index = idx;
return idx;
}
@ -501,7 +501,7 @@ public class XSSFFont implements Font {
* @see org.apache.poi.xssf.model.StylesTable#createDefaultFont()
*/
public FontScheme getScheme() {
CTFontScheme scheme = ctFont.sizeOfSchemeArray() == 0 ? null : ctFont.getSchemeArray(0);
CTFontScheme scheme = _ctFont.sizeOfSchemeArray() == 0 ? null : _ctFont.getSchemeArray(0);
return scheme == null ? FontScheme.NONE : FontScheme.valueOf(scheme.getVal().intValue());
}
@ -512,7 +512,7 @@ public class XSSFFont implements Font {
* @see FontScheme
*/
public void setScheme(FontScheme scheme) {
CTFontScheme ctFontScheme = ctFont.sizeOfSchemeArray() == 0 ? ctFont.addNewScheme() : ctFont.getSchemeArray(0);
CTFontScheme ctFontScheme = _ctFont.sizeOfSchemeArray() == 0 ? _ctFont.addNewScheme() : _ctFont.getSchemeArray(0);
STFontScheme.Enum val = STFontScheme.Enum.forInt(scheme.getValue());
ctFontScheme.setVal(val);
}
@ -524,7 +524,7 @@ public class XSSFFont implements Font {
* @see org.apache.poi.ss.usermodel.FontFamily
*/
public int getFamily() {
CTIntProperty family = ctFont.sizeOfFamilyArray() == 0 ? ctFont.addNewFamily() : ctFont.getFamilyArray(0);
CTIntProperty family = _ctFont.sizeOfFamilyArray() == 0 ? _ctFont.addNewFamily() : _ctFont.getFamilyArray(0);
return family == null ? FontFamily.NOT_APPLICABLE.getValue() : FontFamily.valueOf(family.getVal()).getValue();
}
@ -537,7 +537,7 @@ public class XSSFFont implements Font {
* @see FontFamily
*/
public void setFamily(int value) {
CTIntProperty family = ctFont.sizeOfFamilyArray() == 0 ? ctFont.addNewFamily() : ctFont.getFamilyArray(0);
CTIntProperty family = _ctFont.sizeOfFamilyArray() == 0 ? _ctFont.addNewFamily() : _ctFont.getFamilyArray(0);
family.setVal(value);
}
@ -560,18 +560,18 @@ public class XSSFFont implements Font {
public short getIndex()
{
return index;
return _index;
}
public int hashCode(){
return ctFont.toString().hashCode();
return _ctFont.toString().hashCode();
}
public boolean equals(Object o){
if(!(o instanceof XSSFFont)) return false;
XSSFFont cf = (XSSFFont)o;
return ctFont.toString().equals(cf.getCTFont().toString());
return _ctFont.toString().equals(cf.getCTFont().toString());
}
}

View File

@ -32,10 +32,10 @@ import org.apache.poi.openxml4j.opc.PackageRelationship;
* are largely stored as relations of the sheet
*/
public class XSSFHyperlink implements Hyperlink {
private int type;
private PackageRelationship externalRel;
private CTHyperlink ctHyperlink;
private String location;
private int _type;
private PackageRelationship _externalRel;
private CTHyperlink _ctHyperlink;
private String _location;
/**
* Create a new XSSFHyperlink. This method is protected to be used only by XSSFCreationHelper
@ -43,8 +43,8 @@ public class XSSFHyperlink implements Hyperlink {
* @param type - the type of hyperlink to create
*/
protected XSSFHyperlink(int type) {
this.type = type;
this.ctHyperlink = CTHyperlink.Factory.newInstance();
_type = type;
_ctHyperlink = CTHyperlink.Factory.newInstance();
}
/**
@ -54,37 +54,36 @@ public class XSSFHyperlink implements Hyperlink {
* @param hyperlinkRel the relationship in the underlying OPC package which stores the actual link's address
*/
protected XSSFHyperlink(CTHyperlink ctHyperlink, PackageRelationship hyperlinkRel) {
this.ctHyperlink = ctHyperlink;
this.externalRel = hyperlinkRel;
_ctHyperlink = ctHyperlink;
_externalRel = hyperlinkRel;
// Figure out the Hyperlink type and distination
// If it has a location, it's internal
if (ctHyperlink.getLocation() != null) {
type = Hyperlink.LINK_DOCUMENT;
location = ctHyperlink.getLocation();
_type = Hyperlink.LINK_DOCUMENT;
_location = ctHyperlink.getLocation();
} else {
// Otherwise it's somehow external, check
// the relation to see how
if (externalRel == null) {
if (_externalRel == null) {
if (ctHyperlink.getId() != null) {
throw new IllegalStateException("The hyperlink for cell " + ctHyperlink.getRef() + " references relation " + ctHyperlink.getId() + ", but that didn't exist!");
} else {
}
throw new IllegalStateException("A sheet hyperlink must either have a location, or a relationship. Found:\n" + ctHyperlink);
}
}
URI target = externalRel.getTargetURI();
location = target.toString();
URI target = _externalRel.getTargetURI();
_location = target.toString();
// Try to figure out the type
if (location.startsWith("http://") || location.startsWith("https://")
|| location.startsWith("ftp://")) {
type = Hyperlink.LINK_URL;
} else if (location.startsWith("mailto:")) {
type = Hyperlink.LINK_EMAIL;
if (_location.startsWith("http://") || _location.startsWith("https://")
|| _location.startsWith("ftp://")) {
_type = Hyperlink.LINK_URL;
} else if (_location.startsWith("mailto:")) {
_type = Hyperlink.LINK_EMAIL;
} else {
type = Hyperlink.LINK_FILE;
_type = Hyperlink.LINK_FILE;
}
}
}
@ -93,7 +92,7 @@ public class XSSFHyperlink implements Hyperlink {
* Returns the underlying hyperlink object
*/
protected CTHyperlink getCTHyperlink() {
return ctHyperlink;
return _ctHyperlink;
}
/**
@ -101,7 +100,7 @@ public class XSSFHyperlink implements Hyperlink {
* this hyperlink?
*/
public boolean needsRelationToo() {
return (type != Hyperlink.LINK_DOCUMENT);
return (_type != Hyperlink.LINK_DOCUMENT);
}
/**
@ -111,10 +110,10 @@ public class XSSFHyperlink implements Hyperlink {
if (needsRelationToo()) {
// Generate the relation
PackageRelationship rel =
sheetPart.addExternalRelationship(location, XSSFRelation.SHEET_HYPERLINKS.getRelation());
sheetPart.addExternalRelationship(_location, XSSFRelation.SHEET_HYPERLINKS.getRelation());
// Update the r:id
ctHyperlink.setId(rel.getId());
_ctHyperlink.setId(rel.getId());
}
}
@ -124,7 +123,7 @@ public class XSSFHyperlink implements Hyperlink {
* @return the type of this hyperlink
*/
public int getType() {
return type;
return _type;
}
/**
@ -132,7 +131,7 @@ public class XSSFHyperlink implements Hyperlink {
* es A55
*/
public String getCellRef() {
return ctHyperlink.getRef();
return _ctHyperlink.getRef();
}
/**
@ -141,7 +140,7 @@ public class XSSFHyperlink implements Hyperlink {
* @return the address of this hyperlink
*/
public String getAddress() {
return location;
return _location;
}
/**
@ -150,7 +149,7 @@ public class XSSFHyperlink implements Hyperlink {
* @return text to display
*/
public String getLabel() {
return ctHyperlink.getDisplay();
return _ctHyperlink.getDisplay();
}
/**
@ -160,7 +159,7 @@ public class XSSFHyperlink implements Hyperlink {
* @return location
*/
public String getLocation() {
return ctHyperlink.getLocation();
return _ctHyperlink.getLocation();
}
/**
@ -169,7 +168,7 @@ public class XSSFHyperlink implements Hyperlink {
* @param label text label for this hyperlink
*/
public void setLabel(String label) {
ctHyperlink.setDisplay(label);
_ctHyperlink.setDisplay(label);
}
/**
@ -179,7 +178,7 @@ public class XSSFHyperlink implements Hyperlink {
* @param location - string representing a location of this hyperlink
*/
public void setLocation(String location) {
ctHyperlink.setLocation(location);
_ctHyperlink.setLocation(location);
}
/**
@ -188,9 +187,9 @@ public class XSSFHyperlink implements Hyperlink {
* @param address - the address of this hyperlink
*/
public void setAddress(String address) {
location = address;
_location = address;
//we must set location for internal hyperlinks
if (type == Hyperlink.LINK_DOCUMENT) {
if (_type == Hyperlink.LINK_DOCUMENT) {
setLocation(address);
}
}
@ -199,11 +198,11 @@ public class XSSFHyperlink implements Hyperlink {
* Assigns this hyperlink to the given cell reference
*/
protected void setCellReference(String ref) {
ctHyperlink.setRef(ref);
_ctHyperlink.setRef(ref);
}
private CellReference buildCellReference() {
return new CellReference(ctHyperlink.getRef());
return new CellReference(_ctHyperlink.getRef());
}
@ -251,7 +250,7 @@ public class XSSFHyperlink implements Hyperlink {
* @param col the 0-based column of the first cell that contains the hyperlink
*/
public void setFirstColumn(int col) {
ctHyperlink.setRef(
_ctHyperlink.setRef(
new CellReference(
getFirstRow(), col
).formatAsString()
@ -273,7 +272,7 @@ public class XSSFHyperlink implements Hyperlink {
* @param row the 0-based row of the first cell that contains the hyperlink
*/
public void setFirstRow(int row) {
ctHyperlink.setRef(
_ctHyperlink.setRef(
new CellReference(
row, getFirstColumn()
).formatAsString()

View File

@ -102,8 +102,8 @@ public final class XSSFName implements Name {
*/
public final static String BUILTIN_SHEET_TITLE = "_xlnm.Sheet_Title";
private XSSFWorkbook workbook;
private CTDefinedName ctName;
private XSSFWorkbook _workbook;
private CTDefinedName _ctName;
/**
* Creates an XSSFName object - called internally by XSSFWorkbook.
@ -113,15 +113,15 @@ public final class XSSFName implements Name {
* @see org.apache.poi.xssf.usermodel.XSSFWorkbook#createName()
*/
protected XSSFName(CTDefinedName name, XSSFWorkbook workbook) {
this.workbook = workbook;
this.ctName = name;
_workbook = workbook;
_ctName = name;
}
/**
* Returns the underlying named range object
*/
protected CTDefinedName getCTName() {
return ctName;
return _ctName;
}
/**
@ -130,7 +130,7 @@ public final class XSSFName implements Name {
* @return text name of this defined name
*/
public String getNameName() {
return ctName.getName();
return _ctName.getName();
}
/**
@ -169,8 +169,8 @@ public final class XSSFName implements Name {
int sheetIndex = getSheetIndex();
//Check to ensure no other names have the same case-insensitive name
for (int i = 0; i < workbook.getNumberOfNames(); i++) {
XSSFName nm = workbook.getNameAt(i);
for (int i = 0; i < _workbook.getNumberOfNames(); i++) {
XSSFName nm = _workbook.getNameAt(i);
if (nm != this) {
if(name.equalsIgnoreCase(nm.getNameName()) && sheetIndex == nm.getSheetIndex()){
String msg = "The "+(sheetIndex == -1 ? "workbook" : "sheet")+" already contains this name: " + name;
@ -178,11 +178,11 @@ public final class XSSFName implements Name {
}
}
}
ctName.setName(name);
_ctName.setName(name);
}
public String getRefersToFormula() {
String result = ctName.getStringValue();
String result = _ctName.getStringValue();
if (result == null || result.length() < 1) {
return null;
}
@ -190,11 +190,11 @@ public final class XSSFName implements Name {
}
public void setRefersToFormula(String formulaText) {
XSSFEvaluationWorkbook fpb = XSSFEvaluationWorkbook.create(workbook);
XSSFEvaluationWorkbook fpb = XSSFEvaluationWorkbook.create(_workbook);
//validate through the FormulaParser
FormulaParser.parse(formulaText, fpb, FormulaType.NAMEDRANGE, getSheetIndex());
ctName.setStringValue(formulaText);
_ctName.setStringValue(formulaText);
}
public boolean isDeleted(){
@ -202,7 +202,7 @@ public final class XSSFName implements Name {
if (formulaText == null) {
return false;
}
XSSFEvaluationWorkbook fpb = XSSFEvaluationWorkbook.create(workbook);
XSSFEvaluationWorkbook fpb = XSSFEvaluationWorkbook.create(_workbook);
Ptg[] ptgs = FormulaParser.parse(formulaText, fpb, FormulaType.NAMEDRANGE, getSheetIndex());
return Ptg.doesFormulaReferToDeletedCell(ptgs);
}
@ -213,16 +213,16 @@ public final class XSSFName implements Name {
* @param index the sheet index this name applies to, -1 unsets this property making the name workbook-global
*/
public void setSheetIndex(int index) {
int lastSheetIx = workbook.getNumberOfSheets() - 1;
int lastSheetIx = _workbook.getNumberOfSheets() - 1;
if (index < -1 || index > lastSheetIx) {
throw new IllegalArgumentException("Sheet index (" + index +") is out of range" +
(lastSheetIx == -1 ? "" : (" (0.." + lastSheetIx + ")")));
}
if(index == -1) {
if(ctName.isSetLocalSheetId()) ctName.unsetLocalSheetId();
if(_ctName.isSetLocalSheetId()) _ctName.unsetLocalSheetId();
} else {
ctName.setLocalSheetId(index);
_ctName.setLocalSheetId(index);
}
}
@ -232,7 +232,7 @@ public final class XSSFName implements Name {
* @return the sheet index this name applies to, -1 if this name applies to the entire workbook
*/
public int getSheetIndex() {
return ctName.isSetLocalSheetId() ? (int) ctName.getLocalSheetId() : -1;
return _ctName.isSetLocalSheetId() ? (int) _ctName.getLocalSheetId() : -1;
}
/**
@ -242,7 +242,7 @@ public final class XSSFName implements Name {
* @param value <code>true</code> indicates the name refers to a function.
*/
public void setFunction(boolean value) {
ctName.setFunction(value);
_ctName.setFunction(value);
}
/**
@ -252,7 +252,7 @@ public final class XSSFName implements Name {
* @return <code>true</code> indicates the name refers to a function.
*/
public boolean getFunction() {
return ctName.getFunction();
return _ctName.getFunction();
}
/**
@ -263,7 +263,7 @@ public final class XSSFName implements Name {
* @param functionGroupId the function group index that defines the general category for the function
*/
public void setFunctionGroupId(int functionGroupId) {
ctName.setFunctionGroupId(functionGroupId);
_ctName.setFunctionGroupId(functionGroupId);
}
/**
@ -274,7 +274,7 @@ public final class XSSFName implements Name {
* @return the function group index that defines the general category for the function
*/
public int getFunctionGroupId() {
return (int) ctName.getFunctionGroupId();
return (int) _ctName.getFunctionGroupId();
}
/**
@ -284,16 +284,15 @@ public final class XSSFName implements Name {
* Empty string if the referenced sheet name weas not found.
*/
public String getSheetName() {
if (ctName.isSetLocalSheetId()) {
if (_ctName.isSetLocalSheetId()) {
// Given as explicit sheet id
int sheetId = (int)ctName.getLocalSheetId();
return workbook.getSheetName(sheetId);
} else {
int sheetId = (int)_ctName.getLocalSheetId();
return _workbook.getSheetName(sheetId);
}
String ref = getRefersToFormula();
AreaReference areaRef = new AreaReference(ref);
return areaRef.getFirstCell().getSheetName();
}
}
/**
* Is the name refers to a user-defined function ?
@ -310,7 +309,7 @@ public final class XSSFName implements Name {
* @return the user comment for this named range
*/
public String getComment() {
return ctName.getComment();
return _ctName.getComment();
}
/**
@ -319,12 +318,12 @@ public final class XSSFName implements Name {
* @param comment the user comment for this named range
*/
public void setComment(String comment) {
ctName.setComment(comment);
_ctName.setComment(comment);
}
@Override
public int hashCode() {
return ctName.toString().hashCode();
return _ctName.toString().hashCode();
}
/**
@ -343,7 +342,7 @@ public final class XSSFName implements Name {
if (!(o instanceof XSSFName)) return false;
XSSFName cf = (XSSFName) o;
return ctName.toString().equals(cf.getCTName().toString());
return _ctName.toString().equals(cf.getCTName().toString());
}
private static void validateName(String name){

View File

@ -256,11 +256,10 @@ public final class XSSFRelation extends POIXMLRelation {
PackagePartName relName = PackagingURIHelper.createPartName(rel.getTargetURI());
PackagePart part = corePart.getPackage().getPart(relName);
return part.getInputStream();
} else {
}
log.log(POILogger.WARN, "No part " + _defaultName + " found");
return null;
}
}
/**

View File

@ -324,15 +324,15 @@ public class XSSFRichTextString implements RichTextString {
* Returns the plain string representation.
*/
public String getString() {
if(st.sizeOfRArray() == 0) return st.getT();
else {
if(st.sizeOfRArray() == 0) {
return st.getT();
}
StringBuffer buf = new StringBuffer();
for(CTRElt r : st.getRArray()){
buf.append(r.getT());
}
return buf.toString();
}
}
/**
* Removes any formatting and sets new string value

View File

@ -38,18 +38,18 @@ public class XSSFRow implements Row, Comparable<XSSFRow> {
/**
* the xml bean containing all cell definitions for this row
*/
private final CTRow row;
private final CTRow _row;
/**
* Cells of this row keyed by their column indexes.
* The TreeMap ensures that the cells are ordered by columnIndex in the ascending order.
*/
private final TreeMap<Integer, Cell> cells;
private final TreeMap<Integer, Cell> _cells;
/**
* the parent sheet
*/
private final XSSFSheet sheet;
private final XSSFSheet _sheet;
/**
* Construct a XSSFRow.
@ -58,12 +58,12 @@ public class XSSFRow implements Row, Comparable<XSSFRow> {
* @param sheet the parent sheet.
*/
protected XSSFRow(CTRow row, XSSFSheet sheet) {
this.row = row;
this.sheet = sheet;
this.cells = new TreeMap<Integer, Cell>();
_row = row;
_sheet = sheet;
_cells = new TreeMap<Integer, Cell>();
for (CTCell c : row.getCArray()) {
XSSFCell cell = new XSSFCell(this, c);
cells.put(cell.getColumnIndex(), cell);
_cells.put(cell.getColumnIndex(), cell);
sheet.onReadCell(cell);
}
}
@ -74,7 +74,7 @@ public class XSSFRow implements Row, Comparable<XSSFRow> {
* @return the XSSFSheet that owns this row
*/
public XSSFSheet getSheet() {
return this.sheet;
return this._sheet;
}
/**
@ -89,7 +89,7 @@ public class XSSFRow implements Row, Comparable<XSSFRow> {
* @return an iterator over cells in this row.
*/
public Iterator<Cell> cellIterator() {
return cells.values().iterator();
return _cells.values().iterator();
}
/**
@ -164,7 +164,7 @@ public class XSSFRow implements Row, Comparable<XSSFRow> {
if (type != Cell.CELL_TYPE_BLANK) {
xcell.setCellType(type);
}
cells.put(columnIndex, xcell);
_cells.put(columnIndex, xcell);
return xcell;
}
@ -175,7 +175,7 @@ public class XSSFRow implements Row, Comparable<XSSFRow> {
* @return the cell at the given (0 based) index
*/
public XSSFCell getCell(int cellnum) {
return getCell(cellnum, sheet.getWorkbook().getMissingCellPolicy());
return getCell(cellnum, _sheet.getWorkbook().getMissingCellPolicy());
}
/**
@ -190,7 +190,7 @@ public class XSSFRow implements Row, Comparable<XSSFRow> {
public XSSFCell getCell(int cellnum, MissingCellPolicy policy) {
if(cellnum < 0) throw new IllegalArgumentException("Cell index must be >= 0");
XSSFCell cell = (XSSFCell)cells.get(cellnum);
XSSFCell cell = (XSSFCell)_cells.get(cellnum);
if(policy == RETURN_NULL_AND_BLANK) {
return cell;
}
@ -217,7 +217,7 @@ public class XSSFRow implements Row, Comparable<XSSFRow> {
* or -1 if the row does not contain any cells.
*/
public short getFirstCellNum() {
return (short)(cells.size() == 0 ? -1 : cells.firstKey());
return (short)(_cells.size() == 0 ? -1 : _cells.firstKey());
}
/**
@ -240,7 +240,7 @@ public class XSSFRow implements Row, Comparable<XSSFRow> {
* or -1 if the row does not contain any cells.
*/
public short getLastCellNum() {
return (short)(cells.size() == 0 ? -1 : (cells.lastKey() + 1));
return (short)(_cells.size() == 0 ? -1 : (_cells.lastKey() + 1));
}
/**
@ -261,11 +261,10 @@ public class XSSFRow implements Row, Comparable<XSSFRow> {
* @see org.apache.poi.xssf.usermodel.XSSFSheet#getDefaultRowHeightInPoints()
*/
public float getHeightInPoints() {
if (this.row.isSetHt()) {
return (float) this.row.getHt();
} else {
return sheet.getDefaultRowHeightInPoints();
if (this._row.isSetHt()) {
return (float) this._row.getHt();
}
return _sheet.getDefaultRowHeightInPoints();
}
/**
@ -275,11 +274,11 @@ public class XSSFRow implements Row, Comparable<XSSFRow> {
*/
public void setHeight(short height) {
if (height == -1) {
if (row.isSetHt()) row.unsetHt();
if (row.isSetCustomHeight()) row.unsetCustomHeight();
if (_row.isSetHt()) _row.unsetHt();
if (_row.isSetCustomHeight()) _row.unsetCustomHeight();
} else {
row.setHt((double) height / 20);
row.setCustomHeight(true);
_row.setHt((double) height / 20);
_row.setCustomHeight(true);
}
}
@ -300,7 +299,7 @@ public class XSSFRow implements Row, Comparable<XSSFRow> {
* @return int representing the number of defined cells in the row.
*/
public int getPhysicalNumberOfCells() {
return cells.size();
return _cells.size();
}
/**
@ -309,7 +308,7 @@ public class XSSFRow implements Row, Comparable<XSSFRow> {
* @return the row number (0 based)
*/
public int getRowNum() {
return (int) (row.getR() - 1);
return (int) (_row.getR() - 1);
}
/**
@ -324,7 +323,7 @@ public class XSSFRow implements Row, Comparable<XSSFRow> {
throw new IllegalArgumentException("Invalid row number (" + rowIndex
+ ") outside allowable range (0.." + maxrow + ")");
}
row.setR(rowIndex + 1);
_row.setR(rowIndex + 1);
}
/**
@ -333,7 +332,7 @@ public class XSSFRow implements Row, Comparable<XSSFRow> {
* @return - height is zero or not.
*/
public boolean getZeroHeight() {
return this.row.getHidden();
return this._row.getHidden();
}
/**
@ -342,7 +341,7 @@ public class XSSFRow implements Row, Comparable<XSSFRow> {
* @param height height is zero or not.
*/
public void setZeroHeight(boolean height) {
this.row.setHidden(height);
this._row.setHidden(height);
}
@ -352,7 +351,7 @@ public class XSSFRow implements Row, Comparable<XSSFRow> {
* @param cell the cell to remove
*/
public void removeCell(Cell cell) {
cells.remove(cell.getColumnIndex());
_cells.remove(cell.getColumnIndex());
}
/**
@ -361,7 +360,7 @@ public class XSSFRow implements Row, Comparable<XSSFRow> {
* @return the underlying CTRow xml bean
*/
public CTRow getCTRow(){
return row;
return _row;
}
/**
@ -372,14 +371,14 @@ public class XSSFRow implements Row, Comparable<XSSFRow> {
* @see org.apache.poi.xssf.usermodel.XSSFSheet#commit()
*/
protected void onDocumentWrite(){
ArrayList<CTCell> cArray = new ArrayList<CTCell>(cells.size());
ArrayList<CTCell> cArray = new ArrayList<CTCell>(_cells.size());
//create array of CTCell objects.
//TreeMap's value iterator ensures that the cells are ordered by columnIndex in the ascending order
for (Cell cell : cells.values()) {
for (Cell cell : _cells.values()) {
XSSFCell c = (XSSFCell)cell;
cArray.add(c.getCTCell());
}
row.setCArray(cArray.toArray(new CTCell[cArray.size()]));
_row.setCArray(cArray.toArray(new CTCell[cArray.size()]));
}
/**
@ -387,7 +386,7 @@ public class XSSFRow implements Row, Comparable<XSSFRow> {
*/
@Override
public String toString(){
return row.toString();
return _row.toString();
}
/**
@ -397,8 +396,8 @@ public class XSSFRow implements Row, Comparable<XSSFRow> {
*/
protected void shift(int n) {
int rownum = getRowNum() + n;
CalculationChain calcChain = sheet.getWorkbook().getCalculationChain();
int sheetId = (int)sheet.sheet.getSheetId();
CalculationChain calcChain = _sheet.getWorkbook().getCalculationChain();
int sheetId = (int)_sheet.sheet.getSheetId();
for(Cell c : this){
XSSFCell cell = (XSSFCell)c;

View File

@ -434,8 +434,10 @@ public class XSSFSheet extends POIXMLDocumentPart implements Sheet {
}
public XSSFComment getCellComment(int row, int column) {
if (sheetComments == null) return null;
else return sheetComments.findCellComment(row, column);
if (sheetComments == null) {
return null;
}
return sheetComments.findCellComment(row, column);
}
public XSSFHyperlink getHyperlink(int row, int column) {
@ -1915,9 +1917,8 @@ public class XSSFSheet extends POIXMLDocumentPart implements Sheet {
}
if (endLevel > startLevel) {
return endHidden;
} else {
return startHidden;
}
return startHidden;
}
/**
@ -1925,9 +1926,9 @@ public class XSSFSheet extends POIXMLDocumentPart implements Sheet {
*/
private boolean isRowGroupCollapsed(int row) {
int collapseRow = findEndOfRowOutlineGroup(row) + 1;
if (getRow(collapseRow) == null)
if (getRow(collapseRow) == null) {
return false;
else
}
return getRow(collapseRow).getCTRow().getCollapsed();
}

View File

@ -582,9 +582,9 @@ public class XWPFParagraph {
CTOnOff ct_pageBreak = ppr.isSetPageBreakBefore() ? ppr
.getPageBreakBefore() : null;
if (ct_pageBreak != null
&& ct_pageBreak.getVal().intValue() == STOnOff.INT_TRUE)
&& ct_pageBreak.getVal().intValue() == STOnOff.INT_TRUE) {
return true;
else
}
return false;
}
@ -934,7 +934,7 @@ public class XWPFParagraph {
return (wordWrap.getVal() == STOnOff.ON
|| wordWrap.getVal() == STOnOff.TRUE || wordWrap.getVal() == STOnOff.X_1) ? true
: false;
} else
}
return false;
}

View File

@ -155,9 +155,9 @@ public class XWPFTable {
* @return the row at the position specified or null if no rows is defined or if the position is greather than the max size of rows array
*/
public XWPFTableRow getRow(int pos) {
if (pos >= 0 && pos < ctTbl.sizeOfTrArray())
if (pos >= 0 && pos < ctTbl.sizeOfTrArray()) {
return new XWPFTableRow(ctTbl.getTrArray(pos));
else
}
return null;
}

View File

@ -44,9 +44,9 @@ public class XWPFTableRow {
}
public XWPFTableCell getCell(int pos) {
if (pos >= 0 && pos < ctRow.sizeOfTcArray())
if (pos >= 0 && pos < ctRow.sizeOfTcArray()) {
return new XWPFTableCell(ctRow.getTcArray(pos));
else
}
return null;
}

View File

@ -52,14 +52,6 @@ public final class HeaderFooter
}
public boolean isEmpty()
{
if(_start - _end == 0)
{
return true;
}
else
{
return false;
return _start - _end == 0;
}
}
}

View File

@ -1279,13 +1279,6 @@ public final class StyleSheet {
}
public static boolean getFlag(int x)
{
if(x != 0)
{
return true;
}
else
{
return false;
}
return x != 0;
}
}

View File

@ -314,8 +314,6 @@ public final class WordDocument {
{
throw new IOException("corrupted Word file");
}
else
{
//parse out the text pieces
int pieceTableSize = LittleEndian.getInt(tableStream, ++pos);
pos += 4;
@ -339,9 +337,6 @@ public final class WordDocument {
TextPiece piece = new TextPiece(filePos, totLength, unicode);
_text.add(piece);
}
}
}
@ -355,8 +350,7 @@ public final class WordDocument {
* @param size of the paragraph bin table.
*/
private void findFormatting(byte[] tableStream, int charOffset,
int charPlcSize, int parOffset, int parPlcSize) throws IOException
{
int charPlcSize, int parOffset, int parPlcSize) {
openDoc();
createStyleSheet(tableStream);
createListTables(tableStream);
@ -1287,7 +1281,7 @@ public final class WordDocument {
private ArrayList findProperties(int start, int end, BTreeSet.BTreeNode root)
{
ArrayList results = new ArrayList();
BTreeSet.Entry[] entries = root.entries;
BTreeSet.Entry[] entries = root._entries;
for(int x = 0; x < entries.length; x++)
{
@ -1366,7 +1360,7 @@ public final class WordDocument {
private ArrayList findPAPProperties(int start, int end, BTreeSet.BTreeNode root)
{
ArrayList results = new ArrayList();
BTreeSet.Entry[] entries = root.entries;
BTreeSet.Entry[] entries = root._entries;
for(int x = 0; x < entries.length; x++)
{

View File

@ -42,8 +42,8 @@ public final class BTreeSet extends AbstractSet implements Set {
*/
public BTreeNode root;
private Comparator comparator = null;
private int order;
private int size = 0;
int order;
int size = 0;
/*
* Constructors
@ -99,14 +99,14 @@ public final class BTreeSet extends AbstractSet implements Set {
}
public java.util.Iterator iterator() {
return new Iterator();
return new BTIterator();
}
/*
* Private methods
*/
private int compare(Object x, Object y) {
int compare(Object x, Object y) {
return (comparator == null ? ((Comparable)x).compareTo(y) : comparator.compare(x, y));
}
@ -125,14 +125,14 @@ public final class BTreeSet extends AbstractSet implements Set {
* chance of receiving a NullPointerException. The Iterator.delete method is supported.
*/
private class Iterator implements java.util.Iterator {
private final class BTIterator implements java.util.Iterator {
private int index = 0;
private Stack parentIndex = new Stack(); // Contains all parentIndicies for currentNode
Stack parentIndex = new Stack(); // Contains all parentIndicies for currentNode
private Object lastReturned = null;
private Object next;
private BTreeNode currentNode;
BTreeNode currentNode;
Iterator() {
BTIterator() {
currentNode = firstNode();
next = nextElement();
}
@ -159,8 +159,8 @@ public final class BTreeSet extends AbstractSet implements Set {
private BTreeNode firstNode() {
BTreeNode temp = BTreeSet.this.root;
while (temp.entries[0].child != null) {
temp = temp.entries[0].child;
while (temp._entries[0].child != null) {
temp = temp._entries[0].child;
parentIndex.push(new Integer(0));
}
@ -169,40 +169,39 @@ public final class BTreeSet extends AbstractSet implements Set {
private Object nextElement() {
if (currentNode.isLeaf()) {
if (index < currentNode.nrElements) return currentNode.entries[index++].element;
if (index < currentNode._nrElements) return currentNode._entries[index++].element;
else if (!parentIndex.empty()) { //All elements have been returned, return successor of lastReturned if it exists
currentNode = currentNode.parent;
currentNode = currentNode._parent;
index = ((Integer)parentIndex.pop()).intValue();
while (index == currentNode.nrElements) {
while (index == currentNode._nrElements) {
if (parentIndex.empty()) break;
currentNode = currentNode.parent;
currentNode = currentNode._parent;
index = ((Integer)parentIndex.pop()).intValue();
}
if (index == currentNode.nrElements) return null; //Reached root and he has no more children
return currentNode.entries[index++].element;
if (index == currentNode._nrElements) return null; //Reached root and he has no more children
return currentNode._entries[index++].element;
}
else { //Your a leaf and the root
if (index == currentNode.nrElements) return null;
return currentNode.entries[index++].element;
if (index == currentNode._nrElements) return null;
return currentNode._entries[index++].element;
}
}
else { //Your not a leaf so simply find and return the successor of lastReturned
currentNode = currentNode.entries[index].child;
// else - You're not a leaf so simply find and return the successor of lastReturned
currentNode = currentNode._entries[index].child;
parentIndex.push(new Integer(index));
while (currentNode.entries[0].child != null) {
currentNode = currentNode.entries[0].child;
while (currentNode._entries[0].child != null) {
currentNode = currentNode._entries[0].child;
parentIndex.push(new Integer(0));
}
index = 1;
return currentNode.entries[0].element;
}
return currentNode._entries[0].element;
}
}
@ -216,49 +215,51 @@ public final class BTreeSet extends AbstractSet implements Set {
public class BTreeNode {
public Entry[] entries;
public BTreeNode parent;
private int nrElements = 0;
public Entry[] _entries;
public BTreeNode _parent;
int _nrElements = 0;
private final int MIN = (BTreeSet.this.order - 1) / 2;
BTreeNode(BTreeNode parent) {
this.parent = parent;
entries = new Entry[BTreeSet.this.order];
entries[0] = new Entry();
_parent = parent;
_entries = new Entry[BTreeSet.this.order];
_entries[0] = new Entry();
}
boolean insert(Object x, int parentIndex) {
if (isFull()) { // If full, you must split and promote splitNode before inserting
Object splitNode = entries[nrElements / 2].element;
Object splitNode = _entries[_nrElements / 2].element;
BTreeNode rightSibling = split();
if (isRoot()) { // Grow a level
splitRoot(splitNode, this, rightSibling);
// Determine where to insert
if (BTreeSet.this.compare(x, BTreeSet.this.root.entries[0].element) < 0) insert(x, 0);
if (BTreeSet.this.compare(x, BTreeSet.this.root._entries[0].element) < 0) insert(x, 0);
else rightSibling.insert(x, 1);
}
else { // Promote splitNode
parent.insertSplitNode(splitNode, this, rightSibling, parentIndex);
if (BTreeSet.this.compare(x, parent.entries[parentIndex].element) < 0) return insert(x, parentIndex);
else return rightSibling.insert(x, parentIndex + 1);
_parent.insertSplitNode(splitNode, this, rightSibling, parentIndex);
if (BTreeSet.this.compare(x, _parent._entries[parentIndex].element) < 0) {
return insert(x, parentIndex);
}
return rightSibling.insert(x, parentIndex + 1);
}
}
else if (isLeaf()) { // If leaf, simply insert the non-duplicate element
int insertAt = childToInsertAt(x, true);
if (insertAt == -1) return false; // Determine if the element already exists
else {
if (insertAt == -1) {
return false; // Determine if the element already exists
}
insertNewElement(x, insertAt);
BTreeSet.this.size++;
return true;
}
}
else { // If not full and not leaf recursively find correct node to insert at
int insertAt = childToInsertAt(x, true);
return (insertAt == -1 ? false : entries[insertAt].child.insert(x, insertAt));
return (insertAt == -1 ? false : _entries[insertAt].child.insert(x, insertAt));
}
return false;
}
@ -266,8 +267,8 @@ public final class BTreeSet extends AbstractSet implements Set {
boolean includes(Object x) {
int index = childToInsertAt(x, true);
if (index == -1) return true;
if (entries[index] == null || entries[index].child == null) return false;
return entries[index].child.includes(x);
if (_entries[index] == null || _entries[index].child == null) return false;
return _entries[index].child.includes(x);
}
boolean delete(Object x, int parentIndex) {
@ -276,8 +277,8 @@ public final class BTreeSet extends AbstractSet implements Set {
BTreeNode temp = this;
if (i != -1) {
do {
if (temp.entries[i] == null || temp.entries[i].child == null) return false;
temp = temp.entries[i].child;
if (temp._entries[i] == null || temp._entries[i].child == null) return false;
temp = temp._entries[i].child;
priorParentIndex = parentIndex;
parentIndex = i;
i = temp.childToInsertAt(x, true);
@ -285,54 +286,52 @@ public final class BTreeSet extends AbstractSet implements Set {
} // Now temp contains element to delete and temp's parentIndex is parentIndex
if (temp.isLeaf()) { // If leaf and have more than MIN elements, simply delete
if (temp.nrElements > MIN) {
if (temp._nrElements > MIN) {
temp.deleteElement(x);
BTreeSet.this.size--;
return true;
}
else { // If leaf and have less than MIN elements, than prepare the BTreeSet for deletion
// else If leaf and have less than MIN elements, than prepare the BTreeSet for deletion
temp.prepareForDeletion(parentIndex);
temp.deleteElement(x);
BTreeSet.this.size--;
temp.fixAfterDeletion(priorParentIndex);
return true;
}
}
else { // Only delete at leaf so first switch with successor than delete
// else Only delete at leaf so first switch with successor than delete
temp.switchWithSuccessor(x);
parentIndex = temp.childToInsertAt(x, false) + 1;
return temp.entries[parentIndex].child.delete(x, parentIndex);
}
return temp._entries[parentIndex].child.delete(x, parentIndex);
}
private boolean isFull() { return nrElements == (BTreeSet.this.order - 1); }
private boolean isFull() { return _nrElements == (BTreeSet.this.order - 1); }
private boolean isLeaf() { return entries[0].child == null; }
boolean isLeaf() { return _entries[0].child == null; }
private boolean isRoot() { return parent == null; }
private boolean isRoot() { return _parent == null; }
/*
* Splits a BTreeNode into two BTreeNodes, removing the splitNode from the
* calling BTreeNode.
*/
private BTreeNode split() {
BTreeNode rightSibling = new BTreeNode(parent);
int index = nrElements / 2;
entries[index++].element = null;
BTreeNode rightSibling = new BTreeNode(_parent);
int index = _nrElements / 2;
_entries[index++].element = null;
for (int i = 0, nr = nrElements; index <= nr; i++, index++) {
rightSibling.entries[i] = entries[index];
if (rightSibling.entries[i] != null && rightSibling.entries[i].child != null)
rightSibling.entries[i].child.parent = rightSibling;
entries[index] = null;
nrElements--;
rightSibling.nrElements++;
for (int i = 0, nr = _nrElements; index <= nr; i++, index++) {
rightSibling._entries[i] = _entries[index];
if (rightSibling._entries[i] != null && rightSibling._entries[i].child != null)
rightSibling._entries[i].child._parent = rightSibling;
_entries[index] = null;
_nrElements--;
rightSibling._nrElements++;
}
rightSibling.nrElements--; // Need to correct for copying the last Entry which has a null element and a child
rightSibling._nrElements--; // Need to correct for copying the last Entry which has a null element and a child
return rightSibling;
}
@ -342,34 +341,34 @@ public final class BTreeSet extends AbstractSet implements Set {
*/
private void splitRoot(Object splitNode, BTreeNode left, BTreeNode right) {
BTreeNode newRoot = new BTreeNode(null);
newRoot.entries[0].element = splitNode;
newRoot.entries[0].child = left;
newRoot.entries[1] = new Entry();
newRoot.entries[1].child = right;
newRoot.nrElements = 1;
left.parent = right.parent = newRoot;
newRoot._entries[0].element = splitNode;
newRoot._entries[0].child = left;
newRoot._entries[1] = new Entry();
newRoot._entries[1].child = right;
newRoot._nrElements = 1;
left._parent = right._parent = newRoot;
BTreeSet.this.root = newRoot;
}
private void insertSplitNode(Object splitNode, BTreeNode left, BTreeNode right, int insertAt) {
for (int i = nrElements; i >= insertAt; i--) entries[i + 1] = entries[i];
for (int i = _nrElements; i >= insertAt; i--) _entries[i + 1] = _entries[i];
entries[insertAt] = new Entry();
entries[insertAt].element = splitNode;
entries[insertAt].child = left;
entries[insertAt + 1].child = right;
_entries[insertAt] = new Entry();
_entries[insertAt].element = splitNode;
_entries[insertAt].child = left;
_entries[insertAt + 1].child = right;
nrElements++;
_nrElements++;
}
private void insertNewElement(Object x, int insertAt) {
for (int i = nrElements; i > insertAt; i--) entries[i] = entries[i - 1];
for (int i = _nrElements; i > insertAt; i--) _entries[i] = _entries[i - 1];
entries[insertAt] = new Entry();
entries[insertAt].element = x;
_entries[insertAt] = new Entry();
_entries[insertAt].element = x;
nrElements++;
_nrElements++;
}
/*
@ -382,13 +381,13 @@ public final class BTreeSet extends AbstractSet implements Set {
* in entries[] is returned.
*/
private int childToInsertAt(Object x, boolean position) {
int index = nrElements / 2;
int index = _nrElements / 2;
if (entries[index] == null || entries[index].element == null) return index;
if (_entries[index] == null || _entries[index].element == null) return index;
int lo = 0, hi = nrElements - 1;
int lo = 0, hi = _nrElements - 1;
while (lo <= hi) {
if (BTreeSet.this.compare(x, entries[index].element) > 0) {
if (BTreeSet.this.compare(x, _entries[index].element) > 0) {
lo = index + 1;
index = (hi + lo) / 2;
}
@ -399,32 +398,32 @@ public final class BTreeSet extends AbstractSet implements Set {
}
hi++;
if (entries[hi] == null || entries[hi].element == null) return hi;
return (!position ? hi : BTreeSet.this.compare(x, entries[hi].element) == 0 ? -1 : hi);
if (_entries[hi] == null || _entries[hi].element == null) return hi;
return (!position ? hi : BTreeSet.this.compare(x, _entries[hi].element) == 0 ? -1 : hi);
}
private void deleteElement(Object x) {
int index = childToInsertAt(x, false);
for (; index < (nrElements - 1); index++) entries[index] = entries[index + 1];
for (; index < (_nrElements - 1); index++) _entries[index] = _entries[index + 1];
if (nrElements == 1) entries[index] = new Entry(); // This is root and it is empty
else entries[index] = null;
if (_nrElements == 1) _entries[index] = new Entry(); // This is root and it is empty
else _entries[index] = null;
nrElements--;
_nrElements--;
}
private void prepareForDeletion(int parentIndex) {
if (isRoot()) return; // Don't attempt to steal or merge if your the root
// If not root then try to steal left
else if (parentIndex != 0 && parent.entries[parentIndex - 1].child.nrElements > MIN) {
else if (parentIndex != 0 && _parent._entries[parentIndex - 1].child._nrElements > MIN) {
stealLeft(parentIndex);
return;
}
// If not root and can't steal left try to steal right
else if (parentIndex < entries.length && parent.entries[parentIndex + 1] != null && parent.entries[parentIndex + 1].child != null && parent.entries[parentIndex + 1].child.nrElements > MIN) {
else if (parentIndex < _entries.length && _parent._entries[parentIndex + 1] != null && _parent._entries[parentIndex + 1].child != null && _parent._entries[parentIndex + 1].child._nrElements > MIN) {
stealRight(parentIndex);
return;
}
@ -440,29 +439,29 @@ public final class BTreeSet extends AbstractSet implements Set {
}
private void fixAfterDeletion(int parentIndex) {
if (isRoot() || parent.isRoot()) return; // No fixing needed
if (isRoot() || _parent.isRoot()) return; // No fixing needed
if (parent.nrElements < MIN) { // If parent lost it's n/2 element repair it
BTreeNode temp = parent;
if (_parent._nrElements < MIN) { // If parent lost it's n/2 element repair it
BTreeNode temp = _parent;
temp.prepareForDeletion(parentIndex);
if (temp.parent == null) return; // Root changed
if (!temp.parent.isRoot() && temp.parent.nrElements < MIN) { // If need be recurse
BTreeNode x = temp.parent.parent;
if (temp._parent == null) return; // Root changed
if (!temp._parent.isRoot() && temp._parent._nrElements < MIN) { // If need be recurse
BTreeNode x = temp._parent._parent;
int i = 0;
// Find parent's parentIndex
for (; i < entries.length; i++) if (x.entries[i].child == temp.parent) break;
temp.parent.fixAfterDeletion(i);
for (; i < _entries.length; i++) if (x._entries[i].child == temp._parent) break;
temp._parent.fixAfterDeletion(i);
}
}
}
private void switchWithSuccessor(Object x) {
int index = childToInsertAt(x, false);
BTreeNode temp = entries[index + 1].child;
while (temp.entries[0] != null && temp.entries[0].child != null) temp = temp.entries[0].child;
Object successor = temp.entries[0].element;
temp.entries[0].element = entries[index].element;
entries[index].element = successor;
BTreeNode temp = _entries[index + 1].child;
while (temp._entries[0] != null && temp._entries[0].child != null) temp = temp._entries[0].child;
Object successor = temp._entries[0].element;
temp._entries[0].element = _entries[index].element;
_entries[index].element = successor;
}
/*
@ -470,26 +469,26 @@ public final class BTreeSet extends AbstractSet implements Set {
* has a leftSibling, and the leftSibling has more than the minimum number of elements.
*/
private void stealLeft(int parentIndex) {
BTreeNode p = parent;
BTreeNode ls = parent.entries[parentIndex - 1].child;
BTreeNode p = _parent;
BTreeNode ls = _parent._entries[parentIndex - 1].child;
if (isLeaf()) { // When stealing from leaf to leaf don't worry about children
int add = childToInsertAt(p.entries[parentIndex - 1].element, true);
insertNewElement(p.entries[parentIndex - 1].element, add);
p.entries[parentIndex - 1].element = ls.entries[ls.nrElements - 1].element;
ls.entries[ls.nrElements - 1] = null;
ls.nrElements--;
int add = childToInsertAt(p._entries[parentIndex - 1].element, true);
insertNewElement(p._entries[parentIndex - 1].element, add);
p._entries[parentIndex - 1].element = ls._entries[ls._nrElements - 1].element;
ls._entries[ls._nrElements - 1] = null;
ls._nrElements--;
}
else { // Was called recursively to fix an undermanned parent
entries[0].element = p.entries[parentIndex - 1].element;
p.entries[parentIndex - 1].element = ls.entries[ls.nrElements - 1].element;
entries[0].child = ls.entries[ls.nrElements].child;
entries[0].child.parent = this;
ls.entries[ls.nrElements] = null;
ls.entries[ls.nrElements - 1].element = null;
nrElements++;
ls.nrElements--;
_entries[0].element = p._entries[parentIndex - 1].element;
p._entries[parentIndex - 1].element = ls._entries[ls._nrElements - 1].element;
_entries[0].child = ls._entries[ls._nrElements].child;
_entries[0].child._parent = this;
ls._entries[ls._nrElements] = null;
ls._entries[ls._nrElements - 1].element = null;
_nrElements++;
ls._nrElements--;
}
}
@ -499,30 +498,30 @@ public final class BTreeSet extends AbstractSet implements Set {
* has more than the minimum number of elements.
*/
private void stealRight(int parentIndex) {
BTreeNode p = parent;
BTreeNode rs = p.entries[parentIndex + 1].child;
BTreeNode p = _parent;
BTreeNode rs = p._entries[parentIndex + 1].child;
if (isLeaf()) { // When stealing from leaf to leaf don't worry about children
entries[nrElements] = new Entry();
entries[nrElements].element = p.entries[parentIndex].element;
p.entries[parentIndex].element = rs.entries[0].element;
for (int i = 0; i < rs.nrElements; i++) rs.entries[i] = rs.entries[i + 1];
rs.entries[rs.nrElements - 1] = null;
nrElements++;
rs.nrElements--;
_entries[_nrElements] = new Entry();
_entries[_nrElements].element = p._entries[parentIndex].element;
p._entries[parentIndex].element = rs._entries[0].element;
for (int i = 0; i < rs._nrElements; i++) rs._entries[i] = rs._entries[i + 1];
rs._entries[rs._nrElements - 1] = null;
_nrElements++;
rs._nrElements--;
}
else { // Was called recursively to fix an undermanned parent
for (int i = 0; i <= nrElements; i++) entries[i] = entries[i + 1];
entries[nrElements].element = p.entries[parentIndex].element;
p.entries[parentIndex].element = rs.entries[0].element;
entries[nrElements + 1] = new Entry();
entries[nrElements + 1].child = rs.entries[0].child;
entries[nrElements + 1].child.parent = this;
for (int i = 0; i <= rs.nrElements; i++) rs.entries[i] = rs.entries[i + 1];
rs.entries[rs.nrElements] = null;
nrElements++;
rs.nrElements--;
for (int i = 0; i <= _nrElements; i++) _entries[i] = _entries[i + 1];
_entries[_nrElements].element = p._entries[parentIndex].element;
p._entries[parentIndex].element = rs._entries[0].element;
_entries[_nrElements + 1] = new Entry();
_entries[_nrElements + 1].child = rs._entries[0].child;
_entries[_nrElements + 1].child._parent = this;
for (int i = 0; i <= rs._nrElements; i++) rs._entries[i] = rs._entries[i + 1];
rs._entries[rs._nrElements] = null;
_nrElements++;
rs._nrElements--;
}
}
@ -536,77 +535,77 @@ public final class BTreeSet extends AbstractSet implements Set {
* expect the parent to be in such a condition.
*/
private void mergeLeft(int parentIndex) {
BTreeNode p = parent;
BTreeNode ls = p.entries[parentIndex - 1].child;
BTreeNode p = _parent;
BTreeNode ls = p._entries[parentIndex - 1].child;
if (isLeaf()) { // Don't worry about children
int add = childToInsertAt(p.entries[parentIndex - 1].element, true);
insertNewElement(p.entries[parentIndex - 1].element, add); // Could have been a successor switch
p.entries[parentIndex - 1].element = null;
int add = childToInsertAt(p._entries[parentIndex - 1].element, true);
insertNewElement(p._entries[parentIndex - 1].element, add); // Could have been a successor switch
p._entries[parentIndex - 1].element = null;
for (int i = nrElements - 1, nr = ls.nrElements; i >= 0; i--)
entries[i + nr] = entries[i];
for (int i = _nrElements - 1, nr = ls._nrElements; i >= 0; i--)
_entries[i + nr] = _entries[i];
for (int i = ls.nrElements - 1; i >= 0; i--) {
entries[i] = ls.entries[i];
nrElements++;
for (int i = ls._nrElements - 1; i >= 0; i--) {
_entries[i] = ls._entries[i];
_nrElements++;
}
if (p.nrElements == MIN && p != BTreeSet.this.root) {
if (p._nrElements == MIN && p != BTreeSet.this.root) {
for (int x = parentIndex - 1, y = parentIndex - 2; y >= 0; x--, y--)
p.entries[x] = p.entries[y];
p.entries[0] = new Entry();
p.entries[0].child = ls; //So p doesn't think it's a leaf this will be deleted in the next recursive call
p._entries[x] = p._entries[y];
p._entries[0] = new Entry();
p._entries[0].child = ls; //So p doesn't think it's a leaf this will be deleted in the next recursive call
}
else {
for (int x = parentIndex - 1, y = parentIndex; y <= p.nrElements; x++, y++)
p.entries[x] = p.entries[y];
p.entries[p.nrElements] = null;
for (int x = parentIndex - 1, y = parentIndex; y <= p._nrElements; x++, y++)
p._entries[x] = p._entries[y];
p._entries[p._nrElements] = null;
}
p.nrElements--;
p._nrElements--;
if (p.isRoot() && p.nrElements == 0) { // It's the root and it's empty
if (p.isRoot() && p._nrElements == 0) { // It's the root and it's empty
BTreeSet.this.root = this;
parent = null;
_parent = null;
}
}
else { // I'm not a leaf but fixing the tree structure
entries[0].element = p.entries[parentIndex - 1].element;
entries[0].child = ls.entries[ls.nrElements].child;
nrElements++;
_entries[0].element = p._entries[parentIndex - 1].element;
_entries[0].child = ls._entries[ls._nrElements].child;
_nrElements++;
for (int x = nrElements, nr = ls.nrElements; x >= 0; x--)
entries[x + nr] = entries[x];
for (int x = _nrElements, nr = ls._nrElements; x >= 0; x--)
_entries[x + nr] = _entries[x];
for (int x = ls.nrElements - 1; x >= 0; x--) {
entries[x] = ls.entries[x];
entries[x].child.parent = this;
nrElements++;
for (int x = ls._nrElements - 1; x >= 0; x--) {
_entries[x] = ls._entries[x];
_entries[x].child._parent = this;
_nrElements++;
}
if (p.nrElements == MIN && p != BTreeSet.this.root) { // Push everything to the right
if (p._nrElements == MIN && p != BTreeSet.this.root) { // Push everything to the right
for (int x = parentIndex - 1, y = parentIndex - 2; y >= 0; x++, y++){
System.out.println(x + " " + y);
p.entries[x] = p.entries[y];}
p.entries[0] = new Entry();
p._entries[x] = p._entries[y];}
p._entries[0] = new Entry();
}
else { // Either p.nrElements > MIN or p == BTreeSet.this.root so push everything to the left
for (int x = parentIndex - 1, y = parentIndex; y <= p.nrElements; x++, y++)
p.entries[x] = p.entries[y];
p.entries[p.nrElements] = null;
for (int x = parentIndex - 1, y = parentIndex; y <= p._nrElements; x++, y++)
p._entries[x] = p._entries[y];
p._entries[p._nrElements] = null;
}
p.nrElements--;
p._nrElements--;
if (p.isRoot() && p.nrElements == 0) { // p == BTreeSet.this.root and it's empty
if (p.isRoot() && p._nrElements == 0) { // p == BTreeSet.this.root and it's empty
BTreeSet.this.root = this;
parent = null;
_parent = null;
}
}
}
@ -621,69 +620,69 @@ public final class BTreeSet extends AbstractSet implements Set {
* expect the parent to be in such a condition.
*/
private void mergeRight(int parentIndex) {
BTreeNode p = parent;
BTreeNode rs = p.entries[parentIndex + 1].child;
BTreeNode p = _parent;
BTreeNode rs = p._entries[parentIndex + 1].child;
if (isLeaf()) { // Don't worry about children
entries[nrElements] = new Entry();
entries[nrElements].element = p.entries[parentIndex].element;
nrElements++;
for (int i = 0, nr = nrElements; i < rs.nrElements; i++, nr++) {
entries[nr] = rs.entries[i];
nrElements++;
_entries[_nrElements] = new Entry();
_entries[_nrElements].element = p._entries[parentIndex].element;
_nrElements++;
for (int i = 0, nr = _nrElements; i < rs._nrElements; i++, nr++) {
_entries[nr] = rs._entries[i];
_nrElements++;
}
p.entries[parentIndex].element = p.entries[parentIndex + 1].element;
if (p.nrElements == MIN && p != BTreeSet.this.root) {
p._entries[parentIndex].element = p._entries[parentIndex + 1].element;
if (p._nrElements == MIN && p != BTreeSet.this.root) {
for (int x = parentIndex + 1, y = parentIndex; y >= 0; x--, y--)
p.entries[x] = p.entries[y];
p.entries[0] = new Entry();
p.entries[0].child = rs; // So it doesn't think it's a leaf, this child will be deleted in the next recursive call
p._entries[x] = p._entries[y];
p._entries[0] = new Entry();
p._entries[0].child = rs; // So it doesn't think it's a leaf, this child will be deleted in the next recursive call
}
else {
for (int x = parentIndex + 1, y = parentIndex + 2; y <= p.nrElements; x++, y++)
p.entries[x] = p.entries[y];
p.entries[p.nrElements] = null;
for (int x = parentIndex + 1, y = parentIndex + 2; y <= p._nrElements; x++, y++)
p._entries[x] = p._entries[y];
p._entries[p._nrElements] = null;
}
p.nrElements--;
if (p.isRoot() && p.nrElements == 0) { // It's the root and it's empty
p._nrElements--;
if (p.isRoot() && p._nrElements == 0) { // It's the root and it's empty
BTreeSet.this.root = this;
parent = null;
_parent = null;
}
}
else { // It's not a leaf
entries[nrElements].element = p.entries[parentIndex].element;
nrElements++;
_entries[_nrElements].element = p._entries[parentIndex].element;
_nrElements++;
for (int x = nrElements + 1, y = 0; y <= rs.nrElements; x++, y++) {
entries[x] = rs.entries[y];
rs.entries[y].child.parent = this;
nrElements++;
for (int x = _nrElements + 1, y = 0; y <= rs._nrElements; x++, y++) {
_entries[x] = rs._entries[y];
rs._entries[y].child._parent = this;
_nrElements++;
}
nrElements--;
_nrElements--;
p.entries[++parentIndex].child = this;
p._entries[++parentIndex].child = this;
if (p.nrElements == MIN && p != BTreeSet.this.root) {
if (p._nrElements == MIN && p != BTreeSet.this.root) {
for (int x = parentIndex - 1, y = parentIndex - 2; y >= 0; x--, y--)
p.entries[x] = p.entries[y];
p.entries[0] = new Entry();
p._entries[x] = p._entries[y];
p._entries[0] = new Entry();
}
else {
for (int x = parentIndex - 1, y = parentIndex; y <= p.nrElements; x++, y++)
p.entries[x] = p.entries[y];
p.entries[p.nrElements] = null;
for (int x = parentIndex - 1, y = parentIndex; y <= p._nrElements; x++, y++)
p._entries[x] = p._entries[y];
p._entries[p._nrElements] = null;
}
p.nrElements--;
p._nrElements--;
if (p.isRoot() && p.nrElements == 0) { // It's the root and it's empty
if (p.isRoot() && p._nrElements == 0) { // It's the root and it's empty
BTreeSet.this.root = this;
parent = null;
_parent = null;
}
}
}

View File

@ -52,14 +52,6 @@ public final class HeaderFooter
}
public boolean isEmpty()
{
if(_start - _end == 0)
{
return true;
}
else
{
return false;
return _start - _end == 0;
}
}
}

View File

@ -1466,13 +1466,6 @@ public final class StyleSheet implements HDFType {
*/
public static boolean getFlag(int x)
{
if(x != 0)
{
return true;
}
else
{
return false;
}
return x != 0;
}
}

View File

@ -45,7 +45,7 @@ public final class BTreeSet extends AbstractSet
public BTreeNode root;
private Comparator comparator = null;
private int order;
private int size = 0;
int size = 0;
/*
* Constructors
@ -172,7 +172,7 @@ public final class BTreeSet extends AbstractSet
/*
* Private methods
*/
private int compare(Object x, Object y)
int compare(Object x, Object y)
{
return (comparator == null ? ((Comparable)x).compareTo(y) : comparator.compare(x, y));
}
@ -270,8 +270,7 @@ public final class BTreeSet extends AbstractSet
}
}
else
{ //Your not a leaf so simply find and return the successor of lastReturned
// else - You're not a leaf so simply find and return the successor of lastReturned
currentNode = currentNode.entries[index].child;
parentIndex.push(new Integer(index));
@ -285,7 +284,6 @@ public final class BTreeSet extends AbstractSet
return currentNode.entries[0].element;
}
}
}
public static class Entry
@ -329,22 +327,24 @@ public final class BTreeSet extends AbstractSet
else
{ // Promote splitNode
parent.insertSplitNode(splitNode, this, rightSibling, parentIndex);
if (BTreeSet.this.compare(x, parent.entries[parentIndex].element) < 0) return insert(x, parentIndex);
else return rightSibling.insert(x, parentIndex + 1);
if (BTreeSet.this.compare(x, parent.entries[parentIndex].element) < 0) {
return insert(x, parentIndex);
}
return rightSibling.insert(x, parentIndex + 1);
}
}
else if (isLeaf())
{ // If leaf, simply insert the non-duplicate element
int insertAt = childToInsertAt(x, true);
if (insertAt == -1) return false; // Determine if the element already exists
else
{
// Determine if the element already exists
if (insertAt == -1) {
return false;
}
insertNewElement(x, insertAt);
BTreeSet.this.size++;
return true;
}
}
else
{ // If not full and not leaf recursively find correct node to insert at
@ -388,22 +388,19 @@ public final class BTreeSet extends AbstractSet
return true;
}
else
{ // If leaf and have less than MIN elements, than prepare the BTreeSet for deletion
// else - If leaf and have less than MIN elements, than prepare the BTreeSet for deletion
temp.prepareForDeletion(parentIndex);
temp.deleteElement(x);
BTreeSet.this.size--;
temp.fixAfterDeletion(priorParentIndex);
return true;
}
}
else
{ // Only delete at leaf so first switch with successor than delete
// else - Only delete at leaf so first switch with successor than delete
temp.switchWithSuccessor(x);
parentIndex = temp.childToInsertAt(x, false) + 1;
return temp.entries[parentIndex].child.delete(x, parentIndex);
}
}

View File

@ -311,7 +311,7 @@ private void output8Codes(OutputStream res) throws IOException {
/**
* Does the compression
*/
private void compress(InputStream src, OutputStream res) throws IOException {
public void compress(InputStream src, OutputStream res) throws IOException {
// Have we hit the end of the file yet?
boolean going = true;
@ -375,11 +375,10 @@ private void compress(InputStream src, OutputStream res) throws IOException {
if(findRawCodeInBuffer() > -1) {
// Fits in, wait for next byte
continue;
} else {
}
// Doesn't fit, output
outputUncompressed(dataB,res);
rawCodeLen = 0;
}
} else {
// Nothing in rawCode before, so this byte
// isn't in the buffer dictionary

View File

@ -112,10 +112,9 @@ public class AutoShape extends TextShape {
if(outline == null){
logger.log(POILogger.WARN, "Outline not found for " + ShapeTypes.typeName(getShapeType()));
return anchor;
} else {
}
java.awt.Shape shape = outline.getOutline(this);
return AutoShapes.transform(shape, anchor);
}
}
}

View File

@ -43,15 +43,15 @@ public final class PPGraphics2D extends Graphics2D implements Cloneable {
protected POILogger log = POILogFactory.getLogger(this.getClass());
//The ppt object to write into.
private ShapeGroup group;
private ShapeGroup _group;
private AffineTransform transform;
private Stroke stroke;
private Paint paint;
private Font font;
private Color foreground;
private Color background;
private RenderingHints hints;
private AffineTransform _transform;
private Stroke _stroke;
private Paint _paint;
private Font _font;
private Color _foreground;
private Color _background;
private RenderingHints _hints;
/**
* Construct Java Graphics object which translates graphic calls in ppt drawing layer.
@ -59,22 +59,22 @@ public final class PPGraphics2D extends Graphics2D implements Cloneable {
* @param group The shape group to write the graphics calls into.
*/
public PPGraphics2D(ShapeGroup group){
this.group = group;
this._group = group;
transform = new AffineTransform();
stroke = new BasicStroke();
paint = Color.black;
font = new Font("Arial", Font.PLAIN, 12);
background = Color.black;
foreground = Color.white;
hints = new RenderingHints(null);
_transform = new AffineTransform();
_stroke = new BasicStroke();
_paint = Color.black;
_font = new Font("Arial", Font.PLAIN, 12);
_background = Color.black;
_foreground = Color.white;
_hints = new RenderingHints(null);
}
/**
* @return the shape group being used for drawing
*/
public ShapeGroup getShapeGroup(){
return group;
return _group;
}
/**
@ -84,7 +84,7 @@ public final class PPGraphics2D extends Graphics2D implements Cloneable {
* @see java.awt.Graphics#setFont(Font)
*/
public Font getFont(){
return font;
return _font;
}
/**
@ -98,7 +98,7 @@ public final class PPGraphics2D extends Graphics2D implements Cloneable {
* @see java.awt.Graphics#drawChars(char[], int, int, int, int)
*/
public void setFont(Font font){
this.font = font;
this._font = font;
}
/**
@ -108,7 +108,7 @@ public final class PPGraphics2D extends Graphics2D implements Cloneable {
* @see java.awt.Graphics#setColor
*/
public Color getColor(){
return foreground;
return _foreground;
}
/**
@ -131,7 +131,7 @@ public final class PPGraphics2D extends Graphics2D implements Cloneable {
* @see #setStroke
*/
public Stroke getStroke(){
return stroke;
return _stroke;
}
/**
@ -140,7 +140,7 @@ public final class PPGraphics2D extends Graphics2D implements Cloneable {
* <code>Shape</code> during the rendering process
*/
public void setStroke(Stroke s){
this.stroke = s;
this._stroke = s;
}
/**
@ -152,7 +152,7 @@ public final class PPGraphics2D extends Graphics2D implements Cloneable {
* @see java.awt.Graphics#setColor
*/
public Paint getPaint(){
return paint;
return _paint;
}
/**
@ -168,8 +168,8 @@ public final class PPGraphics2D extends Graphics2D implements Cloneable {
public void setPaint(Paint paint){
if(paint == null) return;
this.paint = paint;
if (paint instanceof Color) foreground = (Color)paint;
this._paint = paint;
if (paint instanceof Color) _foreground = (Color)paint;
}
/**
@ -177,11 +177,11 @@ public final class PPGraphics2D extends Graphics2D implements Cloneable {
* <code>Graphics2D</code> context.
* @return the current <code>AffineTransform</code> in the
* <code>Graphics2D</code> context.
* @see #transform
* @see #_transform
* @see #setTransform
*/
public AffineTransform getTransform(){
return new AffineTransform(transform);
return new AffineTransform(_transform);
}
/**
@ -189,11 +189,11 @@ public final class PPGraphics2D extends Graphics2D implements Cloneable {
* context.
* @param Tx the <code>AffineTransform</code> object to be used in the
* rendering process
* @see #transform
* @see #_transform
* @see AffineTransform
*/
public void setTransform(AffineTransform Tx) {
transform = new AffineTransform(Tx);
_transform = new AffineTransform(Tx);
}
/**
@ -206,19 +206,19 @@ public final class PPGraphics2D extends Graphics2D implements Cloneable {
* @see #setStroke
* @see #setPaint
* @see java.awt.Graphics#setColor
* @see #transform
* @see #_transform
* @see #setTransform
* @see #clip
* @see #setClip
* @see #setComposite
*/
public void draw(Shape shape){
GeneralPath path = new GeneralPath(transform.createTransformedShape(shape));
Freeform p = new Freeform(group);
GeneralPath path = new GeneralPath(_transform.createTransformedShape(shape));
Freeform p = new Freeform(_group);
p.setPath(path);
p.getFill().setForegroundColor(null);
applyStroke(p);
group.addShape(p);
_group.addShape(p);
}
/**
@ -247,18 +247,18 @@ public final class PPGraphics2D extends Graphics2D implements Cloneable {
* @see #setClip
*/
public void drawString(String s, float x, float y) {
TextBox txt = new TextBox(group);
txt.getTextRun().supplySlideShow(group.getSheet().getSlideShow());
txt.getTextRun().setSheet(group.getSheet());
TextBox txt = new TextBox(_group);
txt.getTextRun().supplySlideShow(_group.getSheet().getSlideShow());
txt.getTextRun().setSheet(_group.getSheet());
txt.setText(s);
RichTextRun rt = txt.getTextRun().getRichTextRuns()[0];
rt.setFontSize(font.getSize());
rt.setFontName(font.getFamily());
rt.setFontSize(_font.getSize());
rt.setFontName(_font.getFamily());
if (getColor() != null) rt.setFontColor(getColor());
if (font.isBold()) rt.setBold(true);
if (font.isItalic()) rt.setItalic(true);
if (_font.isBold()) rt.setBold(true);
if (_font.isItalic()) rt.setItalic(true);
txt.setMarginBottom(0);
txt.setMarginTop(0);
@ -269,7 +269,7 @@ public final class PPGraphics2D extends Graphics2D implements Cloneable {
txt.setVerticalAlignment(TextBox.AnchorMiddle);
TextLayout layout = new TextLayout(s, font, getFontRenderContext());
TextLayout layout = new TextLayout(s, _font, getFontRenderContext());
float ascent = layout.getAscent();
float width = (float) Math.floor(layout.getAdvance());
@ -295,7 +295,7 @@ public final class PPGraphics2D extends Graphics2D implements Cloneable {
*/
txt.setAnchor(new Rectangle2D.Float(x, y, width, height));
group.addShape(txt);
_group.addShape(txt);
}
/**
@ -306,19 +306,19 @@ public final class PPGraphics2D extends Graphics2D implements Cloneable {
* @param shape the <code>Shape</code> to be filled
* @see #setPaint
* @see java.awt.Graphics#setColor
* @see #transform
* @see #_transform
* @see #setTransform
* @see #setComposite
* @see #clip
* @see #setClip
*/
public void fill(Shape shape){
GeneralPath path = new GeneralPath(transform.createTransformedShape(shape));
Freeform p = new Freeform(group);
GeneralPath path = new GeneralPath(_transform.createTransformedShape(shape));
Freeform p = new Freeform(_group);
p.setPath(path);
applyPaint(p);
p.setLineColor(null); //Fills must be "No Line"
group.addShape(p);
_group.addShape(p);
}
/**
@ -333,7 +333,7 @@ public final class PPGraphics2D extends Graphics2D implements Cloneable {
* @param y the <i>y</i> coordinate.
*/
public void translate(int x, int y){
transform.translate(x, y);
_transform.translate(x, y);
}
/**
@ -400,7 +400,7 @@ public final class PPGraphics2D extends Graphics2D implements Cloneable {
* rendering operations.
*/
public void scale(double sx, double sy){
transform.scale(sx, sy);
_transform.scale(sx, sy);
}
/**
@ -1055,9 +1055,9 @@ public final class PPGraphics2D extends Graphics2D implements Cloneable {
*/
public Rectangle getClipBounds(){
Shape c = getClip();
if(c==null)
if (c==null) {
return null;
else
}
return c.getBounds();
}
@ -1143,7 +1143,7 @@ public final class PPGraphics2D extends Graphics2D implements Cloneable {
* @param theta the angle of rotation in radians
*/
public void rotate(double theta){
transform.rotate(theta);
_transform.rotate(theta);
}
/**
@ -1166,7 +1166,7 @@ public final class PPGraphics2D extends Graphics2D implements Cloneable {
* @param y y coordinate of the origin of the rotation
*/
public void rotate(double theta, double x, double y){
transform.rotate(theta, x, y);
_transform.rotate(theta, x, y);
}
/**
@ -1188,7 +1188,7 @@ public final class PPGraphics2D extends Graphics2D implements Cloneable {
* the positive Y axis direction as a function of their X coordinate
*/
public void shear(double shx, double shy){
transform.shear(shx, shy);
_transform.shear(shx, shy);
}
/**
@ -1240,7 +1240,7 @@ public final class PPGraphics2D extends Graphics2D implements Cloneable {
* @see AffineTransform
*/
public void transform(AffineTransform Tx) {
transform.concatenate(Tx);
_transform.concatenate(Tx);
}
/**
@ -1258,7 +1258,7 @@ public final class PPGraphics2D extends Graphics2D implements Cloneable {
* @param op the filter to be applied to the image before rendering
* @param x the x coordinate in user space where the image is rendered
* @param y the y coordinate in user space where the image is rendered
* @see #transform
* @see #_transform
* @see #setTransform
* @see #setComposite
* @see #clip
@ -1292,7 +1292,7 @@ public final class PPGraphics2D extends Graphics2D implements Cloneable {
if(color == null)
return;
background = color;
_background = color;
}
/**
@ -1302,7 +1302,7 @@ public final class PPGraphics2D extends Graphics2D implements Cloneable {
* @see #setBackground
*/
public Color getBackground(){
return background;
return _background;
}
/**
@ -1359,7 +1359,7 @@ public final class PPGraphics2D extends Graphics2D implements Cloneable {
* @see RenderingHints
*/
public Object getRenderingHint(RenderingHints.Key hintKey){
return hints.get(hintKey);
return _hints.get(hintKey);
}
/**
@ -1374,7 +1374,7 @@ public final class PPGraphics2D extends Graphics2D implements Cloneable {
* @see RenderingHints
*/
public void setRenderingHint(RenderingHints.Key hintKey, Object hintValue){
hints.put(hintKey, hintValue);
_hints.put(hintKey, hintValue);
}
@ -1434,7 +1434,7 @@ public final class PPGraphics2D extends Graphics2D implements Cloneable {
* @see RenderingHints
*/
public void addRenderingHints(Map hints){
this.hints.putAll(hints);
this._hints.putAll(hints);
}
/**
@ -1454,7 +1454,7 @@ public final class PPGraphics2D extends Graphics2D implements Cloneable {
* @param ty the distance to translate along the y-axis
*/
public void translate(double tx, double ty){
transform.translate(tx, ty);
_transform.translate(tx, ty);
}
/**
@ -1510,7 +1510,7 @@ public final class PPGraphics2D extends Graphics2D implements Cloneable {
* @see #setStroke
* @see #fill(Shape)
* @see #draw(Shape)
* @see #transform
* @see #_transform
* @see #setTransform
* @see #clip
* @see #setClip(Shape)
@ -1540,7 +1540,7 @@ public final class PPGraphics2D extends Graphics2D implements Cloneable {
* @see RenderingHints
*/
public RenderingHints getRenderingHints(){
return hints;
return _hints;
}
/**
@ -1557,7 +1557,7 @@ public final class PPGraphics2D extends Graphics2D implements Cloneable {
* @see RenderingHints
*/
public void setRenderingHints(Map hints){
this.hints = new RenderingHints(hints);
this._hints = new RenderingHints(hints);
}
/**
@ -1579,7 +1579,7 @@ public final class PPGraphics2D extends Graphics2D implements Cloneable {
* @return <code>true</code> if the <code>Image</code> is
* fully loaded and completely rendered;
* <code>false</code> if the <code>Image</code> is still being loaded.
* @see #transform
* @see #_transform
* @see #setTransform
* @see #setComposite
* @see #clip
@ -1713,7 +1713,7 @@ public final class PPGraphics2D extends Graphics2D implements Cloneable {
* @param img the image to be rendered. This method does
* nothing if <code>img</code> is null.
* @param xform the transformation from image space into user space
* @see #transform
* @see #_transform
* @see #setTransform
* @see #setComposite
* @see #clip
@ -1739,7 +1739,7 @@ public final class PPGraphics2D extends Graphics2D implements Cloneable {
* @param img the image to be rendered. This method does
* nothing if <code>img</code> is null.
* @param xform the transformation from image space into user space
* @see #transform
* @see #_transform
* @see #setTransform
* @see #setComposite
* @see #clip
@ -1750,8 +1750,8 @@ public final class PPGraphics2D extends Graphics2D implements Cloneable {
}
protected void applyStroke(SimpleShape shape) {
if (stroke instanceof BasicStroke){
BasicStroke bs = (BasicStroke)stroke;
if (_stroke instanceof BasicStroke){
BasicStroke bs = (BasicStroke)_stroke;
shape.setLineWidth(bs.getLineWidth());
float[] dash = bs.getDashArray();
if (dash != null) {
@ -1762,8 +1762,8 @@ public final class PPGraphics2D extends Graphics2D implements Cloneable {
}
protected void applyPaint(SimpleShape shape) {
if (paint instanceof Color) {
shape.getFill().setForegroundColor((Color)paint);
if (_paint instanceof Color) {
shape.getFill().setForegroundColor((Color)_paint);
}
}
}

View File

@ -204,9 +204,8 @@ public class Picture extends SimpleShape {
if (idx == 0){
logger.log(POILogger.DEBUG, "picture index was not found, returning ");
return null;
} else {
return (EscherBSERecord)lst.get(idx-1);
}
return (EscherBSERecord)lst.get(idx-1);
}
/**

View File

@ -40,10 +40,8 @@ public final class ShapeFactory {
public static Shape createShape(EscherContainerRecord spContainer, Shape parent){
if (spContainer.getRecordId() == EscherContainerRecord.SPGR_CONTAINER){
return createShapeGroup(spContainer, parent);
} else {
return createSimpeShape(spContainer, parent);
}
return createSimpeShape(spContainer, parent);
}
public static ShapeGroup createShapeGroup(EscherContainerRecord spContainer, Shape parent){

View File

@ -17,16 +17,22 @@
package org.apache.poi.hslf.model;
import java.awt.Graphics2D;
import java.util.Vector;
import java.util.Iterator;
import java.awt.*;
import org.apache.poi.hslf.record.*;
import org.apache.poi.hslf.record.SlideListWithText.SlideAtomsSet;
import org.apache.poi.ddf.EscherDggRecord;
import org.apache.poi.ddf.EscherContainerRecord;
import org.apache.poi.ddf.EscherDgRecord;
import org.apache.poi.ddf.EscherDggRecord;
import org.apache.poi.ddf.EscherSpRecord;
import org.apache.poi.hslf.record.ColorSchemeAtom;
import org.apache.poi.hslf.record.Comment2000;
import org.apache.poi.hslf.record.HeadersFootersContainer;
import org.apache.poi.hslf.record.Record;
import org.apache.poi.hslf.record.RecordContainer;
import org.apache.poi.hslf.record.RecordTypes;
import org.apache.poi.hslf.record.SlideAtom;
import org.apache.poi.hslf.record.TextHeaderAtom;
import org.apache.poi.hslf.record.SlideListWithText.SlideAtomsSet;
/**
* This class represents a slide in a PowerPoint Document. It allows
@ -144,8 +150,7 @@ public final class Slide extends Sheet
dgg.setDrawingsSaved(dgg.getDrawingsSaved() + 1);
dgg.setMaxDrawingGroupId(dgId);
for (Iterator it = dgContainer.getChildContainers().iterator(); it.hasNext(); ) {
EscherContainerRecord c = (EscherContainerRecord)it.next();
for (EscherContainerRecord c : dgContainer.getChildContainers()) {
EscherSpRecord spr = null;
switch(c.getRecordId()){
case EscherContainerRecord.SPGR_CONTAINER:
@ -343,9 +348,9 @@ public final class Slide extends Sheet
* Background for this slide.
*/
public Background getBackground() {
if(getFollowMasterBackground())
if(getFollowMasterBackground()) {
return getMasterSheet().getBackground();
else
}
return super.getBackground();
}
@ -449,14 +454,12 @@ public final class Slide extends Sheet
if(hdd == null && !ppt2007) {
return getSlideShow().getSlideHeadersFooters();
}
else {
if(hdd == null) {
hdd = new HeadersFootersContainer(HeadersFootersContainer.SlideHeadersFootersContainer);
newRecord = true;
}
return new HeadersFooters(hdd, this, newRecord, ppt2007);
}
}
protected void onAddTextShape(TextShape shape) {
TextRun run = shape.getTextRun();

View File

@ -46,7 +46,7 @@ public final class TextRun
protected boolean _isUnicode;
protected RichTextRun[] _rtRuns;
private SlideShow slideShow;
private Sheet sheet;
private Sheet _sheet;
private int shapeId;
private int slwtIndex; //position in the owning SlideListWithText
/**
@ -564,9 +564,8 @@ public final class TextRun
public String getRawText() {
if(_isUnicode) {
return _charAtom.getText();
} else {
return _byteAtom.getText();
}
return _byteAtom.getText();
}
/**
@ -610,11 +609,11 @@ public final class TextRun
}
public void setSheet(Sheet sheet){
this.sheet = sheet;
this._sheet = sheet;
}
public Sheet getSheet(){
return this.sheet;
return this._sheet;
}
/**

View File

@ -171,7 +171,7 @@ public final class TxMasterStyleAtom extends RecordAtom {
protected TextProp[] getParagraphProps(int type, int level){
if (level != 0 || type >= MAX_INDENT){
return StyleTextPropAtom.paragraphTextPropTypes;
} else {
}
return new TextProp[] {
new ParagraphFlagsTextProp(),
new TextProp(2, 0x80, "bullet.char"),
@ -190,7 +190,7 @@ public final class TxMasterStyleAtom extends RecordAtom {
new TextProp(2, 0x100000, "para_unknown_4"),
new TextProp(2, 0x200000, "para_unknown_5")
};
}
}
/**
@ -202,7 +202,7 @@ public final class TxMasterStyleAtom extends RecordAtom {
protected TextProp[] getCharacterProps(int type, int level){
if (level != 0 || type >= MAX_INDENT){
return StyleTextPropAtom.characterTextPropTypes;
} else
}
return new TextProp[] {
new CharFlagsTextProp(),
new TextProp(2, 0x10000, "font.index"),

View File

@ -500,12 +500,11 @@ public final class RichTextRun {
public String getFontName() {
if (slideShow == null) {
return _fontname;
} else {
}
int fontIdx = getCharTextPropVal("font.index");
if(fontIdx == -1) { return null; }
return slideShow.getFontCollection().getFontWithId(fontIdx);
}
}
/**
* @return font color as RGB value

View File

@ -262,13 +262,12 @@ public final class SlideShow {
if (coreRecordId != null) {
Record r = _mostRecentCoreRecords[coreRecordId.intValue()];
return r;
} else {
}
logger.log(POILogger.ERROR,
"We tried to look up a reference to a core record, but there was no core ID for reference ID "
+ refID);
return null;
}
}
/**
* Build up model level Slide and Notes objects, from the underlying
@ -989,9 +988,8 @@ public final class SlideShow {
}
if (ppt2007 && _notes.length > 0) {
return new HeadersFooters(hdd, _notes[0], newRecord, ppt2007);
} else {
return new HeadersFooters(hdd, this, newRecord, ppt2007);
}
return new HeadersFooters(hdd, this, newRecord, ppt2007);
}
/**

View File

@ -49,13 +49,10 @@ public final class ComplexFileTable
{
throw new IOException("The text piece table is corrupted");
}
else
{
int pieceTableSize = LittleEndian.getInt(tableStream, ++offset);
offset += LittleEndian.INT_SIZE;
_tpt = new TextPieceTable(documentStream, tableStream, offset, pieceTableSize, fcMin);
}
}
public TextPieceTable getTextPieceTable()
{

View File

@ -194,11 +194,10 @@ public final class ListTables
if(level < lst.numLevels()) {
ListLevel lvl = lst.getLevels()[level];
return lvl;
} else {
}
log.log(POILogger.WARN, "Requested level " + level + " which was greater than the maximum defined (" + lst.numLevels() + ")");
return null;
}
}
public ListData getListData(int listID)
{

View File

@ -226,13 +226,12 @@ public final class PAPFormattedDiskPage extends FormattedDiskPage {
throw new UnsupportedOperationException(
"This Paragraph has no dataStream storage.");
}
else // we have some storage...
{
// get the size of the existing storage
int maxHugeGrpprlSize = LittleEndian.getUShort(_dataStream,
hugeGrpprlOffset);
// we have some storage...
if (maxHugeGrpprlSize < grpprl.length-2) // grpprl.length-2 because we don't store the istd
// get the size of the existing storage
int maxHugeGrpprlSize = LittleEndian.getUShort(_dataStream, hugeGrpprlOffset);
if (maxHugeGrpprlSize < grpprl.length-2) { // grpprl.length-2 because we don't store the istd
throw new UnsupportedOperationException(
"This Paragraph's dataStream storage is too small.");
}

View File

@ -112,11 +112,8 @@ public final class PAPX extends BytePropertyNode {
{
return 0;
}
else
{
return LittleEndian.getShort(buf);
}
}
public SprmBuffer getSprmBuf()
{

View File

@ -67,7 +67,7 @@ public final class SprmBuffer
_buf[grpprlOffset] = operand;
return;
}
else addSprm(opcode, operand);
addSprm(opcode, operand);
}
public void updateSprm(short opcode, short operand)
@ -78,7 +78,7 @@ public final class SprmBuffer
LittleEndian.putShort(_buf, grpprlOffset, operand);
return;
}
else addSprm(opcode, operand);
addSprm(opcode, operand);
}
public void updateSprm(short opcode, int operand)
@ -89,7 +89,7 @@ public final class SprmBuffer
LittleEndian.putInt(_buf, grpprlOffset, operand);
return;
}
else addSprm(opcode, operand);
addSprm(opcode, operand);
}
public void addSprm(short opcode, byte operand)

View File

@ -152,10 +152,7 @@ public final class SprmOperation
_gOffset += 2;
return retVal;
}
else
{
return (0x000000ff & _grpprl[_gOffset++]) + 3;
}
case 7:
return 5;
default:

View File

@ -93,11 +93,8 @@ public class SanityChecker
{
return matchRequired( firstRecord, records, recordIdx );
}
else
{
return matchOptional( firstRecord, records, recordIdx );
}
}
private int matchOptional( int firstRecord, List records, int recordIdx )
{