SonarQube fixes

git-svn-id: https://svn.apache.org/repos/asf/poi/trunk@1793727 13f79535-47bb-0310-9956-ffa450edef68
This commit is contained in:
Andreas Beeker 2017-05-03 22:16:26 +00:00
parent 76dbb5a1eb
commit ad72f60ab6
6 changed files with 38 additions and 26 deletions

View File

@ -401,11 +401,11 @@ public class CopyCompare
final String name, final String name,
final DocumentInputStream stream) final DocumentInputStream stream)
throws IOException { throws IOException {
final DirectoryEntry de = getPath(poiFs, path); if (stream == null || name == null) {
if (stream == null && name == null) {
// Empty directory // Empty directory
return; return;
} }
final DirectoryEntry de = getPath(poiFs, path);
final ByteArrayOutputStream out = new ByteArrayOutputStream(); final ByteArrayOutputStream out = new ByteArrayOutputStream();
int c; int c;
while ((c = stream.read()) != -1) { while ((c = stream.read()) != -1) {

View File

@ -47,7 +47,7 @@ public final class EscherArrayProperty extends EscherComplexProperty implements
public EscherArrayProperty(short id, byte[] complexData) { public EscherArrayProperty(short id, byte[] complexData) {
super(id, checkComplexData(complexData)); super(id, checkComplexData(complexData));
emptyComplexPart = complexData.length == 0; emptyComplexPart = (complexData == null || complexData.length == 0);
} }
public EscherArrayProperty(short propertyNumber, boolean isBlipId, byte[] complexData) { public EscherArrayProperty(short propertyNumber, boolean isBlipId, byte[] complexData) {

View File

@ -128,27 +128,29 @@ public final class ActiveXShape extends HSLFPictureShape {
*/ */
public ExControl getExControl(){ public ExControl getExControl(){
int idx = getControlIndex(); int idx = getControlIndex();
ExControl ctrl = null;
Document doc = getSheet().getSlideShow().getDocumentRecord(); Document doc = getSheet().getSlideShow().getDocumentRecord();
ExObjList lst = (ExObjList)doc.findFirstOfType(RecordTypes.ExObjList.typeID); ExObjList lst = (ExObjList)doc.findFirstOfType(RecordTypes.ExObjList.typeID);
if(lst != null){ if (lst == null) {
Record[] ch = lst.getChildRecords(); return null;
for (int i = 0; i < ch.length; i++) { }
if(ch[i] instanceof ExControl){
ExControl c = (ExControl)ch[i]; for (Record ch : lst.getChildRecords()) {
if(c.getExOleObjAtom().getObjID() == idx){ if(ch instanceof ExControl){
ctrl = c; ExControl c = (ExControl)ch;
break; if(c.getExOleObjAtom().getObjID() == idx){
} return c;
} }
} }
} }
return ctrl; return null;
} }
@Override @Override
protected void afterInsert(HSLFSheet sheet){ protected void afterInsert(HSLFSheet sheet){
ExControl ctrl = getExControl(); ExControl ctrl = getExControl();
if (ctrl == null) {
throw new NullPointerException("ExControl is not defined");
}
ctrl.getExControlAtom().setSlideId(sheet._getSheetNumber()); ctrl.getExControlAtom().setSlideId(sheet._getSheetNumber());
String name = ctrl.getProgId() + "-" + getControlIndex() + '\u0000'; String name = ctrl.getProgId() + "-" + getControlIndex() + '\u0000';

View File

@ -185,7 +185,8 @@ public final class OLEShape extends HSLFPictureShape {
* @return the instance name of the embedded object * @return the instance name of the embedded object
*/ */
public String getInstanceName(){ public String getInstanceName(){
return getExEmbed().getMenuName(); ExEmbed ee = getExEmbed();
return (ee == null) ? null : ee.getMenuName();
} }
/** /**
@ -195,7 +196,8 @@ public final class OLEShape extends HSLFPictureShape {
* @return the full name of the embedded object * @return the full name of the embedded object
*/ */
public String getFullName(){ public String getFullName(){
return getExEmbed().getClipboardName(); ExEmbed ee = getExEmbed();
return (ee == null) ? null : ee.getClipboardName();
} }
/** /**
@ -206,6 +208,7 @@ public final class OLEShape extends HSLFPictureShape {
* @return the ProgID * @return the ProgID
*/ */
public String getProgID(){ public String getProgID(){
return getExEmbed().getProgId(); ExEmbed ee = getExEmbed();
return (ee == null) ? null : ee.getProgId();
} }
} }

View File

@ -360,13 +360,16 @@ public final class PPDrawing extends RecordAtom {
* @return EscherDgRecord * @return EscherDgRecord
*/ */
public EscherDgRecord getEscherDgRecord(){ public EscherDgRecord getEscherDgRecord(){
if(dg == null){ if (dg == null) {
for(EscherRecord r : getDgContainer().getChildRecords()){ EscherContainerRecord dgr = getDgContainer();
if(r instanceof EscherDgRecord){ if (dgr != null) {
dg = (EscherDgRecord)r; for(EscherRecord r : dgr.getChildRecords()){
break; if(r instanceof EscherDgRecord){
} dg = (EscherDgRecord)r;
} break;
}
}
}
} }
return dg; return dg;
} }

View File

@ -372,7 +372,9 @@ public final class HSLFFill {
if(p != null) { if(p != null) {
int idx = p.getPropertyValue(); int idx = p.getPropertyValue();
EscherBSERecord bse = getEscherBSERecord(idx); EscherBSERecord bse = getEscherBSERecord(idx);
bse.setRef(bse.getRef() + 1); if (bse != null) {
bse.setRef(bse.getRef() + 1);
}
} }
} }
@ -521,7 +523,9 @@ public final class HSLFFill {
HSLFShape.setEscherProperty(opt, (short)(EscherProperties.FILL__PATTERNTEXTURE + 0x4000), (data == null ? 0 : data.getIndex())); HSLFShape.setEscherProperty(opt, (short)(EscherProperties.FILL__PATTERNTEXTURE + 0x4000), (data == null ? 0 : data.getIndex()));
if(data != null && shape.getSheet() != null) { if(data != null && shape.getSheet() != null) {
EscherBSERecord bse = getEscherBSERecord(data.getIndex()); EscherBSERecord bse = getEscherBSERecord(data.getIndex());
bse.setRef(bse.getRef() + 1); if (bse != null) {
bse.setRef(bse.getRef() + 1);
}
} }
} }