Eclipse warnings, code formatting, missing @Overrides, Javadoc, missing close(), ...
git-svn-id: https://svn.apache.org/repos/asf/poi/trunk@1696794 13f79535-47bb-0310-9956-ffa450edef68
This commit is contained in:
parent
8e738cac68
commit
39163eccff
@ -389,6 +389,7 @@ public final class HSSFWorkbook extends POIDocument implements org.apache.poi.ss
|
||||
* @see #HSSFWorkbook(POIFSFileSystem)
|
||||
* @exception IOException if the stream cannot be read
|
||||
*/
|
||||
@SuppressWarnings("resource") // NPOIFSFileSystem always closes the stream
|
||||
public HSSFWorkbook(InputStream s, boolean preserveNodes)
|
||||
throws IOException
|
||||
{
|
||||
@ -457,6 +458,7 @@ public final class HSSFWorkbook extends POIDocument implements org.apache.poi.ss
|
||||
* The default is to return blank and null cells.
|
||||
* {@link MissingCellPolicy}
|
||||
*/
|
||||
@Override
|
||||
public MissingCellPolicy getMissingCellPolicy() {
|
||||
return missingCellPolicy;
|
||||
}
|
||||
@ -471,6 +473,7 @@ public final class HSSFWorkbook extends POIDocument implements org.apache.poi.ss
|
||||
* iterators, only on when fetching Cells
|
||||
* by their column index.
|
||||
*/
|
||||
@Override
|
||||
public void setMissingCellPolicy(MissingCellPolicy missingCellPolicy) {
|
||||
this.missingCellPolicy = missingCellPolicy;
|
||||
}
|
||||
@ -482,6 +485,7 @@ public final class HSSFWorkbook extends POIDocument implements org.apache.poi.ss
|
||||
* @param pos the position that we want to insert the sheet into (0 based)
|
||||
*/
|
||||
|
||||
@Override
|
||||
public void setSheetOrder(String sheetname, int pos ) {
|
||||
int oldSheetIndex = getSheetIndex(sheetname);
|
||||
_sheets.add(pos,_sheets.remove(oldSheetIndex));
|
||||
@ -527,6 +531,7 @@ public final class HSSFWorkbook extends POIDocument implements org.apache.poi.ss
|
||||
* Selects a single sheet. This may be different to
|
||||
* the 'active' sheet (which is the sheet with focus).
|
||||
*/
|
||||
@Override
|
||||
public void setSelectedTab(int index) {
|
||||
|
||||
validateSheetIndex(index);
|
||||
@ -568,6 +573,7 @@ public final class HSSFWorkbook extends POIDocument implements org.apache.poi.ss
|
||||
* which is currently displayed when the workbook is viewed in Excel.
|
||||
* 'Selected' sheet(s) is a distinct concept.
|
||||
*/
|
||||
@Override
|
||||
public void setActiveSheet(int index) {
|
||||
|
||||
validateSheetIndex(index);
|
||||
@ -585,6 +591,7 @@ public final class HSSFWorkbook extends POIDocument implements org.apache.poi.ss
|
||||
* in the tabs (at the bottom).
|
||||
* @see org.apache.poi.hssf.usermodel.HSSFSheet#setSelected(boolean)
|
||||
*/
|
||||
@Override
|
||||
public int getActiveSheetIndex() {
|
||||
return workbook.getWindowOne().getActiveSheetIndex();
|
||||
}
|
||||
@ -603,6 +610,7 @@ public final class HSSFWorkbook extends POIDocument implements org.apache.poi.ss
|
||||
* in excel.
|
||||
* @param index
|
||||
*/
|
||||
@Override
|
||||
public void setFirstVisibleTab(int index) {
|
||||
workbook.getWindowOne().setFirstVisibleTab(index);
|
||||
}
|
||||
@ -618,6 +626,7 @@ public final class HSSFWorkbook extends POIDocument implements org.apache.poi.ss
|
||||
/**
|
||||
* sets the first tab that is displayed in the list of tabs in excel.
|
||||
*/
|
||||
@Override
|
||||
public int getFirstVisibleTab() {
|
||||
return workbook.getWindowOne().getFirstVisibleTab();
|
||||
}
|
||||
@ -639,6 +648,7 @@ public final class HSSFWorkbook extends POIDocument implements org.apache.poi.ss
|
||||
* @see #createSheet(String)
|
||||
* @see org.apache.poi.ss.util.WorkbookUtil#createSafeSheetName(String nameProposal)
|
||||
*/
|
||||
@Override
|
||||
public void setSheetName(int sheetIx, String name) {
|
||||
if (name == null) {
|
||||
throw new IllegalArgumentException("sheetName must not be null");
|
||||
@ -654,35 +664,42 @@ public final class HSSFWorkbook extends POIDocument implements org.apache.poi.ss
|
||||
/**
|
||||
* @return Sheet name for the specified index
|
||||
*/
|
||||
@Override
|
||||
public String getSheetName(int sheetIndex) {
|
||||
validateSheetIndex(sheetIndex);
|
||||
return workbook.getSheetName(sheetIndex);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isHidden() {
|
||||
return workbook.getWindowOne().getHidden();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setHidden(boolean hiddenFlag) {
|
||||
workbook.getWindowOne().setHidden(hiddenFlag);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isSheetHidden(int sheetIx) {
|
||||
validateSheetIndex(sheetIx);
|
||||
return workbook.isSheetHidden(sheetIx);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isSheetVeryHidden(int sheetIx) {
|
||||
validateSheetIndex(sheetIx);
|
||||
return workbook.isSheetVeryHidden(sheetIx);
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public void setSheetHidden(int sheetIx, boolean hidden) {
|
||||
validateSheetIndex(sheetIx);
|
||||
workbook.setSheetHidden(sheetIx, hidden);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setSheetHidden(int sheetIx, int hidden) {
|
||||
validateSheetIndex(sheetIx);
|
||||
WorkbookUtil.validateSheetState(hidden);
|
||||
@ -693,6 +710,7 @@ public final class HSSFWorkbook extends POIDocument implements org.apache.poi.ss
|
||||
* @param name the sheet name
|
||||
* @return index of the sheet (0 based)
|
||||
*/
|
||||
@Override
|
||||
public int getSheetIndex(String name){
|
||||
return workbook.getSheetIndex(name);
|
||||
}
|
||||
@ -701,6 +719,7 @@ public final class HSSFWorkbook extends POIDocument implements org.apache.poi.ss
|
||||
* @param sheet the sheet to look up
|
||||
* @return index of the sheet (0 based). <tt>-1</tt> if not found
|
||||
*/
|
||||
@Override
|
||||
public int getSheetIndex(org.apache.poi.ss.usermodel.Sheet sheet) {
|
||||
for(int i=0; i<_sheets.size(); i++) {
|
||||
if(_sheets.get(i) == sheet) {
|
||||
@ -753,6 +772,7 @@ public final class HSSFWorkbook extends POIDocument implements org.apache.poi.ss
|
||||
* @return HSSFSheet representing the new sheet.
|
||||
*/
|
||||
|
||||
@Override
|
||||
public HSSFSheet createSheet()
|
||||
{
|
||||
HSSFSheet sheet = new HSSFSheet(this);
|
||||
@ -771,6 +791,7 @@ public final class HSSFWorkbook extends POIDocument implements org.apache.poi.ss
|
||||
* @return HSSFSheet representing the cloned sheet.
|
||||
*/
|
||||
|
||||
@Override
|
||||
public HSSFSheet cloneSheet(int sheetIndex) {
|
||||
validateSheetIndex(sheetIndex);
|
||||
HSSFSheet srcSheet = _sheets.get(sheetIndex);
|
||||
@ -871,6 +892,7 @@ public final class HSSFWorkbook extends POIDocument implements org.apache.poi.ss
|
||||
* or workbook already contains a sheet with this name
|
||||
* @see org.apache.poi.ss.util.WorkbookUtil#createSafeSheetName(String nameProposal)
|
||||
*/
|
||||
@Override
|
||||
public HSSFSheet createSheet(String sheetname)
|
||||
{
|
||||
if (sheetname == null) {
|
||||
@ -895,6 +917,7 @@ public final class HSSFWorkbook extends POIDocument implements org.apache.poi.ss
|
||||
* @return number of sheets
|
||||
*/
|
||||
|
||||
@Override
|
||||
public int getNumberOfSheets()
|
||||
{
|
||||
return _sheets.size();
|
||||
@ -922,6 +945,7 @@ public final class HSSFWorkbook extends POIDocument implements org.apache.poi.ss
|
||||
* @return HSSFSheet at the provided index
|
||||
*/
|
||||
|
||||
@Override
|
||||
public HSSFSheet getSheetAt(int index)
|
||||
{
|
||||
validateSheetIndex(index);
|
||||
@ -934,6 +958,7 @@ public final class HSSFWorkbook extends POIDocument implements org.apache.poi.ss
|
||||
* @return HSSFSheet with the name provided or <code>null</code> if it does not exist
|
||||
*/
|
||||
|
||||
@Override
|
||||
public HSSFSheet getSheet(String name)
|
||||
{
|
||||
HSSFSheet retval = null;
|
||||
@ -964,6 +989,7 @@ public final class HSSFWorkbook extends POIDocument implements org.apache.poi.ss
|
||||
*
|
||||
* @param index of the sheet (0-based)
|
||||
*/
|
||||
@Override
|
||||
public void removeSheetAt(int index) {
|
||||
validateSheetIndex(index);
|
||||
boolean wasSelected = getSheetAt(index).isSelected();
|
||||
@ -1064,6 +1090,7 @@ public final class HSSFWorkbook extends POIDocument implements org.apache.poi.ss
|
||||
* @deprecated use {@link HSSFSheet#setRepeatingRows(CellRangeAddress)}
|
||||
* or {@link HSSFSheet#setRepeatingColumns(CellRangeAddress)}
|
||||
*/
|
||||
@Override
|
||||
@Deprecated
|
||||
public void setRepeatingRowsAndColumns(int sheetIndex,
|
||||
int startColumn, int endColumn,
|
||||
@ -1126,6 +1153,7 @@ public final class HSSFWorkbook extends POIDocument implements org.apache.poi.ss
|
||||
* @return new font object
|
||||
*/
|
||||
|
||||
@Override
|
||||
public HSSFFont createFont()
|
||||
{
|
||||
/*FontRecord font =*/ workbook.createNewFont();
|
||||
@ -1147,6 +1175,7 @@ public final class HSSFWorkbook extends POIDocument implements org.apache.poi.ss
|
||||
/**
|
||||
* Finds a font that matches the one with the supplied attributes
|
||||
*/
|
||||
@Override
|
||||
public HSSFFont findFont(short boldWeight, short color, short fontHeight,
|
||||
String name, boolean italic, boolean strikeout,
|
||||
short typeOffset, byte underline)
|
||||
@ -1177,6 +1206,7 @@ public final class HSSFWorkbook extends POIDocument implements org.apache.poi.ss
|
||||
* @return number of fonts
|
||||
*/
|
||||
|
||||
@Override
|
||||
public short getNumberOfFonts()
|
||||
{
|
||||
return (short) workbook.getNumberOfFontRecords();
|
||||
@ -1187,6 +1217,7 @@ public final class HSSFWorkbook extends POIDocument implements org.apache.poi.ss
|
||||
* @param idx index number
|
||||
* @return HSSFFont at the index
|
||||
*/
|
||||
@Override
|
||||
public HSSFFont getFontAt(short idx) {
|
||||
if(fonts == null) fonts = new Hashtable<Short, HSSFFont>();
|
||||
|
||||
@ -1220,9 +1251,9 @@ public final class HSSFWorkbook extends POIDocument implements org.apache.poi.ss
|
||||
* You can define up to 4000 unique styles in a .xls workbook.
|
||||
*
|
||||
* @return the new Cell Style object
|
||||
* @throws IllegalStateException if the maximum number of cell styles exceeded the limit
|
||||
* @throws IllegalStateException if the number of cell styles exceeded the limit for this type of Workbook.
|
||||
*/
|
||||
|
||||
@Override
|
||||
public HSSFCellStyle createCellStyle()
|
||||
{
|
||||
if(workbook.getNumExFormats() == MAX_STYLES) {
|
||||
@ -1241,6 +1272,7 @@ public final class HSSFWorkbook extends POIDocument implements org.apache.poi.ss
|
||||
* @return count of cell styles
|
||||
*/
|
||||
|
||||
@Override
|
||||
public short getNumCellStyles()
|
||||
{
|
||||
return (short) workbook.getNumExFormats();
|
||||
@ -1251,6 +1283,7 @@ public final class HSSFWorkbook extends POIDocument implements org.apache.poi.ss
|
||||
* @param idx index within the set of styles
|
||||
* @return HSSFCellStyle object at the index
|
||||
*/
|
||||
@Override
|
||||
public HSSFCellStyle getCellStyleAt(short idx)
|
||||
{
|
||||
ExtendedFormatRecord xfr = workbook.getExFormatAt(idx);
|
||||
@ -1336,6 +1369,7 @@ public final class HSSFWorkbook extends POIDocument implements org.apache.poi.ss
|
||||
public int getTotalSize() {
|
||||
return _totalSize;
|
||||
}
|
||||
@Override
|
||||
public void visitRecord(Record r) {
|
||||
_list.add(r);
|
||||
_totalSize+=r.getRecordSize();
|
||||
@ -1432,11 +1466,13 @@ public final class HSSFWorkbook extends POIDocument implements org.apache.poi.ss
|
||||
return workbook;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getNumberOfNames(){
|
||||
int result = names.size();
|
||||
return result;
|
||||
}
|
||||
|
||||
@Override
|
||||
public HSSFName getName(String name) {
|
||||
int nameIndex = getNameIndex(name);
|
||||
if (nameIndex < 0) {
|
||||
@ -1445,6 +1481,7 @@ public final class HSSFWorkbook extends POIDocument implements org.apache.poi.ss
|
||||
return names.get(nameIndex);
|
||||
}
|
||||
|
||||
@Override
|
||||
public HSSFName getNameAt(int nameIndex) {
|
||||
int nNames = names.size();
|
||||
if (nNames < 1) {
|
||||
@ -1478,6 +1515,7 @@ public final class HSSFWorkbook extends POIDocument implements org.apache.poi.ss
|
||||
* @param sheetIndex Zero-based sheet index (0 Represents the first sheet to keep consistent with java)
|
||||
* @param reference Valid name Reference for the Print Area
|
||||
*/
|
||||
@Override
|
||||
public void setPrintArea(int sheetIndex, String reference)
|
||||
{
|
||||
NameRecord name = workbook.getSpecificBuiltinRecord(NameRecord.BUILTIN_PRINT_AREA, sheetIndex+1);
|
||||
@ -1509,6 +1547,7 @@ public final class HSSFWorkbook extends POIDocument implements org.apache.poi.ss
|
||||
* @param startRow Row to begin the printarea
|
||||
* @param endRow Row to end the printarea
|
||||
*/
|
||||
@Override
|
||||
public void setPrintArea(int sheetIndex, int startColumn, int endColumn,
|
||||
int startRow, int endRow) {
|
||||
|
||||
@ -1528,6 +1567,7 @@ public final class HSSFWorkbook extends POIDocument implements org.apache.poi.ss
|
||||
* @param sheetIndex Zero-based sheet index (0 Represents the first sheet to keep consistent with java)
|
||||
* @return String Null if no print area has been defined
|
||||
*/
|
||||
@Override
|
||||
public String getPrintArea(int sheetIndex) {
|
||||
NameRecord name = workbook.getSpecificBuiltinRecord(NameRecord.BUILTIN_PRINT_AREA, sheetIndex+1);
|
||||
//adding one here because 0 indicates a global named region; doesn't make sense for print areas
|
||||
@ -1542,6 +1582,7 @@ public final class HSSFWorkbook extends POIDocument implements org.apache.poi.ss
|
||||
* Delete the printarea for the sheet specified
|
||||
* @param sheetIndex Zero-based sheet index (0 = First Sheet)
|
||||
*/
|
||||
@Override
|
||||
public void removePrintArea(int sheetIndex) {
|
||||
getWorkbook().removeBuiltinRecord(NameRecord.BUILTIN_PRINT_AREA, sheetIndex+1);
|
||||
}
|
||||
@ -1549,6 +1590,7 @@ public final class HSSFWorkbook extends POIDocument implements org.apache.poi.ss
|
||||
/** creates a new named range and add it to the model
|
||||
* @return named range high level
|
||||
*/
|
||||
@Override
|
||||
public HSSFName createName(){
|
||||
NameRecord nameRecord = workbook.createName();
|
||||
|
||||
@ -1559,6 +1601,7 @@ public final class HSSFWorkbook extends POIDocument implements org.apache.poi.ss
|
||||
return newName;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getNameIndex(String name) {
|
||||
|
||||
for (int k = 0; k < names.size(); k++) {
|
||||
@ -1591,6 +1634,7 @@ public final class HSSFWorkbook extends POIDocument implements org.apache.poi.ss
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public void removeName(int index){
|
||||
names.remove(index);
|
||||
workbook.removeName(index);
|
||||
@ -1602,6 +1646,7 @@ public final class HSSFWorkbook extends POIDocument implements org.apache.poi.ss
|
||||
* @see org.apache.poi.hssf.record.FormatRecord
|
||||
* @see org.apache.poi.hssf.record.Record
|
||||
*/
|
||||
@Override
|
||||
public HSSFDataFormat createDataFormat() {
|
||||
if (formatter == null)
|
||||
formatter = new HSSFDataFormat(workbook);
|
||||
@ -1609,6 +1654,7 @@ public final class HSSFWorkbook extends POIDocument implements org.apache.poi.ss
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public void removeName(String name) {
|
||||
int index = getNameIndex(name);
|
||||
removeName(index);
|
||||
@ -1698,6 +1744,7 @@ public final class HSSFWorkbook extends POIDocument implements org.apache.poi.ss
|
||||
*
|
||||
* @return the index to this picture (1 based).
|
||||
*/
|
||||
@Override
|
||||
public int addPicture(byte[] pictureData, int format)
|
||||
{
|
||||
initDrawings();
|
||||
@ -1780,6 +1827,7 @@ public final class HSSFWorkbook extends POIDocument implements org.apache.poi.ss
|
||||
*
|
||||
* @return the list of pictures (a list of {@link HSSFPictureData} objects.)
|
||||
*/
|
||||
@Override
|
||||
public List<HSSFPictureData> getAllPictures()
|
||||
{
|
||||
// The drawing group record always exists at the top level, so we won't need to do this recursively.
|
||||
@ -1895,6 +1943,7 @@ public final class HSSFWorkbook extends POIDocument implements org.apache.poi.ss
|
||||
* @param name The name the workbook will be referenced as in formulas
|
||||
* @param workbook The open workbook to fetch the link required information from
|
||||
*/
|
||||
@Override
|
||||
public int linkExternalWorkbook(String name, Workbook workbook) {
|
||||
return this.workbook.linkExternalWorkbook(name, workbook);
|
||||
}
|
||||
@ -1967,6 +2016,7 @@ public final class HSSFWorkbook extends POIDocument implements org.apache.poi.ss
|
||||
}
|
||||
}
|
||||
}
|
||||
@Override
|
||||
public HSSFCreationHelper getCreationHelper() {
|
||||
return new HSSFCreationHelper(this);
|
||||
}
|
||||
@ -1987,6 +2037,7 @@ public final class HSSFWorkbook extends POIDocument implements org.apache.poi.ss
|
||||
*
|
||||
* @param toopack the toolpack to register
|
||||
*/
|
||||
@Override
|
||||
public void addToolPack(UDFFinder toopack){
|
||||
AggregatingUDFFinder udfs = (AggregatingUDFFinder)_udfFinder;
|
||||
udfs.add(toopack);
|
||||
@ -2009,6 +2060,7 @@ public final class HSSFWorkbook extends POIDocument implements org.apache.poi.ss
|
||||
* workbook values when the workbook is opened
|
||||
* @since 3.8
|
||||
*/
|
||||
@Override
|
||||
public void setForceFormulaRecalculation(boolean value){
|
||||
InternalWorkbook iwb = getWorkbook();
|
||||
RecalcIdRecord recalc = iwb.getRecalcId();
|
||||
@ -2020,6 +2072,7 @@ public final class HSSFWorkbook extends POIDocument implements org.apache.poi.ss
|
||||
*
|
||||
* @since 3.8
|
||||
*/
|
||||
@Override
|
||||
public boolean getForceFormulaRecalculation(){
|
||||
InternalWorkbook iwb = getWorkbook();
|
||||
RecalcIdRecord recalc = (RecalcIdRecord)iwb.findFirstRecordBySid(RecalcIdRecord.sid);
|
||||
|
@ -290,6 +290,7 @@ public interface Workbook extends Closeable {
|
||||
* @deprecated use {@link Sheet#setRepeatingRows(CellRangeAddress)}
|
||||
* or {@link Sheet#setRepeatingColumns(CellRangeAddress)}
|
||||
*/
|
||||
@Deprecated
|
||||
void setRepeatingRowsAndColumns(int sheetIndex, int startColumn, int endColumn, int startRow, int endRow);
|
||||
|
||||
/**
|
||||
@ -325,6 +326,7 @@ public interface Workbook extends Closeable {
|
||||
* Create a new Cell style and add it to the workbook's style table
|
||||
*
|
||||
* @return the new Cell Style object
|
||||
* @throws IllegalStateException if the number of cell styles exceeded the limit for this type of Workbook.
|
||||
*/
|
||||
CellStyle createCellStyle();
|
||||
|
||||
@ -357,6 +359,7 @@ public interface Workbook extends Closeable {
|
||||
* Workbook should no longer be used.
|
||||
* <p>This will have no effect newly created Workbooks.
|
||||
*/
|
||||
@Override
|
||||
void close() throws IOException;
|
||||
|
||||
/**
|
||||
|
@ -131,6 +131,7 @@ public class XSSFCellStyle implements CellStyle {
|
||||
* XSSFWorkbook if you like. This allows you to
|
||||
* copy styles from one XSSFWorkbook to another.
|
||||
*/
|
||||
@Override
|
||||
public void cloneStyleFrom(CellStyle source) {
|
||||
if(source instanceof XSSFCellStyle) {
|
||||
XSSFCellStyle src = (XSSFCellStyle)source;
|
||||
@ -213,6 +214,7 @@ public class XSSFCellStyle implements CellStyle {
|
||||
* @see org.apache.poi.ss.usermodel.CellStyle#ALIGN_JUSTIFY
|
||||
* @see org.apache.poi.ss.usermodel.CellStyle#ALIGN_CENTER_SELECTION
|
||||
*/
|
||||
@Override
|
||||
public short getAlignment() {
|
||||
return (short)(getAlignmentEnum().ordinal());
|
||||
}
|
||||
@ -250,6 +252,7 @@ public class XSSFCellStyle implements CellStyle {
|
||||
* @see org.apache.poi.ss.usermodel.CellStyle#BORDER_MEDIUM_DASH_DOT_DOT
|
||||
* @see org.apache.poi.ss.usermodel.CellStyle#BORDER_SLANTED_DASH_DOT
|
||||
*/
|
||||
@Override
|
||||
public short getBorderBottom() {
|
||||
if(!_cellXf.getApplyBorder()) return BORDER_NONE;
|
||||
|
||||
@ -289,6 +292,7 @@ public class XSSFCellStyle implements CellStyle {
|
||||
* @see org.apache.poi.ss.usermodel.CellStyle#BORDER_MEDIUM_DASH_DOT_DOT
|
||||
* @see org.apache.poi.ss.usermodel.CellStyle#BORDER_SLANTED_DASH_DOT
|
||||
*/
|
||||
@Override
|
||||
public short getBorderLeft() {
|
||||
if(!_cellXf.getApplyBorder()) return BORDER_NONE;
|
||||
|
||||
@ -327,6 +331,7 @@ public class XSSFCellStyle implements CellStyle {
|
||||
* @see org.apache.poi.ss.usermodel.CellStyle#BORDER_MEDIUM_DASH_DOT_DOT
|
||||
* @see org.apache.poi.ss.usermodel.CellStyle#BORDER_SLANTED_DASH_DOT
|
||||
*/
|
||||
@Override
|
||||
public short getBorderRight() {
|
||||
if(!_cellXf.getApplyBorder()) return BORDER_NONE;
|
||||
|
||||
@ -365,6 +370,7 @@ public class XSSFCellStyle implements CellStyle {
|
||||
* @see org.apache.poi.ss.usermodel.CellStyle#BORDER_MEDIUM_DASH_DOT_DOT
|
||||
* @see org.apache.poi.ss.usermodel.CellStyle#BORDER_SLANTED_DASH_DOT
|
||||
*/
|
||||
@Override
|
||||
public short getBorderTop() {
|
||||
if(!_cellXf.getApplyBorder()) return BORDER_NONE;
|
||||
|
||||
@ -391,6 +397,7 @@ public class XSSFCellStyle implements CellStyle {
|
||||
* @return the index of the color definition, default value is {@link org.apache.poi.ss.usermodel.IndexedColors#AUTOMATIC}
|
||||
* @see org.apache.poi.ss.usermodel.IndexedColors
|
||||
*/
|
||||
@Override
|
||||
public short getBottomBorderColor() {
|
||||
XSSFColor clr = getBottomBorderXSSFColor();
|
||||
return clr == null ? IndexedColors.BLACK.getIndex() : clr.getIndexed();
|
||||
@ -415,6 +422,7 @@ public class XSSFCellStyle implements CellStyle {
|
||||
*
|
||||
* @return the index of the number format
|
||||
*/
|
||||
@Override
|
||||
public short getDataFormat() {
|
||||
return (short)_cellXf.getNumFmtId();
|
||||
}
|
||||
@ -425,6 +433,7 @@ public class XSSFCellStyle implements CellStyle {
|
||||
*
|
||||
* @return the number format string
|
||||
*/
|
||||
@Override
|
||||
public String getDataFormatString() {
|
||||
int idx = getDataFormat();
|
||||
return new XSSFDataFormat(_stylesSource).getFormat((short)idx);
|
||||
@ -439,11 +448,13 @@ public class XSSFCellStyle implements CellStyle {
|
||||
* @return fill color, default value is {@link org.apache.poi.ss.usermodel.IndexedColors#AUTOMATIC}
|
||||
* @see org.apache.poi.ss.usermodel.IndexedColors
|
||||
*/
|
||||
@Override
|
||||
public short getFillBackgroundColor() {
|
||||
XSSFColor clr = getFillBackgroundXSSFColor();
|
||||
return clr == null ? IndexedColors.AUTOMATIC.getIndex() : clr.getIndexed();
|
||||
}
|
||||
|
||||
@Override
|
||||
public XSSFColor getFillBackgroundColorColor() {
|
||||
return getFillBackgroundXSSFColor();
|
||||
}
|
||||
@ -480,11 +491,13 @@ public class XSSFCellStyle implements CellStyle {
|
||||
* @see IndexedColors
|
||||
* @return fill color, default value is {@link org.apache.poi.ss.usermodel.IndexedColors#AUTOMATIC}
|
||||
*/
|
||||
@Override
|
||||
public short getFillForegroundColor() {
|
||||
XSSFColor clr = getFillForegroundXSSFColor();
|
||||
return clr == null ? IndexedColors.AUTOMATIC.getIndex() : clr.getIndexed();
|
||||
}
|
||||
|
||||
@Override
|
||||
public XSSFColor getFillForegroundColorColor() {
|
||||
return getFillForegroundXSSFColor();
|
||||
}
|
||||
@ -530,6 +543,7 @@ public class XSSFCellStyle implements CellStyle {
|
||||
* @see org.apache.poi.ss.usermodel.CellStyle#SQUARES
|
||||
* @see org.apache.poi.ss.usermodel.CellStyle#DIAMONDS
|
||||
*/
|
||||
@Override
|
||||
public short getFillPattern() {
|
||||
// bug 56295: handle missing applyFill attribute as "true" because Excel does as well
|
||||
if(_cellXf.isSetApplyFill() && !_cellXf.getApplyFill()) return 0;
|
||||
@ -569,6 +583,7 @@ public class XSSFCellStyle implements CellStyle {
|
||||
* @return short - font index
|
||||
* @see org.apache.poi.xssf.usermodel.XSSFWorkbook#getFontAt(short)
|
||||
*/
|
||||
@Override
|
||||
public short getFontIndex() {
|
||||
return (short) getFontId();
|
||||
}
|
||||
@ -578,6 +593,7 @@ public class XSSFCellStyle implements CellStyle {
|
||||
*
|
||||
* @return boolean - whether the cell using this style is hidden
|
||||
*/
|
||||
@Override
|
||||
public boolean getHidden() {
|
||||
if (!_cellXf.isSetProtection() || !_cellXf.getProtection().isSetHidden()) {
|
||||
return false;
|
||||
@ -590,6 +606,7 @@ public class XSSFCellStyle implements CellStyle {
|
||||
*
|
||||
* @return indent - number of spaces
|
||||
*/
|
||||
@Override
|
||||
public short getIndention() {
|
||||
CTCellAlignment align = _cellXf.getAlignment();
|
||||
return (short)(align == null ? 0 : align.getIndent());
|
||||
@ -600,9 +617,18 @@ public class XSSFCellStyle implements CellStyle {
|
||||
*
|
||||
* @return unique index number of the underlying record this style represents
|
||||
*/
|
||||
@Override
|
||||
public short getIndex() {
|
||||
return (short)this._cellXfId;
|
||||
}
|
||||
|
||||
/**
|
||||
* Workaround for places where we need to support more than 32767 cell styles, ideally
|
||||
* the main getIndex() and others would return int, not short, but that would affect some
|
||||
* public APIs
|
||||
*
|
||||
* @return
|
||||
*/
|
||||
protected int getUIndex() {
|
||||
return this._cellXfId;
|
||||
}
|
||||
@ -613,6 +639,7 @@ public class XSSFCellStyle implements CellStyle {
|
||||
* @return the index of the color definition, default value is {@link org.apache.poi.ss.usermodel.IndexedColors#BLACK}
|
||||
* @see org.apache.poi.ss.usermodel.IndexedColors
|
||||
*/
|
||||
@Override
|
||||
public short getLeftBorderColor() {
|
||||
XSSFColor clr = getLeftBorderXSSFColor();
|
||||
return clr == null ? IndexedColors.BLACK.getIndex() : clr.getIndexed();
|
||||
@ -638,6 +665,7 @@ public class XSSFCellStyle implements CellStyle {
|
||||
*
|
||||
* @return whether the cell using this style are locked
|
||||
*/
|
||||
@Override
|
||||
public boolean getLocked() {
|
||||
if (!_cellXf.isSetProtection() || !_cellXf.getProtection().isSetLocked()) {
|
||||
return true;
|
||||
@ -651,6 +679,7 @@ public class XSSFCellStyle implements CellStyle {
|
||||
* @return the index of the color definition, default value is {@link org.apache.poi.ss.usermodel.IndexedColors#BLACK}
|
||||
* @see org.apache.poi.ss.usermodel.IndexedColors
|
||||
*/
|
||||
@Override
|
||||
public short getRightBorderColor() {
|
||||
XSSFColor clr = getRightBorderXSSFColor();
|
||||
return clr == null ? IndexedColors.BLACK.getIndex() : clr.getIndexed();
|
||||
@ -683,11 +712,13 @@ public class XSSFCellStyle implements CellStyle {
|
||||
*
|
||||
* @return rotation degrees (between 0 and 180 degrees)
|
||||
*/
|
||||
@Override
|
||||
public short getRotation() {
|
||||
CTCellAlignment align = _cellXf.getAlignment();
|
||||
return (short)(align == null ? 0 : align.getTextRotation());
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean getShrinkToFit() {
|
||||
CTCellAlignment align = _cellXf.getAlignment();
|
||||
return align != null && align.getShrinkToFit();
|
||||
@ -699,6 +730,7 @@ public class XSSFCellStyle implements CellStyle {
|
||||
* @return the index of the color definition, default value is {@link org.apache.poi.ss.usermodel.IndexedColors#BLACK}
|
||||
* @see org.apache.poi.ss.usermodel.IndexedColors
|
||||
*/
|
||||
@Override
|
||||
public short getTopBorderColor() {
|
||||
XSSFColor clr = getTopBorderXSSFColor();
|
||||
return clr == null ? IndexedColors.BLACK.getIndex() : clr.getIndexed();
|
||||
@ -727,6 +759,7 @@ public class XSSFCellStyle implements CellStyle {
|
||||
* @see org.apache.poi.ss.usermodel.CellStyle#VERTICAL_BOTTOM
|
||||
* @see org.apache.poi.ss.usermodel.CellStyle#VERTICAL_JUSTIFY
|
||||
*/
|
||||
@Override
|
||||
public short getVerticalAlignment() {
|
||||
return (short) (getVerticalAlignmentEnum().ordinal());
|
||||
}
|
||||
@ -750,6 +783,7 @@ public class XSSFCellStyle implements CellStyle {
|
||||
*
|
||||
* @return a boolean value indicating if the text in a cell should be line-wrapped within the cell.
|
||||
*/
|
||||
@Override
|
||||
public boolean getWrapText() {
|
||||
CTCellAlignment align = _cellXf.getAlignment();
|
||||
return align != null && align.getWrapText();
|
||||
@ -767,6 +801,7 @@ public class XSSFCellStyle implements CellStyle {
|
||||
* @see org.apache.poi.ss.usermodel.CellStyle#ALIGN_JUSTIFY
|
||||
* @see org.apache.poi.ss.usermodel.CellStyle#ALIGN_CENTER_SELECTION
|
||||
*/
|
||||
@Override
|
||||
public void setAlignment(short align) {
|
||||
getCellAlignment().setHorizontal(HorizontalAlignment.values()[align]);
|
||||
}
|
||||
@ -800,6 +835,7 @@ public class XSSFCellStyle implements CellStyle {
|
||||
* @see org.apache.poi.ss.usermodel.CellStyle#BORDER_MEDIUM_DASH_DOT_DOT
|
||||
* @see org.apache.poi.ss.usermodel.CellStyle#BORDER_SLANTED_DASH_DOT
|
||||
*/
|
||||
@Override
|
||||
public void setBorderBottom(short border) {
|
||||
CTBorder ct = getCTBorder();
|
||||
CTBorderPr pr = ct.isSetBottom() ? ct.getBottom() : ct.addNewBottom();
|
||||
@ -840,6 +876,7 @@ public class XSSFCellStyle implements CellStyle {
|
||||
* @see org.apache.poi.ss.usermodel.CellStyle#BORDER_MEDIUM_DASH_DOT_DOT
|
||||
* @see org.apache.poi.ss.usermodel.CellStyle#BORDER_SLANTED_DASH_DOT
|
||||
*/
|
||||
@Override
|
||||
public void setBorderLeft(short border) {
|
||||
CTBorder ct = getCTBorder();
|
||||
CTBorderPr pr = ct.isSetLeft() ? ct.getLeft() : ct.addNewLeft();
|
||||
@ -880,6 +917,7 @@ public class XSSFCellStyle implements CellStyle {
|
||||
* @see org.apache.poi.ss.usermodel.CellStyle#BORDER_MEDIUM_DASH_DOT_DOT
|
||||
* @see org.apache.poi.ss.usermodel.CellStyle#BORDER_SLANTED_DASH_DOT
|
||||
*/
|
||||
@Override
|
||||
public void setBorderRight(short border) {
|
||||
CTBorder ct = getCTBorder();
|
||||
CTBorderPr pr = ct.isSetRight() ? ct.getRight() : ct.addNewRight();
|
||||
@ -920,6 +958,7 @@ public class XSSFCellStyle implements CellStyle {
|
||||
* @see org.apache.poi.ss.usermodel.CellStyle#BORDER_MEDIUM_DASH_DOT_DOT
|
||||
* @see org.apache.poi.ss.usermodel.CellStyle#BORDER_SLANTED_DASH_DOT
|
||||
*/
|
||||
@Override
|
||||
public void setBorderTop(short border) {
|
||||
CTBorder ct = getCTBorder();
|
||||
CTBorderPr pr = ct.isSetTop() ? ct.getTop() : ct.addNewTop();
|
||||
@ -946,6 +985,7 @@ public class XSSFCellStyle implements CellStyle {
|
||||
* @param color the index of the color definition
|
||||
* @see org.apache.poi.ss.usermodel.IndexedColors
|
||||
*/
|
||||
@Override
|
||||
public void setBottomBorderColor(short color) {
|
||||
XSSFColor clr = new XSSFColor();
|
||||
clr.setIndexed(color);
|
||||
@ -976,6 +1016,7 @@ public class XSSFCellStyle implements CellStyle {
|
||||
*
|
||||
* @param fmt the index of a data format
|
||||
*/
|
||||
@Override
|
||||
public void setDataFormat(short fmt) {
|
||||
// XSSF supports >32,767 formats
|
||||
setDataFormat(fmt&0xffff);
|
||||
@ -1054,6 +1095,7 @@ public class XSSFCellStyle implements CellStyle {
|
||||
* @param bg - the color to use
|
||||
* @see org.apache.poi.ss.usermodel.IndexedColors
|
||||
*/
|
||||
@Override
|
||||
public void setFillBackgroundColor(short bg) {
|
||||
XSSFColor clr = new XSSFColor();
|
||||
clr.setIndexed(bg);
|
||||
@ -1088,6 +1130,7 @@ public class XSSFCellStyle implements CellStyle {
|
||||
* @param fg the color to use
|
||||
* @see org.apache.poi.ss.usermodel.IndexedColors
|
||||
*/
|
||||
@Override
|
||||
public void setFillForegroundColor(short fg) {
|
||||
XSSFColor clr = new XSSFColor();
|
||||
clr.setIndexed(fg);
|
||||
@ -1153,6 +1196,7 @@ public class XSSFCellStyle implements CellStyle {
|
||||
* @see #setFillForegroundColor(short)
|
||||
* @param fp fill pattern (set to {@link org.apache.poi.ss.usermodel.CellStyle#SOLID_FOREGROUND} to fill w/foreground color)
|
||||
*/
|
||||
@Override
|
||||
public void setFillPattern(short fp) {
|
||||
CTFill ct = getCTFill();
|
||||
CTPatternFill ptrn = ct.isSetPatternFill() ? ct.getPatternFill() : ct.addNewPatternFill();
|
||||
@ -1182,6 +1226,7 @@ public class XSSFCellStyle implements CellStyle {
|
||||
* @see org.apache.poi.xssf.usermodel.XSSFWorkbook#createFont()
|
||||
* @see org.apache.poi.xssf.usermodel.XSSFWorkbook#getFontAt(short)
|
||||
*/
|
||||
@Override
|
||||
public void setFont(Font font) {
|
||||
if(font != null){
|
||||
long index = font.getIndex();
|
||||
@ -1197,6 +1242,7 @@ public class XSSFCellStyle implements CellStyle {
|
||||
*
|
||||
* @param hidden - whether the cell using this style should be hidden
|
||||
*/
|
||||
@Override
|
||||
public void setHidden(boolean hidden) {
|
||||
if (!_cellXf.isSetProtection()) {
|
||||
_cellXf.addNewProtection();
|
||||
@ -1209,6 +1255,7 @@ public class XSSFCellStyle implements CellStyle {
|
||||
*
|
||||
* @param indent - number of spaces
|
||||
*/
|
||||
@Override
|
||||
public void setIndention(short indent) {
|
||||
getCellAlignment().setIndent(indent);
|
||||
}
|
||||
@ -1219,6 +1266,7 @@ public class XSSFCellStyle implements CellStyle {
|
||||
* @param color the index of the color definition
|
||||
* @see org.apache.poi.ss.usermodel.IndexedColors
|
||||
*/
|
||||
@Override
|
||||
public void setLeftBorderColor(short color) {
|
||||
XSSFColor clr = new XSSFColor();
|
||||
clr.setIndexed(color);
|
||||
@ -1249,6 +1297,7 @@ public class XSSFCellStyle implements CellStyle {
|
||||
*
|
||||
* @param locked - whether the cell using this style should be locked
|
||||
*/
|
||||
@Override
|
||||
public void setLocked(boolean locked) {
|
||||
if (!_cellXf.isSetProtection()) {
|
||||
_cellXf.addNewProtection();
|
||||
@ -1262,6 +1311,7 @@ public class XSSFCellStyle implements CellStyle {
|
||||
* @param color the index of the color definition
|
||||
* @see org.apache.poi.ss.usermodel.IndexedColors
|
||||
*/
|
||||
@Override
|
||||
public void setRightBorderColor(short color) {
|
||||
XSSFColor clr = new XSSFColor();
|
||||
clr.setIndexed(color);
|
||||
@ -1301,6 +1351,7 @@ public class XSSFCellStyle implements CellStyle {
|
||||
*
|
||||
* @param rotation - the rotation degrees (between 0 and 180 degrees)
|
||||
*/
|
||||
@Override
|
||||
public void setRotation(short rotation) {
|
||||
getCellAlignment().setTextRotation(rotation);
|
||||
}
|
||||
@ -1312,6 +1363,7 @@ public class XSSFCellStyle implements CellStyle {
|
||||
* @param color the index of the color definition
|
||||
* @see org.apache.poi.ss.usermodel.IndexedColors
|
||||
*/
|
||||
@Override
|
||||
public void setTopBorderColor(short color) {
|
||||
XSSFColor clr = new XSSFColor();
|
||||
clr.setIndexed(color);
|
||||
@ -1347,6 +1399,7 @@ public class XSSFCellStyle implements CellStyle {
|
||||
* @see org.apache.poi.ss.usermodel.CellStyle#VERTICAL_JUSTIFY
|
||||
* @see org.apache.poi.ss.usermodel.VerticalAlignment
|
||||
*/
|
||||
@Override
|
||||
public void setVerticalAlignment(short align) {
|
||||
getCellAlignment().setVertical(VerticalAlignment.values()[align]);
|
||||
}
|
||||
@ -1369,6 +1422,7 @@ public class XSSFCellStyle implements CellStyle {
|
||||
*
|
||||
* @param wrapped a boolean value indicating if the text in a cell should be line-wrapped within the cell.
|
||||
*/
|
||||
@Override
|
||||
public void setWrapText(boolean wrapped) {
|
||||
getCellAlignment().setWrapText(wrapped);
|
||||
}
|
||||
@ -1417,6 +1471,7 @@ public class XSSFCellStyle implements CellStyle {
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setShrinkToFit(boolean shrinkToFit) {
|
||||
getCellAlignment().setShrinkToFit(shrinkToFit);
|
||||
}
|
||||
@ -1456,6 +1511,7 @@ public class XSSFCellStyle implements CellStyle {
|
||||
*
|
||||
* @return the hash code value for this style
|
||||
*/
|
||||
@Override
|
||||
public int hashCode(){
|
||||
return _cellXf.toString().hashCode();
|
||||
}
|
||||
@ -1466,6 +1522,7 @@ public class XSSFCellStyle implements CellStyle {
|
||||
* @param o the style to check
|
||||
* @return true if the supplied style is equal to this style
|
||||
*/
|
||||
@Override
|
||||
public boolean equals(Object o){
|
||||
if(o == null || !(o instanceof XSSFCellStyle)) return false;
|
||||
|
||||
@ -1479,6 +1536,7 @@ public class XSSFCellStyle implements CellStyle {
|
||||
*
|
||||
* @return a copy of this style
|
||||
*/
|
||||
@Override
|
||||
public Object clone(){
|
||||
CTXf xf = (CTXf)_cellXf.copy();
|
||||
|
||||
|
@ -18,15 +18,16 @@
|
||||
|
||||
package org.apache.poi.poifs.filesystem;
|
||||
|
||||
import java.io.*;
|
||||
|
||||
import java.util.*;
|
||||
|
||||
import junit.framework.*;
|
||||
import java.io.ByteArrayInputStream;
|
||||
import java.io.FileNotFoundException;
|
||||
import java.io.IOException;
|
||||
import java.util.Iterator;
|
||||
|
||||
import org.apache.poi.poifs.property.DirectoryProperty;
|
||||
import org.apache.poi.poifs.property.DocumentProperty;
|
||||
|
||||
import junit.framework.TestCase;
|
||||
|
||||
/**
|
||||
* Class to test DirectoryNode functionality
|
||||
*
|
||||
@ -51,7 +52,7 @@ public final class TestDirectoryNode extends TestCase {
|
||||
|
||||
// verify that getEntries behaves correctly
|
||||
int count = 0;
|
||||
Iterator iter = node.getEntries();
|
||||
Iterator<Entry> iter = node.getEntries();
|
||||
|
||||
while (iter.hasNext())
|
||||
{
|
||||
@ -106,7 +107,7 @@ public final class TestDirectoryNode extends TestCase {
|
||||
|
||||
// verify that getEntries behaves correctly
|
||||
int count = 0;
|
||||
Iterator iter = node.getEntries();
|
||||
Iterator<Entry> iter = node.getEntries();
|
||||
|
||||
while (iter.hasNext())
|
||||
{
|
||||
@ -189,6 +190,8 @@ public final class TestDirectoryNode extends TestCase {
|
||||
|
||||
// It's really gone!
|
||||
assertTrue(root.isEmpty());
|
||||
|
||||
fs.close();
|
||||
}
|
||||
|
||||
/**
|
||||
@ -211,5 +214,7 @@ public final class TestDirectoryNode extends TestCase {
|
||||
assertTrue(dir.renameTo("FirstDir"));
|
||||
assertTrue(dir2.renameTo("foo"));
|
||||
assertEquals("foo", dir2.getName());
|
||||
|
||||
fs.close();
|
||||
}
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user