From ebdd3c37d42166c1318f819b37af23eb1ebb6a2e Mon Sep 17 00:00:00 2001 From: Andreas Beeker Date: Sat, 24 Oct 2020 20:24:13 +0000 Subject: Sonar fixes - a few "String literals should not be duplicated" git-svn-id: https://svn.apache.org/repos/asf/poi/trunk@1882819 13f79535-47bb-0310-9956-ffa450edef68 --- .../org/apache/poi/poifs/crypt/EncryptionInfo.java | 2 +- src/java/org/apache/poi/sl/draw/SLGraphics.java | 80 +++++++--------------- .../openxml4j/opc/PackageRelationshipTypes.java | 4 +- .../poi/xslf/usermodel/XSLFGraphicFrame.java | 14 ++-- 4 files changed, 35 insertions(+), 65 deletions(-) (limited to 'src') diff --git a/src/java/org/apache/poi/poifs/crypt/EncryptionInfo.java b/src/java/org/apache/poi/poifs/crypt/EncryptionInfo.java index f02fb16d8c..30fc9539e3 100644 --- a/src/java/org/apache/poi/poifs/crypt/EncryptionInfo.java +++ b/src/java/org/apache/poi/poifs/crypt/EncryptionInfo.java @@ -102,7 +102,7 @@ public class EncryptionInfo implements GenericRecord { * Opens for decryption */ public EncryptionInfo(DirectoryNode dir) throws IOException { - this(dir.createDocumentInputStream("EncryptionInfo"), null); + this(dir.createDocumentInputStream(ENCRYPTION_INFO_ENTRY), null); } public EncryptionInfo(LittleEndianInput dis, EncryptionMode preferredEncryptionMode) throws IOException { diff --git a/src/java/org/apache/poi/sl/draw/SLGraphics.java b/src/java/org/apache/poi/sl/draw/SLGraphics.java index fada4c6431..dfd74444cd 100644 --- a/src/java/org/apache/poi/sl/draw/SLGraphics.java +++ b/src/java/org/apache/poi/sl/draw/SLGraphics.java @@ -383,9 +383,7 @@ public class SLGraphics extends Graphics2D implements Cloneable { */ @NotImplemented public void clip(Shape s){ - if (LOG.check(POILogger.WARN)) { - LOG.log(POILogger.WARN, "Not implemented"); - } + logNotImplemented(); } /** @@ -406,9 +404,7 @@ public class SLGraphics extends Graphics2D implements Cloneable { */ @NotImplemented public Shape getClip(){ - if (LOG.check(POILogger.WARN)) { - LOG.log(POILogger.WARN, "Not implemented"); - } + logNotImplemented(); return null; } @@ -675,10 +671,7 @@ public class SLGraphics extends Graphics2D implements Cloneable { public boolean drawImage(Image img, int x, int y, Color bgcolor, ImageObserver observer){ - if (LOG.check(POILogger.WARN)) { - LOG.log(POILogger.WARN, "Not implemented"); - } - + logNotImplemented(); return false; } @@ -725,10 +718,7 @@ public class SLGraphics extends Graphics2D implements Cloneable { int width, int height, Color bgcolor, ImageObserver observer){ - if (LOG.check(POILogger.WARN)) { - LOG.log(POILogger.WARN, "Not implemented"); - } - + logNotImplemented(); return false; } @@ -785,9 +775,7 @@ public class SLGraphics extends Graphics2D implements Cloneable { 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"); - } + logNotImplemented(); return false; } @@ -850,9 +838,7 @@ public class SLGraphics extends Graphics2D implements Cloneable { int sx1, int sy1, int sx2, int sy2, Color bgcolor, ImageObserver observer){ - if (LOG.check(POILogger.WARN)) { - LOG.log(POILogger.WARN, "Not implemented"); - } + logNotImplemented(); return false; } @@ -891,9 +877,7 @@ public class SLGraphics extends Graphics2D implements Cloneable { @NotImplemented public boolean drawImage(Image img, int x, int y, ImageObserver observer) { - if (LOG.check(POILogger.WARN)) { - LOG.log(POILogger.WARN, "Not implemented"); - } + logNotImplemented(); return false; } @@ -1078,9 +1062,7 @@ public class SLGraphics extends Graphics2D implements Cloneable { */ @NotImplemented public void setClip(Shape clip) { - if (LOG.check(POILogger.WARN)) { - LOG.log(POILogger.WARN, "Not implemented"); - } + logNotImplemented(); } /** @@ -1101,9 +1083,7 @@ public class SLGraphics extends Graphics2D implements Cloneable { * @since JDK1.1 */ public Rectangle getClipBounds(){ - if (LOG.check(POILogger.WARN)) { - LOG.log(POILogger.WARN, "Not implemented"); - } + logNotImplemented(); return null; } @@ -1377,9 +1357,7 @@ public class SLGraphics extends Graphics2D implements Cloneable { */ @NotImplemented public void setComposite(Composite comp){ - if (LOG.check(POILogger.WARN)) { - LOG.log(POILogger.WARN, "Not implemented"); - } + logNotImplemented(); } /** @@ -1391,9 +1369,7 @@ public class SLGraphics extends Graphics2D implements Cloneable { */ @NotImplemented public Composite getComposite(){ - if (LOG.check(POILogger.WARN)) { - LOG.log(POILogger.WARN, "Not implemented"); - } + logNotImplemented(); return null; } @@ -1535,9 +1511,7 @@ public class SLGraphics extends Graphics2D implements Cloneable { */ @NotImplemented public void drawString(AttributedCharacterIterator iterator, float x, float y) { - if (LOG.check(POILogger.WARN)) { - LOG.log(POILogger.WARN, "Not implemented"); - } + logNotImplemented(); } /** @@ -1642,9 +1616,7 @@ public class SLGraphics extends Graphics2D implements Cloneable { */ @NotImplemented public boolean drawImage(Image img, AffineTransform xform, ImageObserver obs) { - if (LOG.check(POILogger.WARN)) { - LOG.log(POILogger.WARN, "Not implemented"); - } + logNotImplemented(); return false; } @@ -1688,9 +1660,7 @@ public class SLGraphics extends Graphics2D implements Cloneable { 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"); - } + logNotImplemented(); return false; } @@ -1739,9 +1709,7 @@ public class SLGraphics extends Graphics2D implements Cloneable { */ @NotImplemented public void setXORMode(Color c1) { - if (LOG.check(POILogger.WARN)) { - LOG.log(POILogger.WARN, "Not implemented"); - } + logNotImplemented(); } /** @@ -1753,9 +1721,7 @@ public class SLGraphics extends Graphics2D implements Cloneable { */ @NotImplemented public void setPaintMode() { - if (LOG.check(POILogger.WARN)) { - LOG.log(POILogger.WARN, "Not implemented"); - } + logNotImplemented(); } /** @@ -1791,9 +1757,7 @@ public class SLGraphics extends Graphics2D implements Cloneable { */ @NotImplemented public void drawRenderedImage(RenderedImage img, AffineTransform xform) { - if (LOG.check(POILogger.WARN)) { - LOG.log(POILogger.WARN, "Not implemented"); - } + logNotImplemented(); } /** @@ -1819,9 +1783,7 @@ public class SLGraphics extends Graphics2D implements Cloneable { */ @NotImplemented public void drawRenderableImage(RenderableImage img, AffineTransform xform) { - if (LOG.check(POILogger.WARN)) { - LOG.log(POILogger.WARN, "Not implemented"); - } + logNotImplemented(); } protected void applyStroke(SimpleShape shape) { @@ -1841,4 +1803,10 @@ public class SLGraphics extends Graphics2D implements Cloneable { shape.setFillColor((Color)_paint); } } + + private void logNotImplemented() { + if (LOG.check(POILogger.WARN)) { + LOG.log(POILogger.WARN, "Not implemented"); + } + } } diff --git a/src/ooxml/java/org/apache/poi/openxml4j/opc/PackageRelationshipTypes.java b/src/ooxml/java/org/apache/poi/openxml4j/opc/PackageRelationshipTypes.java index b9cd553ba0..c328849e08 100644 --- a/src/ooxml/java/org/apache/poi/openxml4j/opc/PackageRelationshipTypes.java +++ b/src/ooxml/java/org/apache/poi/openxml4j/opc/PackageRelationshipTypes.java @@ -42,10 +42,10 @@ public interface PackageRelationshipTypes { String CORE_PROPERTIES_ECMA376 = "http://schemas.openxmlformats.org/officedocument/2006/relationships/metadata/core-properties"; /** - * Namespace of Core properties relationship type as defiend in ECMA 376 + * Namespace of Core properties relationship type as defined in ECMA 376 */ String CORE_PROPERTIES_ECMA376_NS = "http://schemas.openxmlformats.org/officeDocument/2006/relationships"; - + /** * Digital signature relationship type. */ diff --git a/src/ooxml/java/org/apache/poi/xslf/usermodel/XSLFGraphicFrame.java b/src/ooxml/java/org/apache/poi/xslf/usermodel/XSLFGraphicFrame.java index 9ae6c9f956..a57e0b7463 100644 --- a/src/ooxml/java/org/apache/poi/xslf/usermodel/XSLFGraphicFrame.java +++ b/src/ooxml/java/org/apache/poi/xslf/usermodel/XSLFGraphicFrame.java @@ -19,6 +19,8 @@ package org.apache.poi.xslf.usermodel; +import static org.apache.poi.openxml4j.opc.PackageRelationshipTypes.CORE_PROPERTIES_ECMA376_NS; + import java.awt.geom.Rectangle2D; import java.io.IOException; @@ -177,7 +179,7 @@ public class XSLFGraphicFrame extends XSLFShape implements GraphicalFrame