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 DocumentInputStream stream)
throws IOException {
final DirectoryEntry de = getPath(poiFs, path);
if (stream == null && name == null) {
if (stream == null || name == null) {
// Empty directory
return;
}
final DirectoryEntry de = getPath(poiFs, path);
final ByteArrayOutputStream out = new ByteArrayOutputStream();
int c;
while ((c = stream.read()) != -1) {

View File

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

View File

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

View File

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

View File

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