public int getCharWidth( char c )
{
Integer widthInteger = charWidths.get(Character.valueOf(c));
- if (widthInteger == null && c != 'W') {
- return getCharWidth('W');
+ if (widthInteger == null) {
+ return 'W' == c ? 0 : getCharWidth('W');
}
- return widthInteger.intValue();
+ return widthInteger;
}
public void addChars( char[] characters, int[] widths )
\r
\r
public static double convertToDecimal(String value, int base, int maxNumberOfPlaces) throws IllegalArgumentException {\r
- if (value != null && value.length() == 0) {\r
+ if (value == null || value.length() == 0) {\r
return 0.0;\r
}\r
\r
public DigitalCertificatePart() throws InvalidFormatException{
super(null, null, new ContentType(""));
- // Review constructor
+ // TODO: Review constructor
}
@Override
public PackageDigitalSignature() throws InvalidFormatException {
super(null, null, new ContentType(""));
+ // TODO: Review constructor
}
@Override
import org.apache.xmlbeans.XmlObject;
import org.apache.xmlbeans.XmlOptions;
import org.openxmlformats.schemas.officeDocument.x2006.relationships.STRelationshipId;
-import org.openxmlformats.schemas.spreadsheetml.x2006.main.*;
+import org.openxmlformats.schemas.spreadsheetml.x2006.main.CTBookView;
+import org.openxmlformats.schemas.spreadsheetml.x2006.main.CTBookViews;
+import org.openxmlformats.schemas.spreadsheetml.x2006.main.CTCalcPr;
+import org.openxmlformats.schemas.spreadsheetml.x2006.main.CTDefinedName;
+import org.openxmlformats.schemas.spreadsheetml.x2006.main.CTDefinedNames;
+import org.openxmlformats.schemas.spreadsheetml.x2006.main.CTDialogsheet;
+import org.openxmlformats.schemas.spreadsheetml.x2006.main.CTSheet;
+import org.openxmlformats.schemas.spreadsheetml.x2006.main.CTSheets;
+import org.openxmlformats.schemas.spreadsheetml.x2006.main.CTWorkbook;
+import org.openxmlformats.schemas.spreadsheetml.x2006.main.CTWorkbookPr;
+import org.openxmlformats.schemas.spreadsheetml.x2006.main.CTWorkbookProtection;
+import org.openxmlformats.schemas.spreadsheetml.x2006.main.CTWorksheet;
+import org.openxmlformats.schemas.spreadsheetml.x2006.main.STCalcMode;
+import org.openxmlformats.schemas.spreadsheetml.x2006.main.STSheetState;
+import org.openxmlformats.schemas.spreadsheetml.x2006.main.WorkbookDocument;
/**
* High level representation of a SpreadsheetML workbook. This is the first object most users
// YK: Mimic Excel and silently truncate sheet names longer than 31 characters
if(sheetname != null && sheetname.length() > 31) sheetname = sheetname.substring(0, 31);
WorkbookUtil.validateSheetName(sheetname);
+ // findbugs fix - validateSheetName has already checked for null value
+ assert(sheetname != null);
if (containsSheet(sheetname, sheetIndex ))
throw new IllegalArgumentException( "The workbook already contains a sheet of this name" );
CTCols aggregateCols = CTCols.Factory.newInstance();
List<CTCols> colsList = worksheet.getColsList();
- if (colsList != null) {
- for (CTCols cols : colsList) {
- for (CTCol col : cols.getColList()) {
- cloneCol(aggregateCols, col);
- }
+ if (colsList == null || colsList.isEmpty()) {
+ return;
+ }
+
+ for (CTCols cols : colsList) {
+ for (CTCol col : cols.getColList()) {
+ cloneCol(aggregateCols, col);
}
}
import org.openxmlformats.schemas.wordprocessingml.x2006.main.CTStyles;
import org.openxmlformats.schemas.wordprocessingml.x2006.main.CTTbl;
import org.openxmlformats.schemas.wordprocessingml.x2006.main.CTTc;
-import org.openxmlformats.schemas.wordprocessingml.x2006.main.NumberingDocument;
import org.openxmlformats.schemas.wordprocessingml.x2006.main.CommentsDocument;
import org.openxmlformats.schemas.wordprocessingml.x2006.main.DocumentDocument;
import org.openxmlformats.schemas.wordprocessingml.x2006.main.EndnotesDocument;
import org.openxmlformats.schemas.wordprocessingml.x2006.main.FootnotesDocument;
+import org.openxmlformats.schemas.wordprocessingml.x2006.main.NumberingDocument;
import org.openxmlformats.schemas.wordprocessingml.x2006.main.STDocProtect;
import org.openxmlformats.schemas.wordprocessingml.x2006.main.StylesDocument;
throw new POIXMLException(e);
} finally {
try {
- out.close();
+ if (out != null) out.close();
} catch (IOException e) {
// ignore
}
throw new POIXMLException(e);
} finally {
try {
- out.close();
+ if (out != null) out.close();
} catch (IOException e) {
// ignore
}
import org.openxmlformats.schemas.wordprocessingml.x2006.main.CTRPr;
import org.openxmlformats.schemas.wordprocessingml.x2006.main.CTRunTrackChange;
import org.openxmlformats.schemas.wordprocessingml.x2006.main.CTSdtBlock;
-import org.openxmlformats.schemas.wordprocessingml.x2006.main.CTSdtContentRun;
import org.openxmlformats.schemas.wordprocessingml.x2006.main.CTSdtRun;
import org.openxmlformats.schemas.wordprocessingml.x2006.main.CTSimpleField;
import org.openxmlformats.schemas.wordprocessingml.x2006.main.CTSmartTagRun;
*/
public void setBorderTop(Borders border) {
CTPBdr ct = getCTPBrd(true);
+ if (ct == null) {
+ throw new RuntimeException("invalid paragraph state");
+ }
- CTBorder pr = (ct != null && ct.isSetTop()) ? ct.getTop() : ct.addNewTop();
+ CTBorder pr = (ct.isSetTop()) ? ct.getTop() : ct.addNewTop();
if (border.getValue() == Borders.NONE.getValue())
ct.unsetTop();
else
throw new POIXMLException(e);
} finally {
try {
- is.close();
+ if (is != null) is.close();
} catch (IOException e) {
throw new POIXMLException(e);
}
import org.apache.poi.hslf.model.textproperties.TextProp;
import org.apache.poi.hslf.model.textproperties.TextPropCollection;
import org.apache.poi.hslf.record.ColorSchemeAtom;
-import org.apache.poi.util.POILogger;
import org.apache.poi.util.POILogFactory;
+import org.apache.poi.util.POILogger;
/**
// paragraphStyle will now be defined
}
+ assert(paragraphStyle!=null);
TextProp tp = fetchOrAddTextProp(paragraphStyle, propName);
tp.setValue(val);
}
// characterStyle will now be defined
}
+ assert(characterStyle!=null);
TextProp tp = fetchOrAddTextProp(characterStyle, propName);
tp.setValue(val);
}
break;
default:
//should never happen
- break;
+ throw new RuntimeException("Invalid sprm type");
}
LittleEndian.putShort(sprm, 0, instruction);
list.add(sprm);
{
continue;
}
- if ( !obj1.equals( obj2 ) )
+ if ( obj1 == null || obj2 == null || !obj1.equals( obj2 ) )
{
return false;
}