Author: kiwiwings
Date: Sat Jun 2 13:01:14 2018
New Revision: 1832735
URL: http://svn.apache.org/viewvc?rev=1832735&view=rev
Log:
sonar fixes
Removed:
poi/trunk/src/ooxml/java/org/apache/poi/openxml4j/opc/EncryptionOption.java
Modified:
poi/trunk/src/java/org/apache/poi/common/usermodel/fonts/FontGroup.java
poi/trunk/src/java/org/apache/poi/sl/draw/SLGraphics.java
poi/trunk/src/java/org/apache/poi/ss/formula/EvaluationConditionalFormatRule.java
poi/trunk/src/java/org/apache/poi/ss/usermodel/TableStyleType.java
poi/trunk/src/ooxml/java/org/apache/poi/openxml4j/opc/PackageRelationshipCollection.java
poi/trunk/src/ooxml/java/org/apache/poi/poifs/crypt/dsig/SignatureInfo.java
poi/trunk/src/scratchpad/src/org/apache/poi/hpbf/model/HPBFPart.java
poi/trunk/src/scratchpad/src/org/apache/poi/hslf/model/PPGraphics2D.java
poi/trunk/src/scratchpad/src/org/apache/poi/hslf/model/textproperties/HSLFTabStopPropCollection.java
poi/trunk/src/scratchpad/src/org/apache/poi/hslf/model/textproperties/TextPropCollection.java
poi/trunk/src/scratchpad/src/org/apache/poi/hslf/usermodel/HSLFTextParagraph.java
poi/trunk/src/scratchpad/src/org/apache/poi/hwpf/model/ListTables.java
Modified:
poi/trunk/src/java/org/apache/poi/common/usermodel/fonts/FontGroup.java
URL:
http://svn.apache.org/viewvc/poi/trunk/src/java/org/apache/poi/common/usermodel/fonts/FontGroup.java?rev=1832735&r1=1832734&r2=1832735&view=diff
==============================================================================
--- poi/trunk/src/java/org/apache/poi/common/usermodel/fonts/FontGroup.java
(original)
+++ poi/trunk/src/java/org/apache/poi/common/usermodel/fonts/FontGroup.java Sat
Jun 2 13:01:14 2018
@@ -111,18 +111,18 @@ public enum FontGroup {
* @return the FontGroup
*/
public static List<FontGroupRange> getFontGroupRanges(final String
runText) {
- List<FontGroupRange> ttrList = new ArrayList<>();
+ final List<FontGroupRange> ttrList = new ArrayList<>();
if (runText == null || runText.isEmpty()) {
return ttrList;
}
FontGroupRange ttrLast = null;
- final int rlen = (runText != null) ? runText.length() : 0;
+ final int rlen = runText.length();
for(int cp, i = 0, charCount; i < rlen; i += charCount) {
cp = runText.codePointAt(i);
charCount = Character.charCount(cp);
// don't switch the font group for a few default characters
supposedly available in all fonts
- FontGroup tt;
+ final FontGroup tt;
if (ttrLast != null && " \n\r".indexOf(cp) > -1) {
tt = ttrLast.fontGroup;
} else {
Modified: poi/trunk/src/java/org/apache/poi/sl/draw/SLGraphics.java
URL:
http://svn.apache.org/viewvc/poi/trunk/src/java/org/apache/poi/sl/draw/SLGraphics.java?rev=1832735&r1=1832734&r2=1832735&view=diff
==============================================================================
--- poi/trunk/src/java/org/apache/poi/sl/draw/SLGraphics.java (original)
+++ poi/trunk/src/java/org/apache/poi/sl/draw/SLGraphics.java Sat Jun 2
13:01:14 2018
@@ -67,12 +67,10 @@ import org.apache.poi.util.SuppressForbi
/**
* Translates Graphics2D calls into PowerPoint.
- *
- * @author Yegor Kozlov
*/
-public final class SLGraphics extends Graphics2D implements Cloneable {
+public class SLGraphics extends Graphics2D implements Cloneable {
- protected POILogger log = POILogFactory.getLogger(this.getClass());
+ private static final POILogger LOG =
POILogFactory.getLogger(SLGraphics.class);
//The ppt object to write into.
private GroupShape<?,?> _group;
@@ -303,7 +301,8 @@ public final class SLGraphics extends Gr
float ascent = layout.getAscent();
float width = (float) Math.floor(layout.getAdvance());
- /**
+
+ /*
* Even if top and bottom margins are set to 0 PowerPoint
* always sets extra space between the text and its bounding box.
*
@@ -384,8 +383,8 @@ public final class SLGraphics extends Gr
*/
@NotImplemented
public void clip(Shape s){
- if (log.check(POILogger.WARN)) {
- log.log(POILogger.WARN, "Not implemented");
+ if (LOG.check(POILogger.WARN)) {
+ LOG.log(POILogger.WARN, "Not implemented");
}
}
@@ -407,8 +406,8 @@ public final class SLGraphics extends Gr
*/
@NotImplemented
public Shape getClip(){
- if (log.check(POILogger.WARN)) {
- log.log(POILogger.WARN, "Not implemented");
+ if (LOG.check(POILogger.WARN)) {
+ LOG.log(POILogger.WARN, "Not implemented");
}
return null;
}
@@ -676,8 +675,8 @@ public final class SLGraphics extends Gr
public boolean drawImage(Image img, int x, int y,
Color bgcolor,
ImageObserver observer){
- if (log.check(POILogger.WARN)) {
- log.log(POILogger.WARN, "Not implemented");
+ if (LOG.check(POILogger.WARN)) {
+ LOG.log(POILogger.WARN, "Not implemented");
}
return false;
@@ -726,8 +725,8 @@ public final class SLGraphics extends Gr
int width, int height,
Color bgcolor,
ImageObserver observer){
- if (log.check(POILogger.WARN)) {
- log.log(POILogger.WARN, "Not implemented");
+ if (LOG.check(POILogger.WARN)) {
+ LOG.log(POILogger.WARN, "Not implemented");
}
return false;
@@ -786,8 +785,8 @@ public final class SLGraphics extends Gr
int dx1, int dy1, int dx2, int dy2,
int sx1, int sy1, int sx2, int sy2,
ImageObserver observer){
- if (log.check(POILogger.WARN)) {
- log.log(POILogger.WARN, "Not implemented");
+ if (LOG.check(POILogger.WARN)) {
+ LOG.log(POILogger.WARN, "Not implemented");
}
return false;
}
@@ -851,8 +850,8 @@ public final class SLGraphics extends Gr
int sx1, int sy1, int sx2, int sy2,
Color bgcolor,
ImageObserver observer){
- if (log.check(POILogger.WARN)) {
- log.log(POILogger.WARN, "Not implemented");
+ if (LOG.check(POILogger.WARN)) {
+ LOG.log(POILogger.WARN, "Not implemented");
}
return false;
}
@@ -892,8 +891,8 @@ public final class SLGraphics extends Gr
@NotImplemented
public boolean drawImage(Image img, int x, int y,
ImageObserver observer) {
- if (log.check(POILogger.WARN)) {
- log.log(POILogger.WARN, "Not implemented");
+ if (LOG.check(POILogger.WARN)) {
+ LOG.log(POILogger.WARN, "Not implemented");
}
return false;
}
@@ -1079,8 +1078,8 @@ public final class SLGraphics extends Gr
*/
@NotImplemented
public void setClip(Shape clip) {
- if (log.check(POILogger.WARN)) {
- log.log(POILogger.WARN, "Not implemented");
+ if (LOG.check(POILogger.WARN)) {
+ LOG.log(POILogger.WARN, "Not implemented");
}
}
@@ -1102,11 +1101,10 @@ public final class SLGraphics extends Gr
* @since JDK1.1
*/
public Rectangle getClipBounds(){
- Shape c = getClip();
- if (c==null) {
- return null;
+ if (LOG.check(POILogger.WARN)) {
+ LOG.log(POILogger.WARN, "Not implemented");
}
- return c.getBounds();
+ return null;
}
/**
@@ -1379,8 +1377,8 @@ public final class SLGraphics extends Gr
*/
@NotImplemented
public void setComposite(Composite comp){
- if (log.check(POILogger.WARN)) {
- log.log(POILogger.WARN, "Not implemented");
+ if (LOG.check(POILogger.WARN)) {
+ LOG.log(POILogger.WARN, "Not implemented");
}
}
@@ -1393,8 +1391,8 @@ public final class SLGraphics extends Gr
*/
@NotImplemented
public Composite getComposite(){
- if (log.check(POILogger.WARN)) {
- log.log(POILogger.WARN, "Not implemented");
+ if (LOG.check(POILogger.WARN)) {
+ LOG.log(POILogger.WARN, "Not implemented");
}
return null;
}
@@ -1537,8 +1535,8 @@ public final class SLGraphics extends Gr
*/
@NotImplemented
public void drawString(AttributedCharacterIterator iterator, float x,
float y) {
- if (log.check(POILogger.WARN)) {
- log.log(POILogger.WARN, "Not implemented");
+ if (LOG.check(POILogger.WARN)) {
+ LOG.log(POILogger.WARN, "Not implemented");
}
}
@@ -1644,8 +1642,8 @@ public final class SLGraphics extends Gr
*/
@NotImplemented
public boolean drawImage(Image img, AffineTransform xform, ImageObserver
obs) {
- if (log.check(POILogger.WARN)) {
- log.log(POILogger.WARN, "Not implemented");
+ if (LOG.check(POILogger.WARN)) {
+ LOG.log(POILogger.WARN, "Not implemented");
}
return false;
}
@@ -1690,8 +1688,8 @@ public final class SLGraphics extends Gr
public boolean drawImage(Image img, int x, int y,
int width, int height,
ImageObserver observer) {
- if (log.check(POILogger.WARN)) {
- log.log(POILogger.WARN, "Not implemented");
+ if (LOG.check(POILogger.WARN)) {
+ LOG.log(POILogger.WARN, "Not implemented");
}
return false;
}
@@ -1741,8 +1739,8 @@ public final class SLGraphics extends Gr
*/
@NotImplemented
public void setXORMode(Color c1) {
- if (log.check(POILogger.WARN)) {
- log.log(POILogger.WARN, "Not implemented");
+ if (LOG.check(POILogger.WARN)) {
+ LOG.log(POILogger.WARN, "Not implemented");
}
}
@@ -1755,8 +1753,8 @@ public final class SLGraphics extends Gr
*/
@NotImplemented
public void setPaintMode() {
- if (log.check(POILogger.WARN)) {
- log.log(POILogger.WARN, "Not implemented");
+ if (LOG.check(POILogger.WARN)) {
+ LOG.log(POILogger.WARN, "Not implemented");
}
}
@@ -1793,8 +1791,8 @@ public final class SLGraphics extends Gr
*/
@NotImplemented
public void drawRenderedImage(RenderedImage img, AffineTransform xform) {
- if (log.check(POILogger.WARN)) {
- log.log(POILogger.WARN, "Not implemented");
+ if (LOG.check(POILogger.WARN)) {
+ LOG.log(POILogger.WARN, "Not implemented");
}
}
@@ -1821,8 +1819,8 @@ public final class SLGraphics extends Gr
*/
@NotImplemented
public void drawRenderableImage(RenderableImage img, AffineTransform
xform) {
- if (log.check(POILogger.WARN)) {
- log.log(POILogger.WARN, "Not implemented");
+ if (LOG.check(POILogger.WARN)) {
+ LOG.log(POILogger.WARN, "Not implemented");
}
}
Modified:
poi/trunk/src/java/org/apache/poi/ss/formula/EvaluationConditionalFormatRule.java
URL:
http://svn.apache.org/viewvc/poi/trunk/src/java/org/apache/poi/ss/formula/EvaluationConditionalFormatRule.java?rev=1832735&r1=1832734&r2=1832735&view=diff
==============================================================================
---
poi/trunk/src/java/org/apache/poi/ss/formula/EvaluationConditionalFormatRule.java
(original)
+++
poi/trunk/src/java/org/apache/poi/ss/formula/EvaluationConditionalFormatRule.java
Sat Jun 2 13:01:14 2018
@@ -632,7 +632,7 @@ public class EvaluationConditionalFormat
for (int c = region.getFirstColumn(); c <= region.getLastColumn();
c++) {
Cell cell = row.getCell(c);
final ValueAndFormat cv = getCellValue(cell);
- if (cv != null && (withText || cv.isNumber()) ) {
+ if (withText || cv.isNumber()) {
allValues.add(cv);
}
}
@@ -646,13 +646,19 @@ public class EvaluationConditionalFormat
private ValueAndFormat getCellValue(Cell cell) {
if (cell != null) {
- final CellType type = cell.getCellType();
- if (type == CellType.NUMERIC || (type == CellType.FORMULA &&
cell.getCachedFormulaResultType() == CellType.NUMERIC) ) {
- return new
ValueAndFormat(Double.valueOf(cell.getNumericCellValue()),
cell.getCellStyle().getDataFormatString(), decimalTextFormat);
- } else if (type == CellType.STRING || (type == CellType.FORMULA &&
cell.getCachedFormulaResultType() == CellType.STRING) ) {
- return new ValueAndFormat(cell.getStringCellValue(),
cell.getCellStyle().getDataFormatString());
- } else if (type == CellType.BOOLEAN || (type == CellType.FORMULA
&& cell.getCachedFormulaResultType() == CellType.BOOLEAN) ) {
- return new ValueAndFormat(cell.getStringCellValue(),
cell.getCellStyle().getDataFormatString());
+ final String format = cell.getCellStyle().getDataFormatString();
+ CellType type = cell.getCellType();
+ if (type == CellType.FORMULA) {
+ type = cell.getCachedFormulaResultType();
+ }
+ switch (type) {
+ case NUMERIC:
+ return new
ValueAndFormat(Double.valueOf(cell.getNumericCellValue()), format,
decimalTextFormat);
+ case STRING:
+ case BOOLEAN:
+ return new ValueAndFormat(cell.getStringCellValue(),
format);
+ default:
+ break;
}
}
return new ValueAndFormat("", "");
Modified: poi/trunk/src/java/org/apache/poi/ss/usermodel/TableStyleType.java
URL:
http://svn.apache.org/viewvc/poi/trunk/src/java/org/apache/poi/ss/usermodel/TableStyleType.java?rev=1832735&r1=1832734&r2=1832735&view=diff
==============================================================================
--- poi/trunk/src/java/org/apache/poi/ss/usermodel/TableStyleType.java
(original)
+++ poi/trunk/src/java/org/apache/poi/ss/usermodel/TableStyleType.java Sat Jun
2 13:01:14 2018
@@ -59,14 +59,15 @@ public enum TableStyleType {
int firstStart = table.getStartColIndex();
int secondStart = firstStart + c1Stripe;
- int c = cell.getCol();
+ final int c = cell.getCol();
// look for the stripe containing c, accounting for the style
element stripe size
// could do fancy math, but tables can't be that wide, a simple
loop is fine
// if not in this type of stripe, return null
- while (true) {
- if (firstStart > c) break;
- if (c >= firstStart && c <= secondStart -1) return new
CellRangeAddress(table.getStartRowIndex(), table.getEndRowIndex(), firstStart,
secondStart - 1);
+ while (firstStart <= c) {
+ if (c >= firstStart && c <= secondStart -1) {
+ return new CellRangeAddress(table.getStartRowIndex(),
table.getEndRowIndex(), firstStart, secondStart - 1);
+ }
firstStart = secondStart + c2Stripe;
secondStart = firstStart + c1Stripe;
}
@@ -86,14 +87,15 @@ public enum TableStyleType {
int firstStart = table.getStartColIndex();
int secondStart = firstStart + c1Stripe;
- int c = cell.getCol();
+ final int c = cell.getCol();
// look for the stripe containing c, accounting for the style
element stripe size
// could do fancy math, but tables can't be that wide, a simple
loop is fine
// if not in this type of stripe, return null
- while (true) {
- if (firstStart > c) break;
- if (c >= secondStart && c <= secondStart + c2Stripe -1) return
new CellRangeAddress(table.getStartRowIndex(), table.getEndRowIndex(),
secondStart, secondStart + c2Stripe - 1);
+ while (firstStart <= c) {
+ if (c >= secondStart && c <= secondStart + c2Stripe -1) {
+ return new CellRangeAddress(table.getStartRowIndex(),
table.getEndRowIndex(), secondStart, secondStart + c2Stripe - 1);
+ }
firstStart = secondStart + c2Stripe;
secondStart = firstStart + c1Stripe;
}
@@ -113,14 +115,15 @@ public enum TableStyleType {
int firstStart = table.getStartRowIndex() +
table.getHeaderRowCount();
int secondStart = firstStart + c1Stripe;
- int c = cell.getRow();
+ final int c = cell.getRow();
// look for the stripe containing c, accounting for the style
element stripe size
// could do fancy math, but tables can't be that wide, a simple
loop is fine
// if not in this type of stripe, return null
- while (true) {
- if (firstStart > c) break;
- if (c >= firstStart && c <= secondStart -1) return new
CellRangeAddress(firstStart, secondStart - 1, table.getStartColIndex(),
table.getEndColIndex());
+ while (firstStart <= c) {
+ if (c >= firstStart && c <= secondStart -1) {
+ return new CellRangeAddress(firstStart, secondStart - 1,
table.getStartColIndex(), table.getEndColIndex());
+ }
firstStart = secondStart + c2Stripe;
secondStart = firstStart + c1Stripe;
}
@@ -140,14 +143,15 @@ public enum TableStyleType {
int firstStart = table.getStartRowIndex() +
table.getHeaderRowCount();
int secondStart = firstStart + c1Stripe;
- int c = cell.getRow();
+ final int c = cell.getRow();
// look for the stripe containing c, accounting for the style
element stripe size
// could do fancy math, but tables can't be that wide, a simple
loop is fine
// if not in this type of stripe, return null
- while (true) {
- if (firstStart > c) break;
- if (c >= secondStart && c <= secondStart +c2Stripe -1) return
new CellRangeAddress(secondStart, secondStart + c2Stripe - 1,
table.getStartColIndex(), table.getEndColIndex());
+ while (firstStart <= c) {
+ if (c >= secondStart && c <= secondStart +c2Stripe -1) {
+ return new CellRangeAddress(secondStart, secondStart +
c2Stripe - 1, table.getStartColIndex(), table.getEndColIndex());
+ }
firstStart = secondStart + c2Stripe;
secondStart = firstStart + c1Stripe;
}
Modified:
poi/trunk/src/ooxml/java/org/apache/poi/openxml4j/opc/PackageRelationshipCollection.java
URL:
http://svn.apache.org/viewvc/poi/trunk/src/ooxml/java/org/apache/poi/openxml4j/opc/PackageRelationshipCollection.java?rev=1832735&r1=1832734&r2=1832735&view=diff
==============================================================================
---
poi/trunk/src/ooxml/java/org/apache/poi/openxml4j/opc/PackageRelationshipCollection.java
(original)
+++
poi/trunk/src/ooxml/java/org/apache/poi/openxml4j/opc/PackageRelationshipCollection.java
Sat Jun 2 13:01:14 2018
@@ -244,13 +244,11 @@ public final class PackageRelationshipCo
* The relationship ID to remove.
*/
public void removeRelationship(String id) {
- if (relationshipsByID != null && relationshipsByType != null) {
- PackageRelationship rel = relationshipsByID.get(id);
- if (rel != null) {
- relationshipsByID.remove(rel.getId());
- relationshipsByType.values().remove(rel);
- internalRelationshipsByTargetName.values().remove(rel);
- }
+ PackageRelationship rel = relationshipsByID.get(id);
+ if (rel != null) {
+ relationshipsByID.remove(rel.getId());
+ relationshipsByType.values().remove(rel);
+ internalRelationshipsByTargetName.values().remove(rel);
}
}
@@ -413,28 +411,23 @@ public final class PackageRelationshipCo
@Override
public String toString() {
- String str;
- if (relationshipsByID == null) {
- str = "relationshipsByID=null";
- } else {
- str = relationshipsByID.size() + " relationship(s) = [";
- }
+ String str = relationshipsByID.size() + " relationship(s) = [";
if ((relationshipPart != null) && (relationshipPart._partName !=
null)) {
- str = str + "," + relationshipPart._partName;
+ str += relationshipPart._partName;
} else {
- str = str + ",relationshipPart=null";
+ str += "relationshipPart=null";
}
// Source of this relationship
if ((sourcePart != null) && (sourcePart._partName != null)) {
- str = str + "," + sourcePart._partName;
+ str += "," + sourcePart._partName;
} else {
- str = str + ",sourcePart=null";
+ str += ",sourcePart=null";
}
if (partName != null) {
- str = str + "," + partName;
+ str += "," + partName;
} else {
- str = str + ",uri=null)";
+ str += ",uri=null)";
}
return str + "]";
}
Modified:
poi/trunk/src/ooxml/java/org/apache/poi/poifs/crypt/dsig/SignatureInfo.java
URL:
http://svn.apache.org/viewvc/poi/trunk/src/ooxml/java/org/apache/poi/poifs/crypt/dsig/SignatureInfo.java?rev=1832735&r1=1832734&r2=1832735&view=diff
==============================================================================
--- poi/trunk/src/ooxml/java/org/apache/poi/poifs/crypt/dsig/SignatureInfo.java
(original)
+++ poi/trunk/src/ooxml/java/org/apache/poi/poifs/crypt/dsig/SignatureInfo.java
Sat Jun 2 13:01:14 2018
@@ -316,7 +316,7 @@ public class SignatureInfo implements Si
} catch (InvalidFormatException e) {
LOG.log(POILogger.WARN, "Reference to
signature is invalid.", e);
}
- } while (sigPart == null);
+ } while (sigRelPart == null);
return new SignaturePart(sigRelPart, signatureConfig);
}
Modified: poi/trunk/src/scratchpad/src/org/apache/poi/hpbf/model/HPBFPart.java
URL:
http://svn.apache.org/viewvc/poi/trunk/src/scratchpad/src/org/apache/poi/hpbf/model/HPBFPart.java?rev=1832735&r1=1832734&r2=1832735&view=diff
==============================================================================
--- poi/trunk/src/scratchpad/src/org/apache/poi/hpbf/model/HPBFPart.java
(original)
+++ poi/trunk/src/scratchpad/src/org/apache/poi/hpbf/model/HPBFPart.java Sat
Jun 2 13:01:14 2018
@@ -32,12 +32,15 @@ import org.apache.poi.util.IOUtils;
*/
public abstract class HPBFPart {
private byte[] data;
+ private final String[] path;
+
/**
* @param path the path to the part, eg Contents or Quill, QuillSub,
CONTENTS
*/
public HPBFPart(DirectoryNode baseDir, String[] path) throws
IOException {
+ this.path = path;
- DirectoryNode dir = getDir(path, baseDir);
+ DirectoryNode dir = getDir(baseDir, path);
String name = path[path.length-1];
if (!dir.hasEntry(name)) {
@@ -45,11 +48,12 @@ public abstract class HPBFPart {
}
// Grab the data from the part stream
- InputStream is = dir.createDocumentInputStream(name);
- data = IOUtils.toByteArray(is);
- is.close();
+ try (InputStream is = dir.createDocumentInputStream(name)) {
+ data = IOUtils.toByteArray(is);
+ }
}
- private DirectoryNode getDir(String[] path, DirectoryNode baseDir) {
+
+ private static DirectoryNode getDir(DirectoryNode baseDir, String[]
path) {
DirectoryNode dir = baseDir;
for(int i=0; i<path.length-1; i++) {
try {
@@ -64,9 +68,6 @@ public abstract class HPBFPart {
public void writeOut(DirectoryNode baseDir) throws IOException {
String[] path = getPath();
- if (path == null) {
- return;
- }
// Ensure that all parent directories exist
DirectoryNode dir = baseDir;
@@ -97,7 +98,9 @@ public abstract class HPBFPart {
* Returns the raw data that makes up
* this document part.
*/
- public final byte[] getData() { return data; }
+ public final byte[] getData() {
+ return data;
+ }
protected final void setData(byte data[]) {
this.data = data.clone();
@@ -106,5 +109,7 @@ public abstract class HPBFPart {
/**
* Returns
*/
- public final String[] getPath() {return null;}
+ public final String[] getPath() {
+ return path;
+ }
}
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]