diff options
author | Andreas Beeker <kiwiwings@apache.org> | 2020-10-24 20:24:13 +0000 |
---|---|---|
committer | Andreas Beeker <kiwiwings@apache.org> | 2020-10-24 20:24:13 +0000 |
commit | ebdd3c37d42166c1318f819b37af23eb1ebb6a2e (patch) | |
tree | e71d62fa4a14291bb43cc5414ddcfc854fd06aa6 /src | |
parent | 0be61931616b3f1f02972c3aa08f043332f284c8 (diff) | |
download | poi-ebdd3c37d42166c1318f819b37af23eb1ebb6a2e.tar.gz poi-ebdd3c37d42166c1318f819b37af23eb1ebb6a2e.zip |
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
Diffstat (limited to 'src')
4 files changed, 35 insertions, 65 deletions
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<XSLFSh XmlObject[] obj = getGraphicalData().selectPath(xpath); if (obj != null && obj.length == 1) { XmlCursor c = obj[0].newCursor(); - QName idQualifiedName = new QName("http://schemas.openxmlformats.org/officeDocument/2006/relationships", "id"); + QName idQualifiedName = new QName(CORE_PROPERTIES_ECMA376_NS, "id"); id = c.getAttributeText(idQualifiedName); c.dispose(); } @@ -216,7 +218,7 @@ public class XSLFGraphicFrame extends XSLFShape implements GraphicalFrame<XSLFSh XmlCursor c = obj[0].newCursor(); try { // duplicate chart with embedded workbook - QName idQualifiedName = new QName("http://schemas.openxmlformats.org/officeDocument/2006/relationships", "id"); + QName idQualifiedName = new QName(CORE_PROPERTIES_ECMA376_NS, "id"); String id = c.getAttributeText(idQualifiedName); XSLFChart srcChart = (XSLFChart) src.getRelationById(id); XSLFChart chartCopy = slide.getSlideShow().createChart(slide); @@ -239,22 +241,22 @@ public class XSLFGraphicFrame extends XSLFShape implements GraphicalFrame<XSLFSh XSLFSheet sheet = srcShape.getSheet(); try { - String dm = c.getAttributeText(new QName("http://schemas.openxmlformats.org/officeDocument/2006/relationships", "dm")); + String dm = c.getAttributeText(new QName(CORE_PROPERTIES_ECMA376_NS, "dm")); PackageRelationship dmRel = sheet.getPackagePart().getRelationship(dm); PackagePart dmPart = sheet.getPackagePart().getRelatedPart(dmRel); getSheet().importPart(dmRel, dmPart); - String lo = c.getAttributeText(new QName("http://schemas.openxmlformats.org/officeDocument/2006/relationships", "lo")); + String lo = c.getAttributeText(new QName(CORE_PROPERTIES_ECMA376_NS, "lo")); PackageRelationship loRel = sheet.getPackagePart().getRelationship(lo); PackagePart loPart = sheet.getPackagePart().getRelatedPart(loRel); getSheet().importPart(loRel, loPart); - String qs = c.getAttributeText(new QName("http://schemas.openxmlformats.org/officeDocument/2006/relationships", "qs")); + String qs = c.getAttributeText(new QName(CORE_PROPERTIES_ECMA376_NS, "qs")); PackageRelationship qsRel = sheet.getPackagePart().getRelationship(qs); PackagePart qsPart = sheet.getPackagePart().getRelatedPart(qsRel); getSheet().importPart(qsRel, qsPart); - String cs = c.getAttributeText(new QName("http://schemas.openxmlformats.org/officeDocument/2006/relationships", "cs")); + String cs = c.getAttributeText(new QName(CORE_PROPERTIES_ECMA376_NS, "cs")); PackageRelationship csRel = sheet.getPackagePart().getRelationship(cs); PackagePart csPart = sheet.getPackagePart().getRelatedPart(csRel); getSheet().importPart(csRel, csPart); |