aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorAndreas Beeker <kiwiwings@apache.org>2015-10-12 20:43:42 +0000
committerAndreas Beeker <kiwiwings@apache.org>2015-10-12 20:43:42 +0000
commit86c72f59dabff2653a5d5ef2caf441e899665eb4 (patch)
tree8806fc40a457c810df0a3046de7f7a147c1ab8bc
parent5735e23853c6e79529f96771ee20c97b2341a9e2 (diff)
downloadpoi-86c72f59dabff2653a5d5ef2caf441e899665eb4.tar.gz
poi-86c72f59dabff2653a5d5ef2caf441e899665eb4.zip
- removed deprecated and confusing methods in XSSFColor
- sonar fixes git-svn-id: https://svn.apache.org/repos/asf/poi/trunk@1708236 13f79535-47bb-0310-9956-ffa450edef68
-rw-r--r--src/examples/src/org/apache/poi/ss/examples/html/ToHtml.java2
-rw-r--r--src/examples/src/org/apache/poi/ss/examples/html/XSSFHtmlHelper.java18
-rw-r--r--src/java/org/apache/poi/hssf/usermodel/DummyGraphics2d.java1022
-rw-r--r--src/java/org/apache/poi/hssf/usermodel/StaticFontMetrics.java118
-rw-r--r--src/java/org/apache/poi/ss/usermodel/FractionFormat.java26
-rw-r--r--src/ooxml/java/org/apache/poi/openxml4j/exceptions/InvalidFormatException.java4
-rw-r--r--src/ooxml/java/org/apache/poi/openxml4j/exceptions/OpenXML4JException.java4
-rw-r--r--src/ooxml/java/org/apache/poi/openxml4j/opc/OPCPackage.java90
-rw-r--r--src/ooxml/java/org/apache/poi/xssf/usermodel/XSSFColor.java52
-rw-r--r--src/ooxml/testcases/org/apache/poi/xssf/usermodel/TestXSSFBugs.java244
-rw-r--r--src/ooxml/testcases/org/apache/poi/xssf/usermodel/TestXSSFCellStyle.java248
-rw-r--r--src/ooxml/testcases/org/apache/poi/xssf/usermodel/TestXSSFColor.java115
-rw-r--r--src/ooxml/testcases/org/apache/poi/xssf/usermodel/extensions/TestXSSFCellFill.java25
-rw-r--r--src/scratchpad/src/org/apache/poi/hwpf/extractor/Word6Extractor.java4
-rw-r--r--src/testcases/org/apache/poi/hssf/usermodel/TestEscherGraphics.java48
-rw-r--r--src/testcases/org/apache/poi/hssf/usermodel/TestEscherGraphics2d.java58
-rw-r--r--src/testcases/org/apache/poi/ss/usermodel/BaseTestBugzillaIssues.java44
17 files changed, 1175 insertions, 947 deletions
diff --git a/src/examples/src/org/apache/poi/ss/examples/html/ToHtml.java b/src/examples/src/org/apache/poi/ss/examples/html/ToHtml.java
index bcfb5dffe6..74e129eee5 100644
--- a/src/examples/src/org/apache/poi/ss/examples/html/ToHtml.java
+++ b/src/examples/src/org/apache/poi/ss/examples/html/ToHtml.java
@@ -149,7 +149,7 @@ public class ToHtml {
if (wb instanceof HSSFWorkbook)
helper = new HSSFHtmlHelper((HSSFWorkbook) wb);
else if (wb instanceof XSSFWorkbook)
- helper = new XSSFHtmlHelper((XSSFWorkbook) wb);
+ helper = new XSSFHtmlHelper();
else
throw new IllegalArgumentException(
"unknown workbook type: " + wb.getClass().getSimpleName());
diff --git a/src/examples/src/org/apache/poi/ss/examples/html/XSSFHtmlHelper.java b/src/examples/src/org/apache/poi/ss/examples/html/XSSFHtmlHelper.java
index 0fe76d17be..9b22e1ed04 100644
--- a/src/examples/src/org/apache/poi/ss/examples/html/XSSFHtmlHelper.java
+++ b/src/examples/src/org/apache/poi/ss/examples/html/XSSFHtmlHelper.java
@@ -17,13 +17,10 @@
package org.apache.poi.ss.examples.html;
import java.util.Formatter;
-import java.util.Map;
-import org.apache.poi.hssf.util.HSSFColor;
import org.apache.poi.ss.usermodel.CellStyle;
import org.apache.poi.xssf.usermodel.XSSFCellStyle;
import org.apache.poi.xssf.usermodel.XSSFColor;
-import org.apache.poi.xssf.usermodel.XSSFWorkbook;
/**
* Implementation of {@link HtmlHelper} for XSSF files.
@@ -31,14 +28,6 @@ import org.apache.poi.xssf.usermodel.XSSFWorkbook;
* @author Ken Arnold, Industrious Media LLC
*/
public class XSSFHtmlHelper implements HtmlHelper {
- private final XSSFWorkbook wb;
-
- private static final Map<Integer,HSSFColor> colors = HSSFColor.getIndexHash();
-
- public XSSFHtmlHelper(XSSFWorkbook wb) {
- this.wb = wb;
- }
-
public void colorStyles(CellStyle style, Formatter out) {
XSSFCellStyle cs = (XSSFCellStyle) style;
styleColor(out, "background-color", cs.getFillForegroundXSSFColor());
@@ -46,10 +35,11 @@ public class XSSFHtmlHelper implements HtmlHelper {
}
private void styleColor(Formatter out, String attr, XSSFColor color) {
- if (color == null || color.isAuto())
+ if (color == null || color.isAuto()) {
return;
+ }
- byte[] rgb = color.getRgb();
+ byte[] rgb = color.getRGB();
if (rgb == null) {
return;
}
@@ -58,7 +48,7 @@ public class XSSFHtmlHelper implements HtmlHelper {
// support it will ignore the rgba specification and stick with the
// solid color, which is declared first
out.format(" %s: #%02x%02x%02x;%n", attr, rgb[0], rgb[1], rgb[2]);
- byte[] argb = color.getARgb();
+ byte[] argb = color.getARGB();
if (argb == null) {
return;
}
diff --git a/src/java/org/apache/poi/hssf/usermodel/DummyGraphics2d.java b/src/java/org/apache/poi/hssf/usermodel/DummyGraphics2d.java
index 3baefb6913..cfe5bf6c9e 100644
--- a/src/java/org/apache/poi/hssf/usermodel/DummyGraphics2d.java
+++ b/src/java/org/apache/poi/hssf/usermodel/DummyGraphics2d.java
@@ -18,7 +18,21 @@
package org.apache.poi.hssf.usermodel;
-import java.awt.*;
+import java.awt.BasicStroke;
+import java.awt.Color;
+import java.awt.Composite;
+import java.awt.Font;
+import java.awt.FontMetrics;
+import java.awt.Graphics;
+import java.awt.Graphics2D;
+import java.awt.GraphicsConfiguration;
+import java.awt.Image;
+import java.awt.Paint;
+import java.awt.Polygon;
+import java.awt.Rectangle;
+import java.awt.RenderingHints;
+import java.awt.Shape;
+import java.awt.Stroke;
import java.awt.font.FontRenderContext;
import java.awt.font.GlyphVector;
import java.awt.geom.AffineTransform;
@@ -27,775 +41,785 @@ import java.awt.image.BufferedImageOp;
import java.awt.image.ImageObserver;
import java.awt.image.RenderedImage;
import java.awt.image.renderable.RenderableImage;
+import java.io.PrintStream;
import java.text.AttributedCharacterIterator;
import java.util.Arrays;
import java.util.Map;
-public class DummyGraphics2d
- extends Graphics2D
-{
+public class DummyGraphics2d extends Graphics2D {
private BufferedImage bufimg;
- private Graphics2D g2D;
+ private final Graphics2D g2D;
+ private final PrintStream log;
- public DummyGraphics2d()
- {
+ public DummyGraphics2d() {
+ this(System.out);
+ }
+
+ public DummyGraphics2d(PrintStream log) {
bufimg = new BufferedImage(1000, 1000, 2);
g2D = (Graphics2D)bufimg.getGraphics();
+ this.log = log;
+ }
+
+ public DummyGraphics2d(PrintStream log, Graphics2D g2D) {
+ this.g2D = g2D;
+ this.log = log;
}
- public void addRenderingHints(Map<?,?> hints)
- {
- System.out.println( "addRenderingHinds(Map):" );
- System.out.println( " hints = " + hints );
+ public void addRenderingHints(Map<?,?> hints) {
+ String l =
+ "addRenderingHinds(Map):" +
+ "\n hints = " + hints;
+ log.println( l );
g2D.addRenderingHints( hints );
}
- public void clip(Shape s)
- {
- System.out.println( "clip(Shape):" );
- System.out.println( " s = " + s );
+ public void clip(Shape s) {
+ String l =
+ "clip(Shape):" +
+ "\n s = " + s;
+ log.println( l );
g2D.clip( s );
}
- public void draw(Shape s)
- {
- System.out.println( "draw(Shape):" );
- System.out.println( "s = " + s );
+ public void draw(Shape s) {
+ String l =
+ "draw(Shape):" +
+ "\n s = " + s;
+ log.println( l );
g2D.draw( s );
}
- public void drawGlyphVector(GlyphVector g, float x, float y)
- {
- System.out.println( "drawGlyphVector(GlyphVector, float, float):" );
- System.out.println( "g = " + g );
- System.out.println( "x = " + x );
- System.out.println( "y = " + y );
+ public void drawGlyphVector(GlyphVector g, float x, float y) {
+ String l =
+ "drawGlyphVector(GlyphVector, float, float):" +
+ "\n g = " + g +
+ "\n x = " + x +
+ "\n y = " + y;
+ log.println( l );
g2D.drawGlyphVector( g, x, y );
}
- public void drawImage(BufferedImage img,
- BufferedImageOp op,
- int x,
- int y)
- {
- System.out.println( "drawImage(BufferedImage, BufferedImageOp, x, y):" );
- System.out.println( "img = " + img );
- System.out.println( "op = " + op );
- System.out.println( "x = " + x );
- System.out.println( "y = " + y );
+ public void drawImage(BufferedImage img, BufferedImageOp op, int x, int y) {
+ String l =
+ "drawImage(BufferedImage, BufferedImageOp, x, y):" +
+ "\n img = " + img +
+ "\n op = " + op +
+ "\n x = " + x +
+ "\n y = " + y;
+ log.println( l );
g2D.drawImage( img, op, x, y );
}
- public boolean drawImage(Image img,
- AffineTransform xform,
- ImageObserver obs)
- {
- System.out.println( "drawImage(Image,AfflineTransform,ImageObserver):" );
- System.out.println( "img = " + img );
- System.out.println( "xform = " + xform );
- System.out.println( "obs = " + obs );
+ public boolean drawImage(Image img, AffineTransform xform, ImageObserver obs) {
+ String l =
+ "drawImage(Image,AfflineTransform,ImageObserver):" +
+ "\n img = " + img +
+ "\n xform = " + xform +
+ "\n obs = " + obs;
+ log.println( l );
return g2D.drawImage( img, xform, obs );
}
- public void drawRenderableImage(RenderableImage img,
- AffineTransform xform)
- {
- System.out.println( "drawRenderableImage(RenderableImage, AfflineTransform):" );
- System.out.println( "img = " + img );
- System.out.println( "xform = " + xform );
+ public void drawRenderableImage(RenderableImage img, AffineTransform xform) {
+ String l =
+ "drawRenderableImage(RenderableImage, AfflineTransform):" +
+ "\n img = " + img +
+ "\n xform = " + xform;
+ log.println( l );
g2D.drawRenderableImage( img, xform );
}
- public void drawRenderedImage(RenderedImage img,
- AffineTransform xform)
- {
- System.out.println( "drawRenderedImage(RenderedImage, AffineTransform):" );
- System.out.println( "img = " + img );
- System.out.println( "xform = " + xform );
+ public void drawRenderedImage(RenderedImage img, AffineTransform xform) {
+ String l =
+ "drawRenderedImage(RenderedImage, AffineTransform):" +
+ "\n img = " + img +
+ "\n xform = " + xform;
+ log.println( l );
g2D.drawRenderedImage( img, xform );
}
- public void drawString(AttributedCharacterIterator iterator,
- float x, float y)
- {
- System.out.println( "drawString(AttributedCharacterIterator):" );
- System.out.println( "iterator = " + iterator );
- System.out.println( "x = " + x );
- System.out.println( "y = " + y );
+ public void drawString(AttributedCharacterIterator iterator, float x, float y) {
+ String l =
+ "drawString(AttributedCharacterIterator):" +
+ "\n iterator = " + iterator +
+ "\n x = " + x +
+ "\n y = " + y;
+ log.println( l );
g2D.drawString( iterator, x, y );
}
-// public void drawString(AttributedCharacterIterator iterator,
-// int x, int y)
-// {
-// g2D.drawString( iterator, x, y );
-// }
-
- public void drawString(String s, float x, float y)
- {
- System.out.println( "drawString(s,x,y):" );
- System.out.println( "s = " + s );
- System.out.println( "x = " + x );
- System.out.println( "y = " + y );
+ public void drawString(String s, float x, float y) {
+ String l =
+ "drawString(s,x,y):" +
+ "\n s = " + s +
+ "\n x = " + x +
+ "\n y = " + y;
+ log.println( l );
g2D.drawString( s, x, y );
}
-// public void drawString(String str, int x, int y)
-// {
-// g2D.drawString( str, x, y );
-// }
-
- public void fill(Shape s)
- {
- System.out.println( "fill(Shape):" );
- System.out.println( "s = " + s );
+ public void fill(Shape s) {
+ String l =
+ "fill(Shape):" +
+ "\n s = " + s;
+ log.println( l );
g2D.fill( s );
}
-// public void fill3DRect(int x, int y, int width, int height,
-// boolean raised) {
-// g2D.fill3DRect( x, y, width, height, raised );
-// }
-
- public Color getBackground()
- {
- System.out.println( "getBackground():" );
+ public Color getBackground() {
+ log.println( "getBackground():" );
return g2D.getBackground();
}
- public Composite getComposite()
- {
- System.out.println( "getComposite():" );
+ public Composite getComposite() {
+ log.println( "getComposite():" );
return g2D.getComposite();
}
- public GraphicsConfiguration getDeviceConfiguration()
- {
- System.out.println( "getDeviceConfiguration():" );
+ public GraphicsConfiguration getDeviceConfiguration() {
+ log.println( "getDeviceConfiguration():" );
return g2D.getDeviceConfiguration();
}
- public FontRenderContext getFontRenderContext()
- {
- System.out.println( "getFontRenderContext():" );
+ public FontRenderContext getFontRenderContext() {
+ log.println( "getFontRenderContext():" );
return g2D.getFontRenderContext();
}
- public Paint getPaint()
- {
- System.out.println( "getPaint():" );
+ public Paint getPaint() {
+ log.println( "getPaint():" );
return g2D.getPaint();
}
- public Object getRenderingHint(RenderingHints.Key hintKey)
- {
- System.out.println( "getRenderingHint(RenderingHints.Key):" );
- System.out.println( "hintKey = " + hintKey );
+ public Object getRenderingHint(RenderingHints.Key hintKey) {
+ String l =
+ "getRenderingHint(RenderingHints.Key):" +
+ "\n hintKey = " + hintKey;
+ log.println( l );
return g2D.getRenderingHint( hintKey );
}
- public RenderingHints getRenderingHints()
- {
- System.out.println( "getRenderingHints():" );
+ public RenderingHints getRenderingHints() {
+ log.println( "getRenderingHints():" );
return g2D.getRenderingHints();
}
- public Stroke getStroke()
- {
- System.out.println( "getStroke():" );
+ public Stroke getStroke() {
+ log.println( "getStroke():" );
return g2D.getStroke();
}
- public AffineTransform getTransform()
- {
- System.out.println( "getTransform():" );
+ public AffineTransform getTransform() {
+ log.println( "getTransform():" );
return g2D.getTransform();
}
- public boolean hit(Rectangle rect,
- Shape s,
- boolean onStroke)
- {
- System.out.println( "hit(Rectangle, Shape, onStroke):" );
- System.out.println( "rect = " + rect );
- System.out.println( "s = " + s );
- System.out.println( "onStroke = " + onStroke );
+ public boolean hit(Rectangle rect, Shape s, boolean onStroke) {
+ String l =
+ "hit(Rectangle, Shape, onStroke):" +
+ "\n rect = " + rect +
+ "\n s = " + s +
+ "\n onStroke = " + onStroke;
+ log.println( l );
return g2D.hit( rect, s, onStroke );
}
- public void rotate(double theta)
- {
- System.out.println( "rotate(theta):" );
- System.out.println( "theta = " + theta );
+ public void rotate(double theta) {
+ String l =
+ "rotate(theta):" +
+ "\n theta = " + theta;
+ log.println( l );
g2D.rotate( theta );
}
- public void rotate(double theta, double x, double y)
- {
- System.out.println( "rotate(double,double,double):" );
- System.out.println( "theta = " + theta );
- System.out.println( "x = " + x );
- System.out.println( "y = " + y );
+ public void rotate(double theta, double x, double y) {
+ String l =
+ "rotate(double,double,double):" +
+ "\n theta = " + theta +
+ "\n x = " + x +
+ "\n y = " + y;
+ log.println( l );
g2D.rotate( theta, x, y );
}
- public void scale(double sx, double sy)
- {
- System.out.println( "scale(double,double):" );
- System.out.println( "sx = " + sx );
- System.out.println( "sy" );
+ public void scale(double sx, double sy) {
+ String l =
+ "scale(double,double):" +
+ "\n sx = " + sx +
+ "\n sy";
+ log.println( l );
g2D.scale( sx, sy );
}
- public void setBackground(Color color)
- {
- System.out.println( "setBackground(Color):" );
- System.out.println( "color = " + color );
+ public void setBackground(Color color) {
+ String l =
+ "setBackground(Color):" +
+ "\n color = " + color;
+ log.println( l );
g2D.setBackground( color );
}
- public void setComposite(Composite comp)
- {
- System.out.println( "setComposite(Composite):" );
- System.out.println( "comp = " + comp );
+ public void setComposite(Composite comp) {
+ String l =
+ "setComposite(Composite):" +
+ "\n comp = " + comp;
+ log.println( l );
g2D.setComposite( comp );
}
- public void setPaint( Paint paint )
- {
- System.out.println( "setPaint(Paint):" );
- System.out.println( "paint = " + paint );
+ public void setPaint( Paint paint ) {
+ String l =
+ "setPaint(Paint):" +
+ "\n paint = " + paint;
+ log.println( l );
g2D.setPaint( paint );
}
- public void setRenderingHint(RenderingHints.Key hintKey, Object hintValue)
- {
- System.out.println( "setRenderingHint(RenderingHints.Key, Object):" );
- System.out.println( "hintKey = " + hintKey );
- System.out.println( "hintValue = " + hintValue );
+ public void setRenderingHint(RenderingHints.Key hintKey, Object hintValue) {
+ String l =
+ "setRenderingHint(RenderingHints.Key, Object):" +
+ "\n hintKey = " + hintKey +
+ "\n hintValue = " + hintValue;
+ log.println( l );
g2D.setRenderingHint( hintKey, hintValue );
}
- public void setRenderingHints(Map<?,?> hints)
- {
- System.out.println( "setRenderingHints(Map):" );
- System.out.println( "hints = " + hints );
+ public void setRenderingHints(Map<?,?> hints) {
+ String l =
+ "setRenderingHints(Map):" +
+ "\n hints = " + hints;
+ log.println( l );
g2D.setRenderingHints( hints );
}
- public void setStroke(Stroke s)
- {
- System.out.println( "setStroke(Stoke):" );
+ public void setStroke(Stroke s) {
+ String l;
if (s instanceof BasicStroke) {
BasicStroke bs = (BasicStroke)s;
- StringBuilder str = new StringBuilder("s = BasicStroke(");
- str.append("dash[]: "+Arrays.toString(bs.getDashArray())+", ");
- str.append("dashPhase: "+bs.getDashPhase()+", ");
- str.append("endCap: "+bs.getEndCap()+", ");
- str.append("lineJoin: "+bs.getLineJoin()+", ");
- str.append("width: "+bs.getLineWidth()+", ");
- str.append("miterLimit: "+bs.getMiterLimit()+")");
- System.out.println(str.toString());
+ l = "setStroke(Stoke):" +
+ "\n s = BasicStroke(" +
+ "\n dash[]: "+Arrays.toString(bs.getDashArray()) +
+ "\n dashPhase: "+bs.getDashPhase() +
+ "\n endCap: "+bs.getEndCap() +
+ "\n lineJoin: "+bs.getLineJoin() +
+ "\n width: "+bs.getLineWidth() +
+ "\n miterLimit: "+bs.getMiterLimit() +
+ "\n )";
} else {
- System.out.println( "s = " + s );
+ l = "setStroke(Stoke):" +
+ "\n s = " + s;
}
+ log.println( l );
g2D.setStroke( s );
}
- public void setTransform(AffineTransform Tx)
- {
- System.out.println( "setTransform():" );
- System.out.println( "Tx = " + Tx );
+ public void setTransform(AffineTransform Tx) {
+ String l =
+ "setTransform():" +
+ "\n Tx = " + Tx;
+ log.println( l );
g2D.setTransform( Tx );
}
- public void shear(double shx, double shy)
- {
- System.out.println( "shear(shx, dhy):" );
- System.out.println( "shx = " + shx );
- System.out.println( "shy = " + shy );
+ public void shear(double shx, double shy) {
+ String l =
+ "shear(shx, dhy):" +
+ "\n shx = " + shx +
+ "\n shy = " + shy;
+ log.println( l );
g2D.shear( shx, shy );
}
- public void transform(AffineTransform Tx)
- {
- System.out.println( "transform(AffineTransform):" );
- System.out.println( "Tx = " + Tx );
+ public void transform(AffineTransform Tx) {
+ String l =
+ "transform(AffineTransform):" +
+ "\n Tx = " + Tx;
+ log.println( l );
g2D.transform( Tx );
}
- public void translate(double tx, double ty)
- {
- System.out.println( "translate(double, double):" );
- System.out.println( "tx = " + tx );
- System.out.println( "ty = " + ty );
+ public void translate(double tx, double ty) {
+ String l =
+ "translate(double, double):" +
+ "\n tx = " + tx +
+ "\n ty = " + ty;
+ log.println( l );
g2D.translate( tx, ty );
}
-// public void translate(int x, int y)
-// {
-// g2D.translate( x, y );
-// }
-
- public void clearRect(int x, int y, int width, int height)
- {
- System.out.println( "clearRect(int,int,int,int):" );
- System.out.println( "x = " + x );
- System.out.println( "y = " + y );
- System.out.println( "width = " + width );
- System.out.println( "height = " + height );
+ public void clearRect(int x, int y, int width, int height) {
+ String l =
+ "clearRect(int,int,int,int):" +
+ "\n x = " + x +
+ "\n y = " + y +
+ "\n width = " + width +
+ "\n height = " + height;
+ log.println( l );
g2D.clearRect( x, y, width, height );
}
- public void clipRect(int x, int y, int width, int height)
- {
- System.out.println( "clipRect(int, int, int, int):" );
- System.out.println( "x = " + x );
- System.out.println( "y = " + y );
- System.out.println( "width = " + width );
- System.out.println( "height = " + height );
+ public void clipRect(int x, int y, int width, int height) {
+ String l =
+ "clipRect(int, int, int, int):" +
+ "\n x = " + x +
+ "\n y = " + y +
+ "\n width = " + width +
+ "height = " + height;
+ log.println( l );
g2D.clipRect( x, y, width, height );
}
- public void copyArea(int x, int y, int width, int height,
- int dx, int dy)
- {
- System.out.println( "copyArea(int,int,int,int):" );
- System.out.println( "x = " + x );
- System.out.println( "y = " + y );
- System.out.println( "width = " + width );
- System.out.println( "height = " + height );
+ public void copyArea(int x, int y, int width, int height, int dx, int dy) {
+ String l =
+ "copyArea(int,int,int,int):" +
+ "\n x = " + x +
+ "\n y = " + y +
+ "\n width = " + width +
+ "\n height = " + height;
+ log.println( l );
g2D.copyArea( x, y, width, height, dx, dy );
}
- public Graphics create()
- {
- System.out.println( "create():" );
+ public Graphics create() {
+ log.println( "create():" );
return g2D.create();
}
public Graphics create(int x, int y, int width, int height) {
- System.out.println( "create(int,int,int,int):" );
- System.out.println( "x = " + x );
- System.out.println( "y = " + y );
- System.out.println( "width = " + width );
- System.out.println( "height = " + height );
+ String l =
+ "create(int,int,int,int):" +
+ "\n x = " + x +
+ "\n y = " + y +
+ "\n width = " + width +
+ "\n height = " + height;
+ log.println( l );
return g2D.create( x, y, width, height );
}
- public void dispose()
- {
- System.out.println( "dispose():" );
+ public void dispose() {
+ log.println( "dispose():" );
g2D.dispose();
}
- public void draw3DRect(int x, int y, int width, int height,
- boolean raised) {
- System.out.println( "draw3DRect(int,int,int,int,boolean):" );
- System.out.println( "x = " + x );
- System.out.println( "y = " + y );
- System.out.println( "width = " + width );
- System.out.println( "height = " + height );
- System.out.println( "raised = " + raised );
+ public void draw3DRect(int x, int y, int width, int height, boolean raised) {
+ String l =
+ "draw3DRect(int,int,int,int,boolean):" +
+ "\n x = " + x +
+ "\n y = " + y +
+ "\n width = " + width +
+ "\n height = " + height +
+ "\n raised = " + raised;
+ log.println( l );
g2D.draw3DRect( x, y, width, height, raised );
}
- public void drawArc(int x, int y, int width, int height,
- int startAngle, int arcAngle)
- {
- System.out.println( "drawArc(int,int,int,int,int,int):" );
- System.out.println( "x = " + x );
- System.out.println( "y = " + y );
- System.out.println( "width = " + width );
- System.out.println( "height = " + height );
- System.out.println( "startAngle = " + startAngle );
- System.out.println( "arcAngle = " + arcAngle );
+ public void drawArc(int x, int y, int width, int height, int startAngle, int arcAngle) {
+ String l =
+ "drawArc(int,int,int,int,int,int):" +
+ "\n x = " + x +
+ "\n y = " + y +
+ "\n width = " + width +
+ "\n height = " + height +
+ "\n startAngle = " + startAngle +
+ "\n arcAngle = " + arcAngle;
+ log.println( l );
g2D.drawArc( x, y, width, height, startAngle, arcAngle );
}
public void drawBytes(byte data[], int offset, int length, int x, int y) {
- System.out.println( "drawBytes(byte[],int,int,int,int):" );
- System.out.println( "data = " + Arrays.toString(data) );
- System.out.println( "offset = " + offset );
- System.out.println( "length = " + length );
- System.out.println( "x = " + x );
- System.out.println( "y = " + y );
+ String l =
+ "drawBytes(byte[],int,int,int,int):" +
+ "\n data = " + Arrays.toString(data) +
+ "\n offset = " + offset +
+ "\n length = " + length +
+ "\n x = " + x +
+ "\n y = " + y;
+ log.println( l );
g2D.drawBytes( data, offset, length, x, y );
}
public void drawChars(char data[], int offset, int length, int x, int y) {
- System.out.println( "drawChars(data,int,int,int,int):" );
- System.out.println( "data = " + Arrays.toString(data) );
- System.out.println( "offset = " + offset );
- System.out.println( "length = " + length );
- System.out.println( "x = " + x );
- System.out.println( "y = " + y );
+ String l =
+ "drawChars(data,int,int,int,int):" +
+ "\n data = " + Arrays.toString(data) +
+ "\n offset = " + offset +
+ "\n length = " + length +
+ "\n x = " + x +
+ "\n y = " + y;
+ log.println( l );
g2D.drawChars( data, offset, length, x, y );
}
- public boolean drawImage(Image img,
- int dx1, int dy1, int dx2, int dy2,
- int sx1, int sy1, int sx2, int sy2,
- ImageObserver observer)
- {
- System.out.println( "drawImage(Image,int,int,int,int,int,int,int,int,ImageObserver):" );
- System.out.println( "img = " + img );
- System.out.println( "dx1 = " + dx1 );
- System.out.println( "dy1 = " + dy1 );
- System.out.println( "dx2 = " + dx2 );
- System.out.println( "dy2 = " + dy2 );
- System.out.println( "sx1 = " + sx1 );
- System.out.println( "sy1 = " + sy1 );
- System.out.println( "sx2 = " + sx2 );
- System.out.println( "sy2 = " + sy2 );
- System.out.println( "observer = " + observer );
+ public boolean drawImage(Image img, int dx1, int dy1, int dx2, int dy2, int sx1, int sy1, int sx2, int sy2, ImageObserver observer) {
+ String l =
+ "drawImage(Image,int,int,int,int,int,int,int,int,ImageObserver):" +
+ "\n img = " + img +
+ "\n dx1 = " + dx1 +
+ "\n dy1 = " + dy1 +
+ "\n dx2 = " + dx2 +
+ "\n dy2 = " + dy2 +
+ "\n sx1 = " + sx1 +
+ "\n sy1 = " + sy1 +
+ "\n sx2 = " + sx2 +
+ "\n sy2 = " + sy2 +
+ "\n observer = " + observer;
+ log.println( l );
return g2D.drawImage( img, dx1, dy1, dx2, dy2, sx1, sy1, sx2, sy2, observer );
}
- public boolean drawImage(Image img,
- int dx1, int dy1, int dx2, int dy2,
- int sx1, int sy1, int sx2, int sy2,
- Color bgcolor,
- ImageObserver observer)
- {
- System.out.println( "drawImage(Image,int,int,int,int,int,int,int,int,Color,ImageObserver):" );
- System.out.println( "img = " + img );
- System.out.println( "dx1 = " + dx1 );
- System.out.println( "dy1 = " + dy1 );
- System.out.println( "dx2 = " + dx2 );
- System.out.println( "dy2 = " + dy2 );
- System.out.println( "sx1 = " + sx1 );
- System.out.println( "sy1 = " + sy1 );
- System.out.println( "sx2 = " + sx2 );
- System.out.println( "sy2 = " + sy2 );
- System.out.println( "bgcolor = " + bgcolor );
- System.out.println( "observer = " + observer );
+ public boolean drawImage(Image img, int dx1, int dy1, int dx2, int dy2, int sx1, int sy1, int sx2, int sy2, Color bgcolor, ImageObserver observer) {
+ String l =
+ "drawImage(Image,int,int,int,int,int,int,int,int,Color,ImageObserver):" +
+ "\n img = " + img +
+ "\n dx1 = " + dx1 +
+ "\n dy1 = " + dy1 +
+ "\n dx2 = " + dx2 +
+ "\n dy2 = " + dy2 +
+ "\n sx1 = " + sx1 +
+ "\n sy1 = " + sy1 +
+ "\n sx2 = " + sx2 +
+ "\n sy2 = " + sy2 +
+ "\n bgcolor = " + bgcolor +
+ "\n observer = " + observer;
+ log.println( l );
return g2D.drawImage( img, dx1, dy1, dx2, dy2, sx1, sy1, sx2, sy2, bgcolor, observer );
}
- public boolean drawImage(Image img, int x, int y,
- Color bgcolor,
- ImageObserver observer)
- {
- System.out.println( "drawImage(Image,int,int,Color,ImageObserver):" );
- System.out.println( "img = " + img );
- System.out.println( "x = " + x );
- System.out.println( "y = " + y );
- System.out.println( "bgcolor = " + bgcolor );
- System.out.println( "observer = " + observer );
+ public boolean drawImage(Image img, int x, int y, Color bgcolor, ImageObserver observer) {
+ String l =
+ "drawImage(Image,int,int,Color,ImageObserver):" +
+ "\n img = " + img +
+ "\n x = " + x +
+ "\n y = " + y +
+ "\n bgcolor = " + bgcolor +
+ "\n observer = " + observer;
+ log.println( l );
return g2D.drawImage( img, x, y, bgcolor, observer );
}
- public boolean drawImage(Image img, int x, int y,
- ImageObserver observer)
- {
- System.out.println( "drawImage(Image,int,int,observer):" );
- System.out.println( "img = " + img );
- System.out.println( "x = " + x );
- System.out.println( "y = " + y );
- System.out.println( "observer = " + observer );
+ public boolean drawImage(Image img, int x, int y, ImageObserver observer) {
+ String l =
+ "drawImage(Image,int,int,observer):" +
+ "\n img = " + img +
+ "\n x = " + x +
+ "\n y = " + y +
+ "\n observer = " + observer;
+ log.println( l );
return g2D.drawImage( img, x, y, observer );
}
- public boolean drawImage(Image img, int x, int y,
- int width, int height,
- Color bgcolor,
- ImageObserver observer)
- {
- System.out.println( "drawImage(Image,int,int,int,int,Color,ImageObserver):" );
- System.out.println( "img = " + img );
- System.out.println( "x = " + x );
- System.out.println( "y = " + y );
- System.out.println( "width = " + width );
- System.out.println( "height = " + height );
- System.out.println( "bgcolor = " + bgcolor );
- System.out.println( "observer = " + observer );
+ public boolean drawImage(Image img, int x, int y, int width, int height, Color bgcolor, ImageObserver observer) {
+ String l =
+ "drawImage(Image,int,int,int,int,Color,ImageObserver):" +
+ "\n img = " + img +
+ "\n x = " + x +
+ "\n y = " + y +
+ "\n width = " + width +
+ "\n height = " + height +
+ "\n bgcolor = " + bgcolor +
+ "\n observer = " + observer;
+ log.println( l );
return g2D.drawImage( img, x, y, width, height, bgcolor, observer );
}
- public boolean drawImage(Image img, int x, int y,
- int width, int height,
- ImageObserver observer)
- {
- System.out.println( "drawImage(Image,int,int,width,height,observer):" );
- System.out.println( "img = " + img );
- System.out.println( "x = " + x );
- System.out.println( "y = " + y );
- System.out.println( "width = " + width );
- System.out.println( "height = " + height );
- System.out.println( "observer = " + observer );
+ public boolean drawImage(Image img, int x, int y, int width, int height, ImageObserver observer) {
+ String l =
+ "drawImage(Image,int,int,width,height,observer):" +
+ "\n img = " + img +
+ "\n x = " + x +
+ "\n y = " + y +
+ "\n width = " + width +
+ "\n height = " + height +
+ "\n observer = " + observer;
+ log.println( l );
return g2D.drawImage( img, x, y, width, height, observer );
}
- public void drawLine(int x1, int y1, int x2, int y2)
- {
- System.out.println( "drawLine(int,int,int,int):" );
- System.out.println( "x1 = " + x1 );
- System.out.println( "y1 = " + y1 );
- System.out.println( "x2 = " + x2 );
- System.out.println( "y2 = " + y2 );
+ public void drawLine(int x1, int y1, int x2, int y2) {
+ String l =
+ "drawLine(int,int,int,int):" +
+ "\n x1 = " + x1 +
+ "\n y1 = " + y1 +
+ "\n x2 = " + x2 +
+ "\n y2 = " + y2;
+ log.println( l );
g2D.drawLine( x1, y1, x2, y2 );
}
- public void drawOval(int x, int y, int width, int height)
- {
- System.out.println( "drawOval(int,int,int,int):" );
- System.out.println( "x = " + x );
- System.out.println( "y = " + y );
- System.out.println( "width = " + width );
- System.out.println( "height = " + height );
+ public void drawOval(int x, int y, int width, int height) {
+ String l =
+ "drawOval(int,int,int,int):" +
+ "\n x = " + x +
+ "\n y = " + y +
+ "\n width = " + width +
+ "\n height = " + height;
+ log.println( l );
g2D.drawOval( x, y, width, height );
}
public void drawPolygon(Polygon p) {
- System.out.println( "drawPolygon(Polygon):" );
- System.out.println( "p = " + p );
+ String l =
+ "drawPolygon(Polygon):" +
+ "\n p = " + p;
+ log.println( l );
g2D.drawPolygon( p );
}
- public void drawPolygon(int xPoints[], int yPoints[],
- int nPoints)
- {
- System.out.println( "drawPolygon(int[],int[],int):" );
- System.out.println( "xPoints = " + Arrays.toString(xPoints) );
- System.out.println( "yPoints = " + Arrays.toString(yPoints) );
- System.out.println( "nPoints = " + nPoints );
+ public void drawPolygon(int xPoints[], int yPoints[], int nPoints) {
+ String l =
+ "drawPolygon(int[],int[],int):" +
+ "\n xPoints = " + Arrays.toString(xPoints) +
+ "\n yPoints = " + Arrays.toString(yPoints) +
+ "\n nPoints = " + nPoints;
+ log.println( l );
g2D.drawPolygon( xPoints, yPoints, nPoints );
}
- public void drawPolyline(int xPoints[], int yPoints[],
- int nPoints)
- {
- System.out.println( "drawPolyline(int[],int[],int):" );
- System.out.println( "xPoints = " + Arrays.toString(xPoints) );
- System.out.println( "yPoints = " + Arrays.toString(yPoints) );
- System.out.println( "nPoints = " + nPoints );
+ public void drawPolyline(int xPoints[], int yPoints[], int nPoints) {
+ String l =
+ "drawPolyline(int[],int[],int):" +
+ "\n xPoints = " + Arrays.toString(xPoints) +
+ "\n yPoints = " + Arrays.toString(yPoints) +
+ "\n nPoints = " + nPoints;
+ log.println( l );
g2D.drawPolyline( xPoints, yPoints, nPoints );
}
public void drawRect(int x, int y, int width, int height) {
- System.out.println( "drawRect(int,int,int,int):" );
- System.out.println( "x = " + x );
- System.out.println( "y = " + y );
- System.out.println( "width = " + width );
- System.out.println( "height = " + height );
+ String l =
+ "drawRect(int,int,int,int):" +
+ "\n x = " + x +
+ "\n y = " + y +
+ "\n width = " + width +
+ "\n height = " + height;
+ log.println( l );
g2D.drawRect( x, y, width, height );
}
- public void drawRoundRect(int x, int y, int width, int height,
- int arcWidth, int arcHeight)
- {
- System.out.println( "drawRoundRect(int,int,int,int,int,int):" );
- System.out.println( "x = " + x );
- System.out.println( "y = " + y );
- System.out.println( "width = " + width );
- System.out.println( "height = " + height );
- System.out.println( "arcWidth = " + arcWidth );
- System.out.println( "arcHeight = " + arcHeight );
+ public void drawRoundRect(int x, int y, int width, int height, int arcWidth, int arcHeight) {
+ String l =
+ "drawRoundRect(int,int,int,int,int,int):" +
+ "\n x = " + x +
+ "\n y = " + y +
+ "\n width = " + width +
+ "\n height = " + height +
+ "\n arcWidth = " + arcWidth +
+ "\n arcHeight = " + arcHeight;
+ log.println( l );
g2D.drawRoundRect( x, y, width, height, arcWidth, arcHeight );
}
- public void drawString(AttributedCharacterIterator iterator,
- int x, int y)
- {
- System.out.println( "drawString(AttributedCharacterIterator,int,int):" );
- System.out.println( "iterator = " + iterator );
- System.out.println( "x = " + x );
- System.out.println( "y = " + y );
+ public void drawString(AttributedCharacterIterator iterator, int x, int y) {
+ String l =
+ "drawString(AttributedCharacterIterator,int,int):" +
+ "\n iterator = " + iterator +
+ "\n x = " + x +
+ "\n y = " + y;
+ log.println( l );
g2D.drawString( iterator, x, y );
}
- public void drawString(String str, int x, int y)
- {
- System.out.println( "drawString(str,int,int):" );
- System.out.println( "str = " + str );
- System.out.println( "x = " + x );
- System.out.println( "y = " + y );
+ public void drawString(String str, int x, int y) {
+ String l =
+ "drawString(str,int,int):" +
+ "\n str = " + str +
+ "\n x = " + x +
+ "\n y = " + y;
+ log.println( l );
g2D.drawString( str, x, y );
}
- public void fill3DRect(int x, int y, int width, int height,
- boolean raised) {
- System.out.println( "fill3DRect(int,int,int,int,boolean):" );
- System.out.println( "x = " + x );
- System.out.println( "y = " + y );
- System.out.println( "width = " + width );
- System.out.println( "height = " + height );
- System.out.println( "raised = " + raised );
+ public void fill3DRect(int x, int y, int width, int height, boolean raised) {
+ String l =
+ "fill3DRect(int,int,int,int,boolean):" +
+ "\n x = " + x +
+ "\n y = " + y +
+ "\n width = " + width +
+ "\n height = " + height +
+ "\n raised = " + raised;
+ log.println( l );
g2D.fill3DRect( x, y, width, height, raised );
}
- public void fillArc(int x, int y, int width, int height,
- int startAngle, int arcAngle)
- {
- System.out.println( "fillArc(int,int,int,int,int,int):" );
- System.out.println( "x = " + x );
- System.out.println( "y = " + y );
- System.out.println( "width = " + width );
- System.out.println( "height = " + height );
- System.out.println( "startAngle = " + startAngle );
- System.out.println( "arcAngle = " + arcAngle );
+ public void fillArc(int x, int y, int width, int height, int startAngle, int arcAngle) {
+ String l =
+ "fillArc(int,int,int,int,int,int):" +
+ "\n x = " + x +
+ "\n y = " + y +
+ "\n width = " + width +
+ "\n height = " + height +
+ "\n startAngle = " + startAngle +
+ "\n arcAngle = " + arcAngle;
+ log.println( l );
g2D.fillArc( x, y, width, height, startAngle, arcAngle );
}
- public void fillOval(int x, int y, int width, int height)
- {
- System.out.println( "fillOval(int,int,int,int):" );
- System.out.println( "x = " + x );
- System.out.println( "y = " + y );
- System.out.println( "width = " + width );
- System.out.println( "height = " + height );
+ public void fillOval(int x, int y, int width, int height) {
+ String l =
+ "fillOval(int,int,int,int):" +
+ "\n x = " + x +
+ "\n y = " + y +
+ "\n width = " + width +
+ "\n height = " + height;
+ log.println( l );
g2D.fillOval( x, y, width, height );
}
public void fillPolygon(Polygon p) {
- System.out.println( "fillPolygon(Polygon):" );
- System.out.println( "p = " + p );
+ String l =
+ "fillPolygon(Polygon):" +
+ "\n p = " + p;
+ log.println( l );
g2D.fillPolygon( p );
}
- public void fillPolygon(int xPoints[], int yPoints[],
- int nPoints)
- {
- System.out.println( "fillPolygon(int[],int[],int):" );
- System.out.println( "xPoints = " + Arrays.toString(xPoints) );
- System.out.println( "yPoints = " + Arrays.toString(yPoints) );
- System.out.println( "nPoints = " + nPoints );
+ public void fillPolygon(int xPoints[], int yPoints[], int nPoints) {
+ String l =
+ "fillPolygon(int[],int[],int):" +
+ "\n xPoints = " + Arrays.toString(xPoints) +
+ "\n yPoints = " + Arrays.toString(yPoints) +
+ "\n nPoints = " + nPoints;
+ log.println( l );
g2D.fillPolygon( xPoints, yPoints, nPoints );
}
- public void fillRect(int x, int y, int width, int height)
- {
- System.out.println( "fillRect(int,int,int,int):" );
- System.out.println( "x = " + x );
- System.out.println( "y = " + y );
- System.out.println( "width = " + width );
- System.out.println( "height = " + height );
+ public void fillRect(int x, int y, int width, int height) {
+ String l =
+ "fillRect(int,int,int,int):" +
+ "\n x = " + x +
+ "\n y = " + y +
+ "\n width = " + width +
+ "\n height = " + height;
+ log.println( l );
g2D.fillRect( x, y, width, height );
}
- public void fillRoundRect(int x, int y, int width, int height,
- int arcWidth, int arcHeight)
- {
- System.out.println( "fillRoundRect(int,int,int,int,int,int):" );
- System.out.println( "x = " + x );
- System.out.println( "y = " + y );
- System.out.println( "width = " + width );
- System.out.println( "height = " + height );
+ public void fillRoundRect(int x, int y, int width, int height, int arcWidth, int arcHeight) {
+ String l =
+ "fillRoundRect(int,int,int,int,int,int):" +
+ "\n x = " + x +
+ "\n y = " + y +
+ "\n width = " + width +
+ "\n height = " + height;
+ log.println( l );
g2D.fillRoundRect( x, y, width, height, arcWidth, arcHeight );
}
public void finalize() {
- System.out.println( "finalize():" );
- g2D.finalize();
-
+ log.println( "finalize():" );
+ g2D.finalize(); // NOSOLAR
super.finalize();
}
- public Shape getClip()
- {
- System.out.println( "getClip():" );
+ public Shape getClip() {
+ log.println( "getClip():" );
return g2D.getClip();
}
- public Rectangle getClipBounds()
- {
- System.out.println( "getClipBounds():" );
+ public Rectangle getClipBounds() {
+ log.println( "getClipBounds():" );
return g2D.getClipBounds();
}
public Rectangle getClipBounds(Rectangle r) {
- System.out.println( "getClipBounds(Rectangle):" );
- System.out.println( "r = " + r );
+ String l =
+ "getClipBounds(Rectangle):" +
+ "\n r = " + r;
+ log.println( l );
return g2D.getClipBounds( r );
}
- public Color getColor()
- {
- System.out.println( "getColor():" );
+ public Color getColor() {
+ log.println( "getColor():" );
return g2D.getColor();
}
- public Font getFont()
- {
- System.out.println( "getFont():" );
+ public Font getFont() {
+ log.println( "getFont():" );
return g2D.getFont();
}
public FontMetrics getFontMetrics() {
- System.out.println( "getFontMetrics():" );
+ log.println( "getFontMetrics():" );
return g2D.getFontMetrics();
}
- public FontMetrics getFontMetrics(Font f)
- {
- System.out.println( "getFontMetrics():" );
+ public FontMetrics getFontMetrics(Font f) {
+ log.println( "getFontMetrics():" );
return g2D.getFontMetrics( f );
}
public boolean hitClip(int x, int y, int width, int height) {
- System.out.println( "hitClip(int,int,int,int):" );
- System.out.println( "x = " + x );
- System.out.println( "y = " + y );
- System.out.println( "width = " + width );
- System.out.println( "height = " + height );
+ String l =
+ "hitClip(int,int,int,int):" +
+ "\n x = " + x +
+ "\n y = " + y +
+ "\n width = " + width +
+ "\n height = " + height;
+ log.println( l );
return g2D.hitClip( x, y, width, height );
}
- public void setClip(Shape clip)
- {
- System.out.println( "setClip(Shape):" );
- System.out.println( "clip = " + clip );
+ public void setClip(Shape clip) {
+ String l =
+ "setClip(Shape):" +
+ "\n clip = " + clip;
+ log.println( l );
g2D.setClip( clip );
}
- public void setClip(int x, int y, int width, int height)
- {
- System.out.println( "setClip(int,int,int,int):" );
- System.out.println( "x = " + x );
- System.out.println( "y = " + y );
- System.out.println( "width = " + width );
- System.out.println( "height = " + height );
+ public void setClip(int x, int y, int width, int height) {
+ String l =
+ "setClip(int,int,int,int):" +
+ "\n x = " + x +
+ "\n y = " + y +
+ "\n width = " + width +
+ "\n height = " + height;
+ log.println( l );
g2D.setClip( x, y, width, height );
}
- public void setColor(Color c)
- {
- System.out.println( "setColor():" );
- System.out.println( "c = " + c );
+ public void setColor(Color c) {
+ String l =
+ "setColor():" +
+ "\n c = " + c;
+ log.println( l );
g2D.setColor( c );
}
- public void setFont(Font font)
- {
- System.out.println( "setFont(Font):" );
- System.out.println( "font = " + font );
+ public void setFont(Font font) {
+ String l =
+ "setFont(Font):" +
+ "\n font = " + font;
+ log.println( l );
g2D.setFont( font );
}
- public void setPaintMode()
- {
- System.out.println( "setPaintMode():" );
+ public void setPaintMode() {
+ log.println( "setPaintMode():" );
g2D.setPaintMode();
}
- public void setXORMode(Color c1)
- {
- System.out.println( "setXORMode(Color):" );
- System.out.println( "c1 = " + c1 );
+ public void setXORMode(Color c1) {
+ String l =
+ "setXORMode(Color):" +
+ "\n c1 = " + c1;
+ log.println( l );
g2D.setXORMode( c1 );
}
public String toString() {
- System.out.println( "toString():" );
+ log.println( "toString():" );
return g2D.toString();
}
- public void translate(int x, int y)
- {
- System.out.println( "translate(int,int):" );
- System.out.println( "x = " + x );
- System.out.println( "y = " + y );
+ public void translate(int x, int y) {
+ String l =
+ "translate(int,int):" +
+ "\n x = " + x +
+ "\n y = " + y;
+ log.println( l );
g2D.translate( x, y );
}
}
diff --git a/src/java/org/apache/poi/hssf/usermodel/StaticFontMetrics.java b/src/java/org/apache/poi/hssf/usermodel/StaticFontMetrics.java
index 37e7616aea..fcfd23f178 100644
--- a/src/java/org/apache/poi/hssf/usermodel/StaticFontMetrics.java
+++ b/src/java/org/apache/poi/hssf/usermodel/StaticFontMetrics.java
@@ -20,13 +20,15 @@ package org.apache.poi.hssf.usermodel;
import java.awt.Font;
import java.io.File;
import java.io.FileInputStream;
-import java.io.FileNotFoundException;
import java.io.IOException;
import java.io.InputStream;
import java.util.HashMap;
import java.util.Map;
import java.util.Properties;
+import org.apache.poi.util.POILogFactory;
+import org.apache.poi.util.POILogger;
+
/**
* Allows the user to lookup the font metrics for a particular font without
* actually having the font on the system. The font details are loaded as a
@@ -35,11 +37,14 @@ import java.util.Properties;
* font. Use a multiplier for other sizes.
*/
final class StaticFontMetrics {
+ private static final POILogger LOGGER = POILogFactory.getLogger(StaticFontMetrics.class);
/** The font metrics property file we're using */
private static Properties fontMetricsProps;
/** Our cache of font details we've already looked up */
- private static Map<String, FontDetails> fontDetailsMap = new HashMap<String, FontDetails>();
+ private static final Map<String, FontDetails> fontDetailsMap = new HashMap<String, FontDetails>();
+ private StaticFontMetrics() {}
+
/**
* Retrieves the fake font details for a given font.
*
@@ -47,47 +52,15 @@ final class StaticFontMetrics {
* the font to lookup.
* @return the fake font.
*/
- public static FontDetails getFontDetails(Font font) {
+ public static synchronized FontDetails getFontDetails(Font font) {
// If we haven't already identified out font metrics file,
// figure out which one to use and load it
if (fontMetricsProps == null) {
- InputStream metricsIn = null;
- try {
- fontMetricsProps = new Properties();
-
- // Check to see if the font metric file was specified
- // as a system property
- String propFileName = null;
- try {
- propFileName = System.getProperty("font.metrics.filename");
- } catch (SecurityException e) {
- }
-
- if (propFileName != null) {
- File file = new File(propFileName);
- if (!file.exists())
- throw new FileNotFoundException(
- "font_metrics.properties not found at path "
- + file.getAbsolutePath());
- metricsIn = new FileInputStream(file);
- } else {
- // Use the built-in font metrics file off the classpath
- metricsIn = FontDetails.class.getResourceAsStream("/font_metrics.properties");
- if (metricsIn == null)
- throw new FileNotFoundException(
- "font_metrics.properties not found in classpath");
- }
- fontMetricsProps.load(metricsIn);
- } catch (IOException e) {
- throw new RuntimeException("Could not load font metrics: " + e.getMessage());
- } finally {
- if (metricsIn != null) {
- try {
- metricsIn.close();
- } catch (IOException ignore) {
- }
- }
- }
+ try {
+ fontMetricsProps = loadMetrics();
+ } catch (IOException e) {
+ throw new RuntimeException("Could not load font metrics", e);
+ }
}
// Grab the base name of the font they've asked about
@@ -97,28 +70,73 @@ final class StaticFontMetrics {
// Others have different font instances for bold etc
// (eg font.dialog.plain.* vs font.Californian FB Bold.*)
String fontStyle = "";
- if (font.isPlain())
+ if (font.isPlain()) {
fontStyle += "plain";
- if (font.isBold())
+ }
+ if (font.isBold()) {
fontStyle += "bold";
- if (font.isItalic())
+ }
+ if (font.isItalic()) {
fontStyle += "italic";
+ }
// Do we have a definition for this font with just the name?
// If not, check with the font style added
- if (fontMetricsProps.get(FontDetails.buildFontHeightProperty(fontName)) == null
- && fontMetricsProps.get(FontDetails.buildFontHeightProperty(fontName + "."
- + fontStyle)) != null) {
+ String fontHeight = FontDetails.buildFontHeightProperty(fontName);
+ String styleHeight = FontDetails.buildFontHeightProperty(fontName + "." + fontStyle);
+
+ if (fontMetricsProps.get(fontHeight) == null
+ && fontMetricsProps.get(styleHeight) != null) {
// Need to add on the style to the font name
fontName += "." + fontStyle;
}
// Get the details on this font
- if (fontDetailsMap.get(fontName) == null) {
- FontDetails fontDetails = FontDetails.create(fontName, fontMetricsProps);
+ FontDetails fontDetails = fontDetailsMap.get(fontName);
+ if (fontDetails == null) {
+ fontDetails = FontDetails.create(fontName, fontMetricsProps);
fontDetailsMap.put(fontName, fontDetails);
- return fontDetails;
}
- return fontDetailsMap.get(fontName);
+ return fontDetails;
+ }
+
+ private static Properties loadMetrics() throws IOException {
+ // Check to see if the font metric file was specified
+ // as a system property
+ File propFile = null;
+ try {
+ String propFileName = System.getProperty("font.metrics.filename");
+ if (propFileName != null) {
+ propFile = new File(propFileName);
+ if (!propFile.exists()) {
+ LOGGER.log(POILogger.WARN, "font_metrics.properties not found at path "+propFile.getAbsolutePath());
+ propFile = null;
+ }
+ }
+ } catch (SecurityException e) {
+ LOGGER.log(POILogger.WARN, "Can't access font.metrics.filename system property", e);
+ }
+
+ InputStream metricsIn = null;
+ try {
+ if (propFile != null) {
+ metricsIn = new FileInputStream(propFile);
+ } else {
+ // Use the built-in font metrics file off the classpath
+ metricsIn = FontDetails.class.getResourceAsStream("/font_metrics.properties");
+ if (metricsIn == null) {
+ String err = "font_metrics.properties not found in classpath";
+ throw new IOException(err);
+ }
+ }
+
+ Properties props = new Properties();
+ props.load(metricsIn);
+ return props;
+ } finally {
+ if (metricsIn != null) {
+ metricsIn.close();
+ }
+ }
}
}
diff --git a/src/java/org/apache/poi/ss/usermodel/FractionFormat.java b/src/java/org/apache/poi/ss/usermodel/FractionFormat.java
index b371c4ec84..bd5c8c8fec 100644
--- a/src/java/org/apache/poi/ss/usermodel/FractionFormat.java
+++ b/src/java/org/apache/poi/ss/usermodel/FractionFormat.java
@@ -99,31 +99,33 @@ public class FractionFormat extends Format {
public String format(Number num) {
- double doubleValue = num.doubleValue();
+ final double doubleValue = num.doubleValue();
- boolean isNeg = (doubleValue < 0.0f) ? true : false;
- double absDoubleValue = Math.abs(doubleValue);
+ final boolean isNeg = (doubleValue < 0.0f) ? true : false;
+ final double absDoubleValue = Math.abs(doubleValue);
- double wholePart = Math.floor(absDoubleValue);
- double decPart = absDoubleValue - wholePart;
+ final double wholePart = Math.floor(absDoubleValue);
+ final double decPart = absDoubleValue - wholePart;
if (wholePart + decPart == 0) {
return "0";
}
- //if the absolute value is smaller than 1 over the exact or maxDenom
- //you can stop here and return "0"
- if (absDoubleValue < (1/Math.max(exactDenom, maxDenom))){
- return "0";
- }
+ // if the absolute value is smaller than 1 over the exact or maxDenom
+ // you can stop here and return "0"
+ // reciprocal is result of an int devision ... and so it's nearly always 0
+ // double reciprocal = 1/Math.max(exactDenom, maxDenom);
+ // if (absDoubleValue < reciprocal) {
+ // return "0";
+ // }
//this is necessary to prevent overflow in the maxDenom calculation
- if (wholePart+(int)decPart == wholePart+decPart){
+ if (Double.compare(decPart, 0) == 0){
StringBuilder sb = new StringBuilder();
if (isNeg){
sb.append("-");
}
- sb.append(Integer.toString((int)wholePart));
+ sb.append((int)wholePart);
return sb.toString();
}
diff --git a/src/ooxml/java/org/apache/poi/openxml4j/exceptions/InvalidFormatException.java b/src/ooxml/java/org/apache/poi/openxml4j/exceptions/InvalidFormatException.java
index 13ed195c22..832d47623b 100644
--- a/src/ooxml/java/org/apache/poi/openxml4j/exceptions/InvalidFormatException.java
+++ b/src/ooxml/java/org/apache/poi/openxml4j/exceptions/InvalidFormatException.java
@@ -23,4 +23,8 @@ public final class InvalidFormatException extends OpenXML4JException{
public InvalidFormatException(String message){
super(message);
}
+
+ public InvalidFormatException(String message, Throwable cause){
+ super(message,cause);
+ }
}
diff --git a/src/ooxml/java/org/apache/poi/openxml4j/exceptions/OpenXML4JException.java b/src/ooxml/java/org/apache/poi/openxml4j/exceptions/OpenXML4JException.java
index 09979d96de..ce08aafc88 100644
--- a/src/ooxml/java/org/apache/poi/openxml4j/exceptions/OpenXML4JException.java
+++ b/src/ooxml/java/org/apache/poi/openxml4j/exceptions/OpenXML4JException.java
@@ -31,4 +31,8 @@ public class OpenXML4JException extends Exception {
public OpenXML4JException(String msg) {
super(msg);
}
+
+ public OpenXML4JException(String msg, Throwable cause) {
+ super(msg, cause);
+ }
}
diff --git a/src/ooxml/java/org/apache/poi/openxml4j/opc/OPCPackage.java b/src/ooxml/java/org/apache/poi/openxml4j/opc/OPCPackage.java
index 23f028b66b..4c1acd0179 100644
--- a/src/ooxml/java/org/apache/poi/openxml4j/opc/OPCPackage.java
+++ b/src/ooxml/java/org/apache/poi/openxml4j/opc/OPCPackage.java
@@ -21,7 +21,6 @@ import java.io.ByteArrayOutputStream;
import java.io.Closeable;
import java.io.File;
import java.io.FileInputStream;
-import java.io.FileNotFoundException;
import java.io.FileOutputStream;
import java.io.IOException;
import java.io.InputStream;
@@ -33,6 +32,7 @@ import java.util.Collections;
import java.util.Date;
import java.util.Hashtable;
import java.util.List;
+import java.util.Map;
import java.util.concurrent.locks.ReentrantReadWriteLock;
import java.util.regex.Matcher;
import java.util.regex.Pattern;
@@ -92,7 +92,7 @@ public abstract class OPCPackage implements RelationshipSource, Closeable {
/**
* Part marshallers by content type.
*/
- protected Hashtable<ContentType, PartMarshaller> partMarshallers;
+ protected Map<ContentType, PartMarshaller> partMarshallers;
/**
* Default part marshaller.
@@ -102,7 +102,7 @@ public abstract class OPCPackage implements RelationshipSource, Closeable {
/**
* Part unmarshallers by content type.
*/
- protected Hashtable<ContentType, PartUnmarshaller> partUnmarshallers;
+ protected Map<ContentType, PartUnmarshaller> partUnmarshallers;
/**
* Core package properties.
@@ -167,7 +167,8 @@ public abstract class OPCPackage implements RelationshipSource, Closeable {
throw new OpenXML4JRuntimeException(
"Package.init() : this exception should never happen, " +
"if you read this message please send a mail to the developers team. : " +
- e.getMessage()
+ e.getMessage(),
+ e
);
}
}
@@ -215,12 +216,14 @@ public abstract class OPCPackage implements RelationshipSource, Closeable {
*/
public static OPCPackage open(String path, PackageAccess access)
throws InvalidFormatException {
- if (path == null || "".equals(path.trim()))
+ if (path == null || "".equals(path.trim())) {
throw new IllegalArgumentException("'path' must be given");
+ }
File file = new File(path);
- if (file.exists() && file.isDirectory())
+ if (file.exists() && file.isDirectory()) {
throw new IllegalArgumentException("path must not be a directory");
+ }
OPCPackage pack = new ZipPackage(path, access);
if (pack.partList == null && access != PackageAccess.WRITE) {
@@ -318,8 +321,9 @@ public abstract class OPCPackage implements RelationshipSource, Closeable {
* @return A newly created PackageBase ready to use.
*/
public static OPCPackage create(File file) {
- if (file == null || (file.exists() && file.isDirectory()))
+ if (file == null || (file.exists() && file.isDirectory())) {
throw new IllegalArgumentException("file");
+ }
if (file.exists()) {
throw new InvalidOperationException(
@@ -457,8 +461,9 @@ public abstract class OPCPackage implements RelationshipSource, Closeable {
*/
public void addThumbnail(String path) throws IOException {
// Check parameter
- if ("".equals(path))
+ if ("".equals(path)) {
throw new IllegalArgumentException("path");
+ }
// Get the filename from the path
String filename = path
@@ -478,7 +483,7 @@ public abstract class OPCPackage implements RelationshipSource, Closeable {
+ path.substring(path.lastIndexOf(".") + 1));
} catch (InvalidFormatException e2) {
throw new InvalidOperationException(
- "Can't add a thumbnail file named '" + filename + "'");
+ "Can't add a thumbnail file named '" + filename + "'", e2);
}
}
@@ -511,9 +516,10 @@ public abstract class OPCPackage implements RelationshipSource, Closeable {
* @see org.apache.poi.openxml4j.opc.PackageAccess
*/
void throwExceptionIfReadOnly() throws InvalidOperationException {
- if (packageAccess == PackageAccess.READ)
+ if (packageAccess == PackageAccess.READ) {
throw new InvalidOperationException(
"Operation not allowed, document open in read only mode!");
+ }
}
/**
@@ -526,9 +532,10 @@ public abstract class OPCPackage implements RelationshipSource, Closeable {
* @see org.apache.poi.openxml4j.opc.PackageAccess
*/
void throwExceptionIfWriteOnly() throws InvalidOperationException {
- if (packageAccess == PackageAccess.WRITE)
+ if (packageAccess == PackageAccess.WRITE) {
throw new InvalidOperationException(
"Operation not allowed, document open in write only mode!");
+ }
}
/**
@@ -557,8 +564,9 @@ public abstract class OPCPackage implements RelationshipSource, Closeable {
public PackagePart getPart(PackagePartName partName) {
throwExceptionIfWriteOnly();
- if (partName == null)
+ if (partName == null) {
throw new IllegalArgumentException("partName");
+ }
// If the partlist is null, then we parse the package.
if (partList == null) {
@@ -581,8 +589,9 @@ public abstract class OPCPackage implements RelationshipSource, Closeable {
public ArrayList<PackagePart> getPartsByContentType(String contentType) {
ArrayList<PackagePart> retArr = new ArrayList<PackagePart>();
for (PackagePart part : partList.values()) {
- if (part.getContentType().equals(contentType))
+ if (part.getContentType().equals(contentType)) {
retArr.add(part);
+ }
}
Collections.sort(retArr);
return retArr;
@@ -599,8 +608,9 @@ public abstract class OPCPackage implements RelationshipSource, Closeable {
*/
public ArrayList<PackagePart> getPartsByRelationshipType(
String relationshipType) {
- if (relationshipType == null)
+ if (relationshipType == null) {
throw new IllegalArgumentException("relationshipType");
+ }
ArrayList<PackagePart> retArr = new ArrayList<PackagePart>();
for (PackageRelationship rel : getRelationshipsByType(relationshipType)) {
PackagePart part = getPart(rel);
@@ -686,13 +696,14 @@ public abstract class OPCPackage implements RelationshipSource, Closeable {
PackagePart[] parts = this.getPartsImpl();
this.partList = new PackagePartCollection();
for (PackagePart part : parts) {
- if (partList.containsKey(part._partName))
+ if (partList.containsKey(part._partName)) {
throw new InvalidFormatException(
"A part with the name '" +
part._partName +
"' already exist : Packages shall not contain equivalent " +
"part names and package implementers shall neither create " +
"nor recognize packages with equivalent part names. [M1.12]");
+ }
// Check OPC compliance rule M4.1
if (part.getContentType().equals(
@@ -729,13 +740,13 @@ public abstract class OPCPackage implements RelationshipSource, Closeable {
+ part._partName);
continue;
} catch (InvalidOperationException invoe) {
- throw new InvalidFormatException(invoe.getMessage());
+ throw new InvalidFormatException(invoe.getMessage(), invoe);
}
} else {
try {
partList.put(part._partName, part);
} catch (InvalidOperationException e) {
- throw new InvalidFormatException(e.getMessage());
+ throw new InvalidFormatException(e.getMessage(), e);
}
}
}
@@ -813,9 +824,10 @@ public abstract class OPCPackage implements RelationshipSource, Closeable {
// Note - POI will read files with more than one Core Properties, which
// Office sometimes produces, but is strict on generation
if (contentType.equals(ContentTypes.CORE_PROPERTIES_PART)) {
- if (this.packageProperties != null)
+ if (this.packageProperties != null) {
throw new InvalidOperationException(
"OPC Compliance error [M4.1]: you try to add more than one core properties relationship in the package !");
+ }
}
/* End check OPC compliance */
@@ -929,8 +941,9 @@ public abstract class OPCPackage implements RelationshipSource, Closeable {
*/
public void removePart(PackagePartName partName) {
throwExceptionIfReadOnly();
- if (partName == null || !this.containPart(partName))
+ if (partName == null || !this.containPart(partName)) {
throw new IllegalArgumentException("partName");
+ }
// Delete the specified part from the package.
if (this.partList.containsKey(partName)) {
@@ -964,8 +977,9 @@ public abstract class OPCPackage implements RelationshipSource, Closeable {
clearRelationships();
} else if (containPart(sourcePartName)) {
PackagePart part = getPart(sourcePartName);
- if (part != null)
+ if (part != null) {
part.clearRelationships();
+ }
}
}
@@ -1019,8 +1033,9 @@ public abstract class OPCPackage implements RelationshipSource, Closeable {
* Name of the part to delete
*/
public void deletePart(PackagePartName partName) {
- if (partName == null)
+ if (partName == null) {
throw new IllegalArgumentException("partName");
+ }
// Remove the part
this.removePart(partName);
@@ -1039,8 +1054,9 @@ public abstract class OPCPackage implements RelationshipSource, Closeable {
* Name of the part to delete
*/
public void deletePartRecursive(PackagePartName partName) {
- if (partName == null || !this.containPart(partName))
+ if (partName == null || !this.containPart(partName)) {
throw new IllegalArgumentException("partName");
+ }
PackagePart partToDelete = this.getPart(partName);
// Remove the part
@@ -1064,8 +1080,9 @@ public abstract class OPCPackage implements RelationshipSource, Closeable {
// Remove the relationships part
PackagePartName relationshipPartName = PackagingURIHelper
.getRelationshipPartName(partName);
- if (relationshipPartName != null && containPart(relationshipPartName))
+ if (relationshipPartName != null && containPart(relationshipPartName)) {
this.removePart(relationshipPartName);
+ }
}
/**
@@ -1115,9 +1132,10 @@ public abstract class OPCPackage implements RelationshipSource, Closeable {
// relationship for a package to be an error. If present, the
// relationship shall target the Core Properties part.
if (relationshipType.equals(PackageRelationshipTypes.CORE_PROPERTIES)
- && this.packageProperties != null)
+ && this.packageProperties != null) {
throw new InvalidOperationException(
"OPC Compliance error [M4.1]: can't add another core properties part ! Use the built-in package method instead.");
+ }
/*
* Check rule M1.25: The Relationships part shall not have relationships
@@ -1311,8 +1329,9 @@ public abstract class OPCPackage implements RelationshipSource, Closeable {
*/
public boolean isRelationshipExists(PackageRelationship rel) {
for (PackageRelationship r : this.getRelationships()) {
- if (r == rel)
+ if (r == rel) {
return true;
+ }
}
return false;
}
@@ -1360,7 +1379,11 @@ public abstract class OPCPackage implements RelationshipSource, Closeable {
* The content type associated with the marshaller to remove.
*/
public void removeMarshaller(String contentType) {
- partMarshallers.remove(contentType);
+ try {
+ partMarshallers.remove(new ContentType(contentType));
+ } catch (InvalidFormatException e) {
+ throw new RuntimeException(e);
+ }
}
/**
@@ -1370,7 +1393,11 @@ public abstract class OPCPackage implements RelationshipSource, Closeable {
* The content type associated with the unmarshaller to remove.
*/
public void removeUnmarshaller(String contentType) {
- partUnmarshallers.remove(contentType);
+ try {
+ partUnmarshallers.remove(new ContentType(contentType));
+ } catch (InvalidFormatException e) {
+ throw new RuntimeException(e);
+ }
}
/* Accesseurs */
@@ -1403,8 +1430,9 @@ public abstract class OPCPackage implements RelationshipSource, Closeable {
* @see #save(OutputStream)
*/
public void save(File targetFile) throws IOException {
- if (targetFile == null)
+ if (targetFile == null) {
throw new IllegalArgumentException("targetFile");
+ }
this.throwExceptionIfReadOnly();
@@ -1421,13 +1449,9 @@ public abstract class OPCPackage implements RelationshipSource, Closeable {
FileOutputStream fos = null;
try {
fos = new FileOutputStream(targetFile);
- } catch (FileNotFoundException e) {
- throw new IOException(e.getLocalizedMessage());
- }
- try {
this.save(fos);
} finally {
- fos.close();
+ if (fos != null) fos.close();
}
}
diff --git a/src/ooxml/java/org/apache/poi/xssf/usermodel/XSSFColor.java b/src/ooxml/java/org/apache/poi/xssf/usermodel/XSSFColor.java
index 9154e7f7dd..fc5304a0aa 100644
--- a/src/ooxml/java/org/apache/poi/xssf/usermodel/XSSFColor.java
+++ b/src/ooxml/java/org/apache/poi/xssf/usermodel/XSSFColor.java
@@ -93,13 +93,16 @@ public class XSSFColor extends ExtendedColor {
* A boolean value indicating if the ctColor has a tint or not
*/
public boolean hasTint() {
- if (! ctColor.isSetRgb()) return false;
+ if (! ctColor.isSetRgb()) {
+ return false;
+ }
return ctColor.getRgb().length == 4;
}
/**
* Indexed ctColor value. Only used for backwards compatibility. References a ctColor in indexedColors.
*/
+ @Override
public short getIndex() {
return (short)ctColor.getIndexed();
}
@@ -121,9 +124,12 @@ public class XSSFColor extends ExtendedColor {
* Standard Red Green Blue ctColor value (RGB).
* If there was an A (Alpha) value, it will be stripped.
*/
+ @Override
public byte[] getRGB() {
byte[] rgb = getRGBOrARGB();
- if(rgb == null) return null;
+ if(rgb == null) {
+ return null;
+ }
if(rgb.length == 4) {
// Need to trim off the alpha
@@ -134,19 +140,16 @@ public class XSSFColor extends ExtendedColor {
return rgb;
}
}
- /**
- * @deprecated use {@link #getRGB()}
- */
- public byte[] getRgb() {
- return getRGB();
- }
/**
* Standard Alpha Red Green Blue ctColor value (ARGB).
*/
+ @Override
public byte[] getARGB() {
byte[] rgb = getRGBOrARGB();
- if(rgb == null) return null;
+ if(rgb == null) {
+ return null;
+ }
if(rgb.length == 3) {
// Pad with the default Alpha
@@ -158,34 +161,16 @@ public class XSSFColor extends ExtendedColor {
return rgb;
}
}
- /**
- * @deprecated Use {@link #getARGB()}
- */
- public byte[] getARgb() {
- return getARGB();
- }
+ @Override
protected byte[] getStoredRBG() {
return ctColor.getRgb();
}
/**
- * Standard Red Green Blue ctColor value (RGB) with applied tint.
- * Alpha values are ignored.
- */
- public byte[] getRgbWithTint() {
- return getRGBWithTint();
- }
-
- /**
- * Standard Alpha Red Green Blue ctColor value (ARGB).
- */
- public void setRgb(byte[] rgb) {
- setRGB(rgb);
- }
- /**
* Standard Alpha Red Green Blue ctColor value (ARGB).
*/
+ @Override
public void setRGB(byte[] rgb) {
ctColor.setRgb(rgb);
}
@@ -194,6 +179,7 @@ public class XSSFColor extends ExtendedColor {
* Index into the <clrScheme> collection, referencing a particular <sysClr> or
* <srgbClr> value expressed in the Theme part.
*/
+ @Override
public int getTheme() {
return (int)ctColor.getTheme();
}
@@ -247,6 +233,7 @@ public class XSSFColor extends ExtendedColor {
*
* @return the tint value
*/
+ @Override
public double getTint() {
return ctColor.getTint();
}
@@ -292,6 +279,7 @@ public class XSSFColor extends ExtendedColor {
*
* @param tint the tint value
*/
+ @Override
public void setTint(double tint) {
ctColor.setTint(tint);
}
@@ -313,12 +301,16 @@ public class XSSFColor extends ExtendedColor {
return (XSSFColor)color;
}
+ @Override
public int hashCode(){
return ctColor.toString().hashCode();
}
+ @Override
public boolean equals(Object o){
- if(o == null || !(o instanceof XSSFColor)) return false;
+ if(!(o instanceof XSSFColor)) {
+ return false;
+ }
XSSFColor cf = (XSSFColor)o;
return ctColor.toString().equals(cf.getCTColor().toString());
diff --git a/src/ooxml/testcases/org/apache/poi/xssf/usermodel/TestXSSFBugs.java b/src/ooxml/testcases/org/apache/poi/xssf/usermodel/TestXSSFBugs.java
index 2643654f8d..93cee9b603 100644
--- a/src/ooxml/testcases/org/apache/poi/xssf/usermodel/TestXSSFBugs.java
+++ b/src/ooxml/testcases/org/apache/poi/xssf/usermodel/TestXSSFBugs.java
@@ -50,7 +50,9 @@ import org.apache.poi.POIXMLProperties;
import org.apache.poi.hssf.HSSFTestDataSamples;
import org.apache.poi.hssf.usermodel.HSSFFormulaEvaluator;
import org.apache.poi.hssf.usermodel.HSSFWorkbook;
+import org.apache.poi.openxml4j.exceptions.InvalidFormatException;
import org.apache.poi.openxml4j.exceptions.InvalidOperationException;
+import org.apache.poi.openxml4j.exceptions.OpenXML4JException;
import org.apache.poi.openxml4j.opc.OPCPackage;
import org.apache.poi.openxml4j.opc.PackageAccess;
import org.apache.poi.openxml4j.opc.PackagePart;
@@ -62,7 +64,29 @@ import org.apache.poi.ss.formula.eval.ErrorEval;
import org.apache.poi.ss.formula.eval.NumberEval;
import org.apache.poi.ss.formula.eval.ValueEval;
import org.apache.poi.ss.formula.functions.Function;
-import org.apache.poi.ss.usermodel.*;
+import org.apache.poi.ss.usermodel.BaseTestBugzillaIssues;
+import org.apache.poi.ss.usermodel.Cell;
+import org.apache.poi.ss.usermodel.CellStyle;
+import org.apache.poi.ss.usermodel.CellValue;
+import org.apache.poi.ss.usermodel.ClientAnchor;
+import org.apache.poi.ss.usermodel.Comment;
+import org.apache.poi.ss.usermodel.CreationHelper;
+import org.apache.poi.ss.usermodel.DataFormat;
+import org.apache.poi.ss.usermodel.DataFormatter;
+import org.apache.poi.ss.usermodel.DateUtil;
+import org.apache.poi.ss.usermodel.Drawing;
+import org.apache.poi.ss.usermodel.Font;
+import org.apache.poi.ss.usermodel.FormulaError;
+import org.apache.poi.ss.usermodel.FormulaEvaluator;
+import org.apache.poi.ss.usermodel.Hyperlink;
+import org.apache.poi.ss.usermodel.IndexedColors;
+import org.apache.poi.ss.usermodel.Name;
+import org.apache.poi.ss.usermodel.PrintSetup;
+import org.apache.poi.ss.usermodel.Row;
+import org.apache.poi.ss.usermodel.Sheet;
+import org.apache.poi.ss.usermodel.SheetConditionalFormatting;
+import org.apache.poi.ss.usermodel.Workbook;
+import org.apache.poi.ss.usermodel.WorkbookFactory;
import org.apache.poi.ss.util.AreaReference;
import org.apache.poi.ss.util.CellRangeAddress;
import org.apache.poi.ss.util.CellReference;
@@ -74,6 +98,7 @@ import org.apache.poi.xssf.XSSFTestDataSamples;
import org.apache.poi.xssf.model.CalculationChain;
import org.apache.poi.xssf.streaming.SXSSFWorkbook;
import org.apache.poi.xssf.usermodel.extensions.XSSFCellFill;
+import org.apache.xmlbeans.XmlException;
import org.junit.Ignore;
import org.junit.Test;
import org.openxmlformats.schemas.spreadsheetml.x2006.main.CTCalcCell;
@@ -93,7 +118,7 @@ public final class TestXSSFBugs extends BaseTestBugzillaIssues {
* open resulting file in Excel to check results!
*/
@Test
- public void bug15375_2() throws Exception {
+ public void bug15375_2() throws IOException {
bug15375(1000);
}
@@ -102,7 +127,7 @@ public final class TestXSSFBugs extends BaseTestBugzillaIssues {
* the wrong sheet name
*/
@Test
- public void bug45430() throws Exception {
+ public void bug45430() throws IOException {
XSSFWorkbook wb = XSSFTestDataSamples.openSampleWorkbook("45430.xlsx");
assertFalse(wb.isMacroEnabled());
assertEquals(3, wb.getNumberOfNames());
@@ -133,9 +158,10 @@ public final class TestXSSFBugs extends BaseTestBugzillaIssues {
/**
* We should carry vba macros over after save
+ * @throws InvalidFormatException
*/
@Test
- public void bug45431() throws Exception {
+ public void bug45431() throws IOException, InvalidFormatException {
XSSFWorkbook wb1 = XSSFTestDataSamples.openSampleWorkbook("45431.xlsm");
OPCPackage pkg1 = wb1.getPackage();
assertTrue(wb1.isMacroEnabled());
@@ -190,7 +216,7 @@ public final class TestXSSFBugs extends BaseTestBugzillaIssues {
}
@Test
- public void bug47504() throws Exception {
+ public void bug47504() throws IOException {
XSSFWorkbook wb1 = XSSFTestDataSamples.openSampleWorkbook("47504.xlsx");
assertEquals(1, wb1.getNumberOfSheets());
XSSFSheet sh = wb1.getSheetAt(0);
@@ -218,7 +244,7 @@ public final class TestXSSFBugs extends BaseTestBugzillaIssues {
* read the file despite the naughtyness
*/
@Test
- public void bug49020() throws Exception {
+ public void bug49020() throws IOException {
XSSFWorkbook wb = XSSFTestDataSamples.openSampleWorkbook("BrNotClosed.xlsx");
wb.close();
}
@@ -227,7 +253,7 @@ public final class TestXSSFBugs extends BaseTestBugzillaIssues {
* ensure that CTPhoneticPr is loaded by the ooxml test suite so that it is included in poi-ooxml-schemas
*/
@Test
- public void bug49325() throws Exception {
+ public void bug49325() throws IOException {
XSSFWorkbook wb = XSSFTestDataSamples.openSampleWorkbook("49325.xlsx");
CTWorksheet sh = wb.getSheetAt(0).getCTWorksheet();
assertNotNull(sh.getPhoneticPr());
@@ -239,7 +265,7 @@ public final class TestXSSFBugs extends BaseTestBugzillaIssues {
* should return that sheet index properly
*/
@Test
- public void bug48923() throws Exception {
+ public void bug48923() throws IOException {
XSSFWorkbook wb = XSSFTestDataSamples.openSampleWorkbook("48923.xlsx");
assertEquals(4, wb.getNumberOfNames());
@@ -280,7 +306,7 @@ public final class TestXSSFBugs extends BaseTestBugzillaIssues {
* TODO: delete this test case when MROUND and VAR are implemented
*/
@Test
- public void bug48539() throws Exception {
+ public void bug48539() throws IOException {
XSSFWorkbook wb = XSSFTestDataSamples.openSampleWorkbook("48539.xlsx");
try {
assertEquals(3, wb.getNumberOfSheets());
@@ -325,7 +351,7 @@ public final class TestXSSFBugs extends BaseTestBugzillaIssues {
* a theme is used
*/
@Test
- public void bug48779() throws Exception {
+ public void bug48779() throws IOException {
XSSFWorkbook wb = XSSFTestDataSamples.openSampleWorkbook("48779.xlsx");
XSSFCell cell = wb.getSheetAt(0).getRow(0).getCell(0);
XSSFCellStyle cs = cell.getCellStyle();
@@ -363,7 +389,7 @@ public final class TestXSSFBugs extends BaseTestBugzillaIssues {
* for integers
*/
@Test
- public void bug47490() throws Exception {
+ public void bug47490() throws IOException {
XSSFWorkbook wb = XSSFTestDataSamples.openSampleWorkbook("GeneralFormatTests.xlsx");
Sheet s = wb.getSheetAt(1);
Row r;
@@ -402,7 +428,7 @@ public final class TestXSSFBugs extends BaseTestBugzillaIssues {
* The OPC spec tolerates both of these peculiarities, so does POI
*/
@Test
- public void bug49609() throws Exception {
+ public void bug49609() throws IOException {
XSSFWorkbook wb = XSSFTestDataSamples.openSampleWorkbook("49609.xlsx");
assertEquals("FAM", wb.getSheetName(0));
assertEquals("Cycle", wb.getSheetAt(0).getRow(0).getCell(1).getStringCellValue());
@@ -411,7 +437,7 @@ public final class TestXSSFBugs extends BaseTestBugzillaIssues {
}
@Test
- public void bug49783() throws Exception {
+ public void bug49783() throws IOException {
Workbook wb = XSSFTestDataSamples.openSampleWorkbook("49783.xlsx");
Sheet sheet = wb.getSheetAt(0);
FormulaEvaluator evaluator = wb.getCreationHelper().createFormulaEvaluator();
@@ -445,7 +471,7 @@ public final class TestXSSFBugs extends BaseTestBugzillaIssues {
* with something like "helloworld" !
*/
@Test
- public void bug49941() throws Exception {
+ public void bug49941() throws IOException {
XSSFWorkbook wb1 = new XSSFWorkbook();
XSSFSheet s = wb1.createSheet();
XSSFRow r = s.createRow(0);
@@ -524,7 +550,7 @@ public final class TestXSSFBugs extends BaseTestBugzillaIssues {
* Repeatedly writing the same file which has styles
*/
@Test
- public void bug49940() throws Exception {
+ public void bug49940() throws IOException {
XSSFWorkbook wb = XSSFTestDataSamples.openSampleWorkbook("styles.xlsx");
assertEquals(3, wb.getNumberOfSheets());
assertEquals(10, wb.getStylesSource().getNumCellStyles());
@@ -554,7 +580,7 @@ public final class TestXSSFBugs extends BaseTestBugzillaIssues {
* entry.
*/
@Test
- public void bug49966() throws Exception {
+ public void bug49966() throws IOException {
XSSFWorkbook wb1 = XSSFTestDataSamples
.openSampleWorkbook("shared_formulas.xlsx");
XSSFSheet sheet = wb1.getSheetAt(0);
@@ -610,7 +636,7 @@ public final class TestXSSFBugs extends BaseTestBugzillaIssues {
}
@Test
- public void bug49966Row() throws Exception {
+ public void bug49966Row() throws IOException {
XSSFWorkbook wb = XSSFTestDataSamples
.openSampleWorkbook("shared_formulas.xlsx");
XSSFSheet sheet = wb.getSheetAt(0);
@@ -630,7 +656,7 @@ public final class TestXSSFBugs extends BaseTestBugzillaIssues {
}
@Test
- public void bug49156() throws Exception {
+ public void bug49156() throws IOException {
Workbook wb = XSSFTestDataSamples.openSampleWorkbook("49156.xlsx");
FormulaEvaluator formulaEvaluator = wb.getCreationHelper().createFormulaEvaluator();
@@ -649,7 +675,7 @@ public final class TestXSSFBugs extends BaseTestBugzillaIssues {
* Newlines are valid characters in a formula
*/
@Test
- public void bug50440And51875() throws Exception {
+ public void bug50440And51875() throws IOException {
Workbook wb = XSSFTestDataSamples.openSampleWorkbook("NewlineInFormulas.xlsx");
Sheet s = wb.getSheetAt(0);
Cell c = s.getRow(0).getCell(0);
@@ -676,7 +702,7 @@ public final class TestXSSFBugs extends BaseTestBugzillaIssues {
* Moving a cell comment from one cell to another
*/
@Test
- public void bug50795() throws Exception {
+ public void bug50795() throws IOException {
XSSFWorkbook wb1 = XSSFTestDataSamples.openSampleWorkbook("50795.xlsx");
XSSFSheet sheet = wb1.getSheetAt(0);
XSSFRow row = sheet.getRow(0);
@@ -738,7 +764,7 @@ public final class TestXSSFBugs extends BaseTestBugzillaIssues {
* For those cases, ensure we don't break on reading the colour
*/
@Test
- public void bug50299() throws Exception {
+ public void bug50299() throws IOException {
Workbook wb = XSSFTestDataSamples.openSampleWorkbook("50299.xlsx");
// Check all the colours
@@ -769,9 +795,8 @@ public final class TestXSSFBugs extends BaseTestBugzillaIssues {
/**
* Excel .xls style indexed colours in a .xlsx file
*/
- @SuppressWarnings("deprecation")
@Test
- public void bug50786() throws Exception {
+ public void bug50786() throws IOException {
XSSFWorkbook wb = XSSFTestDataSamples.openSampleWorkbook("50786-indexed_colours.xlsx");
XSSFSheet s = wb.getSheetAt(0);
XSSFRow r = s.getRow(2);
@@ -784,7 +809,7 @@ public final class TestXSSFBugs extends BaseTestBugzillaIssues {
XSSFCellStyle cs = c.getCellStyle();
assertEquals(42, cs.getFillForegroundColor());
assertEquals(42, cs.getFillForegroundColorColor().getIndexed());
- assertNotNull(cs.getFillForegroundColorColor().getRgb());
+ assertNotNull(cs.getFillForegroundColorColor().getRGB());
assertEquals("FFCCFFCC", cs.getFillForegroundColorColor().getARGBHex());
wb.close();
}
@@ -794,7 +819,7 @@ public final class TestXSSFBugs extends BaseTestBugzillaIssues {
* should still be able to get colours
*/
@Test
- public void bug50846() throws Exception {
+ public void bug50846() throws IOException {
XSSFWorkbook wb = XSSFTestDataSamples.openSampleWorkbook("50846-border_colours.xlsx");
XSSFSheet sheet = wb.getSheetAt(0);
@@ -823,9 +848,8 @@ public final class TestXSSFBugs extends BaseTestBugzillaIssues {
* then being set explicitly still should allow the
* fetching of the RGB.
*/
- @SuppressWarnings("deprecation")
@Test
- public void bug50784() throws Exception {
+ public void bug50784() throws IOException {
XSSFWorkbook wb = XSSFTestDataSamples.openSampleWorkbook("50784-font_theme_colours.xlsx");
XSSFSheet s = wb.getSheetAt(0);
XSSFRow r = s.getRow(0);
@@ -836,7 +860,7 @@ public final class TestXSSFBugs extends BaseTestBugzillaIssues {
XSSFColor colr = fr.getXSSFColor();
// No theme, has colours
assertEquals(0, colr.getTheme());
- assertNotNull( colr.getRgb() );
+ assertNotNull( colr.getRGB() );
// Column 0 has a font with colours from a theme
XSSFCell ct = r.getCell(0);
@@ -845,8 +869,8 @@ public final class TestXSSFBugs extends BaseTestBugzillaIssues {
// Has a theme, which has the colours on it
assertEquals(9, colt.getTheme());
XSSFColor themeC = wb.getTheme().getThemeColor(colt.getTheme());
- assertNotNull( themeC.getRgb() );
- assertNotNull( colt.getRgb() );
+ assertNotNull( themeC.getRGB() );
+ assertNotNull( colt.getRGB() );
assertEquals( themeC.getARGBHex(), colt.getARGBHex() ); // The same colour
wb.close();
}
@@ -856,7 +880,7 @@ public final class TestXSSFBugs extends BaseTestBugzillaIssues {
* a rich text string
*/
@Test
- public void bug48877() throws Exception {
+ public void bug48877() throws IOException {
String text = "Use \n with word wrap on to create a new line.\n" +
"This line finishes with two trailing spaces. ";
@@ -929,7 +953,7 @@ public final class TestXSSFBugs extends BaseTestBugzillaIssues {
* Adding sheets when one has a table, then re-ordering
*/
@Test
- public void bug50867() throws Exception {
+ public void bug50867() throws IOException {
XSSFWorkbook wb1 = XSSFTestDataSamples.openSampleWorkbook("50867_with_table.xlsx");
assertEquals(3, wb1.getNumberOfSheets());
@@ -1051,7 +1075,7 @@ public final class TestXSSFBugs extends BaseTestBugzillaIssues {
*/
@SuppressWarnings("deprecation")
@Test
- public void bug49253() throws Exception {
+ public void bug49253() throws IOException {
XSSFWorkbook wb1 = new XSSFWorkbook();
XSSFWorkbook wb2 = new XSSFWorkbook();
@@ -1096,7 +1120,7 @@ public final class TestXSSFBugs extends BaseTestBugzillaIssues {
* Default Column style
*/
@Test
- public void bug51037() throws Exception {
+ public void bug51037() throws IOException {
XSSFWorkbook wb = new XSSFWorkbook();
XSSFSheet s = wb.createSheet();
@@ -1175,7 +1199,7 @@ public final class TestXSSFBugs extends BaseTestBugzillaIssues {
* Something with the SharedStringsTable currently breaks...
*/
@Test
- public void bug46662() throws Exception {
+ public void bug46662() throws IOException {
// New file
XSSFWorkbook wb1 = new XSSFWorkbook();
XSSFTestDataSamples.writeOutAndReadBack(wb1).close();
@@ -1198,7 +1222,7 @@ public final class TestXSSFBugs extends BaseTestBugzillaIssues {
* Colours and styles when the list has gaps in it
*/
@Test
- public void bug51222() throws Exception {
+ public void bug51222() throws IOException {
XSSFWorkbook wb = XSSFTestDataSamples.openSampleWorkbook("51222.xlsx");
XSSFSheet s = wb.getSheetAt(0);
@@ -1239,7 +1263,7 @@ public final class TestXSSFBugs extends BaseTestBugzillaIssues {
}
@Test
- public void bug51470() throws Exception {
+ public void bug51470() throws IOException {
XSSFWorkbook wb = XSSFTestDataSamples.openSampleWorkbook("51470.xlsx");
XSSFSheet sh0 = wb.getSheetAt(0);
XSSFSheet sh1 = wb.cloneSheet(0);
@@ -1257,7 +1281,7 @@ public final class TestXSSFBugs extends BaseTestBugzillaIssues {
* comments (so /xl/comments1.xml is taken)
*/
@Test
- public void bug51850() throws Exception {
+ public void bug51850() throws IOException {
XSSFWorkbook wb1 = XSSFTestDataSamples.openSampleWorkbook("51850.xlsx");
XSSFSheet sh1 = wb1.getSheetAt(0);
XSSFSheet sh2 = wb1.getSheetAt(1);
@@ -1322,7 +1346,7 @@ public final class TestXSSFBugs extends BaseTestBugzillaIssues {
* Sheet names with a , in them
*/
@Test
- public void bug51963() throws Exception {
+ public void bug51963() throws IOException {
XSSFWorkbook wb = XSSFTestDataSamples.openSampleWorkbook("51963.xlsx");
Sheet sheet = wb.getSheetAt(0);
assertEquals("Abc,1", sheet.getSheetName());
@@ -1345,7 +1369,7 @@ public final class TestXSSFBugs extends BaseTestBugzillaIssues {
* DISABLED As we can't currently evaluate these
*/
@Ignore
- public void bug48703() throws Exception {
+ public void bug48703() throws IOException {
XSSFWorkbook wb = XSSFTestDataSamples.openSampleWorkbook("48703.xlsx");
XSSFSheet sheet = wb.getSheetAt(0);
@@ -1375,7 +1399,7 @@ public final class TestXSSFBugs extends BaseTestBugzillaIssues {
* Bugzilla 51710: problems reading shared formuals from .xlsx
*/
@Test
- public void bug51710() throws Exception {
+ public void bug51710() throws IOException {
Workbook wb = XSSFTestDataSamples.openSampleWorkbook("51710.xlsx");
final String[] columns = {"A","B","C","D","E","F","G","H","I","J","K","L","M","N"};
@@ -1407,7 +1431,7 @@ public final class TestXSSFBugs extends BaseTestBugzillaIssues {
* Bug 53101:
*/
@Test
- public void bug5301() throws Exception {
+ public void bug5301() throws IOException {
Workbook wb = XSSFTestDataSamples.openSampleWorkbook("53101.xlsx");
FormulaEvaluator evaluator =
wb.getCreationHelper().createFormulaEvaluator();
@@ -1428,7 +1452,7 @@ public final class TestXSSFBugs extends BaseTestBugzillaIssues {
}
@Test
- public void bug54436() throws Exception {
+ public void bug54436() throws IOException {
Workbook wb = XSSFTestDataSamples.openSampleWorkbook("54436.xlsx");
if(!WorkbookEvaluator.getSupportedFunctionNames().contains("GETPIVOTDATA")){
Function func = new Function() {
@@ -1449,7 +1473,7 @@ public final class TestXSSFBugs extends BaseTestBugzillaIssues {
* error message when called via WorkbookFactory with no password
*/
@Test(expected=EncryptedDocumentException.class)
- public void bug55692_poifs() throws Exception {
+ public void bug55692_poifs() throws IOException {
// Via a POIFSFileSystem
POIFSFileSystem fsP = new POIFSFileSystem(
POIDataSamples.getPOIFSInstance().openResourceAsStream("protect.xlsx"));
@@ -1461,7 +1485,7 @@ public final class TestXSSFBugs extends BaseTestBugzillaIssues {
}
@Test
- public void bug55692_stream() throws Exception {
+ public void bug55692_stream() throws IOException, InvalidFormatException {
// Directly on a Stream, will go via NPOIFS and spot it's
// actually a .xlsx file encrypted with the default password, and open
Workbook wb = WorkbookFactory.create(
@@ -1472,7 +1496,7 @@ public final class TestXSSFBugs extends BaseTestBugzillaIssues {
}
@Test
- public void bug55692_npoifs() throws Exception {
+ public void bug55692_npoifs() throws IOException {
// Via a NPOIFSFileSystem, will spot it's actually a .xlsx file
// encrypted with the default password, and open
NPOIFSFileSystem fsNP = new NPOIFSFileSystem(
@@ -1485,7 +1509,7 @@ public final class TestXSSFBugs extends BaseTestBugzillaIssues {
}
@Test
- public void bug53282() throws Exception {
+ public void bug53282() throws IOException {
Workbook wb = XSSFTestDataSamples.openSampleWorkbook("53282b.xlsx");
Cell c = wb.getSheetAt(0).getRow(1).getCell(0);
assertEquals("#@_#", c.getStringCellValue());
@@ -1499,7 +1523,7 @@ public final class TestXSSFBugs extends BaseTestBugzillaIssues {
* due to a lack of Styles Table
*/
@Test
- public void bug56278() throws Exception {
+ public void bug56278() throws IOException {
Workbook wb = XSSFTestDataSamples.openSampleWorkbook("56278.xlsx");
assertEquals(0, wb.getSheetIndex("Market Rates"));
@@ -1511,7 +1535,7 @@ public final class TestXSSFBugs extends BaseTestBugzillaIssues {
}
@Test
- public void bug56315() throws Exception {
+ public void bug56315() throws IOException {
XSSFWorkbook wb = XSSFTestDataSamples.openSampleWorkbook("56315.xlsx");
Cell c = wb.getSheetAt(0).getRow(1).getCell(0);
CellValue cv = wb.getCreationHelper().createFormulaEvaluator().evaluate(c);
@@ -1521,7 +1545,7 @@ public final class TestXSSFBugs extends BaseTestBugzillaIssues {
}
@Test
- public void bug56468() throws Exception {
+ public void bug56468() throws IOException, InterruptedException {
XSSFWorkbook wb = new XSSFWorkbook();
XSSFSheet sheet = wb.createSheet();
XSSFRow row = sheet.createRow(0);
@@ -1615,7 +1639,7 @@ public final class TestXSSFBugs extends BaseTestBugzillaIssues {
* SUMIF was throwing a NPE on some formulas
*/
@Test
- public void testBug56420SumIfNPE() throws Exception {
+ public void testBug56420SumIfNPE() throws IOException {
XSSFWorkbook wb = XSSFTestDataSamples.openSampleWorkbook("56420.xlsx");
FormulaEvaluator evaluator = wb.getCreationHelper().createFormulaEvaluator();
@@ -1679,7 +1703,7 @@ public final class TestXSSFBugs extends BaseTestBugzillaIssues {
* with DataFormatter
*/
@Test
- public void bug56702() throws Exception {
+ public void bug56702() throws IOException {
XSSFWorkbook wb = XSSFTestDataSamples.openSampleWorkbook("56702.xlsx");
Sheet sheet = wb.getSheetAt(0);
@@ -1754,9 +1778,11 @@ public final class TestXSSFBugs extends BaseTestBugzillaIssues {
}
FileOutputStream fileOutStream = new FileOutputStream(outFile);
- wb.write(fileOutStream);
- fileOutStream.close();
- //System.out.println("File \""+outFile.getName()+"\" has been saved successfully");
+ try {
+ wb.write(fileOutStream);
+ } finally {
+ fileOutStream.close();
+ }
FileInputStream is = new FileInputStream(outFile);
try {
@@ -1773,7 +1799,9 @@ public final class TestXSSFBugs extends BaseTestBugzillaIssues {
}
assertNotNull(newWB.getSheet("test"));
} finally {
- newWB.close();
+ if (newWB != null) {
+ newWB.close();
+ }
}
} finally {
is.close();
@@ -1781,28 +1809,28 @@ public final class TestXSSFBugs extends BaseTestBugzillaIssues {
}
@Test
- public void testBug56688_1() throws Exception {
+ public void testBug56688_1() throws IOException {
XSSFWorkbook excel = XSSFTestDataSamples.openSampleWorkbook("56688_1.xlsx");
checkValue(excel, "-1.0"); /* Not 0.0 because POI sees date "0" minus one month as invalid date, which is -1! */
excel.close();
}
@Test
- public void testBug56688_2() throws Exception {
+ public void testBug56688_2() throws IOException {
XSSFWorkbook excel = XSSFTestDataSamples.openSampleWorkbook("56688_2.xlsx");
checkValue(excel, "#VALUE!");
excel.close();
}
@Test
- public void testBug56688_3() throws Exception {
+ public void testBug56688_3() throws IOException {
XSSFWorkbook excel = XSSFTestDataSamples.openSampleWorkbook("56688_3.xlsx");
checkValue(excel, "#VALUE!");
excel.close();
}
@Test
- public void testBug56688_4() throws Exception {
+ public void testBug56688_4() throws IOException {
XSSFWorkbook excel = XSSFTestDataSamples.openSampleWorkbook("56688_4.xlsx");
Calendar calendar = LocaleUtil.getLocaleCalendar();
@@ -1855,7 +1883,7 @@ public final class TestXSSFBugs extends BaseTestBugzillaIssues {
* function in another file
*/
@Test
- public void bug56502() throws Exception {
+ public void bug56502() throws IOException {
Workbook wb = XSSFTestDataSamples.openSampleWorkbook("56502.xlsx");
Sheet sheet = wb.getSheetAt(0);
@@ -1876,7 +1904,7 @@ public final class TestXSSFBugs extends BaseTestBugzillaIssues {
}
@Test
- public void bug54764() throws Exception {
+ public void bug54764() throws IOException, OpenXML4JException, XmlException {
OPCPackage pkg = XSSFTestDataSamples.openSamplePackage("54764.xlsx");
// Check the core properties - will be found but empty, due
@@ -1914,7 +1942,7 @@ public final class TestXSSFBugs extends BaseTestBugzillaIssues {
* poi-ooxml-schemas jar
*/
@Test
- public void bug57176() throws Exception {
+ public void bug57176() throws IOException {
XSSFWorkbook wb = XSSFTestDataSamples.openSampleWorkbook("57176.xlsx");
CTDefinedNames definedNames = wb.getCTWorkbook().getDefinedNames();
List<CTDefinedName> definedNameList = definedNames.getDefinedNameList();
@@ -1929,9 +1957,11 @@ public final class TestXSSFBugs extends BaseTestBugzillaIssues {
/**
* .xlsb files are not supported, but we should generate a helpful
* error message if given one
+ * @throws InvalidFormatException
+ * @throws
*/
@Test
- public void bug56800_xlsb() throws Exception {
+ public void bug56800_xlsb() throws IOException, InvalidFormatException {
// Can be opened at the OPC level
OPCPackage pkg = XSSFTestDataSamples.openSamplePackage("Simple.xlsb");
@@ -1987,7 +2017,7 @@ public final class TestXSSFBugs extends BaseTestBugzillaIssues {
}
@Test
- public void test57196_Detail() throws Exception {
+ public void test57196_Detail() throws IOException {
XSSFWorkbook wb = new XSSFWorkbook();
XSSFSheet sheet = wb.createSheet("Sheet1");
XSSFRow row = sheet.createRow(0);
@@ -2001,7 +2031,7 @@ public final class TestXSSFBugs extends BaseTestBugzillaIssues {
}
@Test
- public void test57196_Detail2() throws Exception {
+ public void test57196_Detail2() throws IOException {
XSSFWorkbook wb = new XSSFWorkbook();
XSSFSheet sheet = wb.createSheet("Sheet1");
XSSFRow row = sheet.createRow(0);
@@ -2015,7 +2045,7 @@ public final class TestXSSFBugs extends BaseTestBugzillaIssues {
}
@Test
- public void test57196_WorkbookEvaluator() throws Exception {
+ public void test57196_WorkbookEvaluator() throws IOException {
String previousLogger = System.getProperty("org.apache.poi.util.POILogger");
//System.setProperty("org.apache.poi.util.POILogger", "org.apache.poi.util.SystemOutLogger");
//System.setProperty("poi.log.level", "3");
@@ -2098,10 +2128,11 @@ public final class TestXSSFBugs extends BaseTestBugzillaIssues {
/**
* A .xlsx file with no Shared Strings table should open fine
* in read-only mode
+ * @throws InvalidFormatException
*/
@SuppressWarnings("resource")
@Test
- public void bug57482() throws Exception {
+ public void bug57482() throws IOException, InvalidFormatException {
for (PackageAccess access : new PackageAccess[] {
PackageAccess.READ_WRITE, PackageAccess.READ
}) {
@@ -2109,12 +2140,12 @@ public final class TestXSSFBugs extends BaseTestBugzillaIssues {
OPCPackage pkg = OPCPackage.open(file, access);
try {
// Try to open it and read the contents
- XSSFWorkbook wb = new XSSFWorkbook(pkg);
- assertNotNull(wb.getSharedStringSource());
- assertEquals(0, wb.getSharedStringSource().getCount());
+ XSSFWorkbook wb1 = new XSSFWorkbook(pkg);
+ assertNotNull(wb1.getSharedStringSource());
+ assertEquals(0, wb1.getSharedStringSource().getCount());
DataFormatter fmt = new DataFormatter();
- XSSFSheet s = wb.getSheetAt(0);
+ XSSFSheet s = wb1.getSheetAt(0);
assertEquals("1", fmt.formatCellValue(s.getRow(0).getCell(0)));
assertEquals("11", fmt.formatCellValue(s.getRow(0).getCell(1)));
assertEquals("5", fmt.formatCellValue(s.getRow(4).getCell(0)));
@@ -2125,25 +2156,32 @@ public final class TestXSSFBugs extends BaseTestBugzillaIssues {
// Try to write-out and read again, should only work
// in read-write mode, not read-only mode
+ XSSFWorkbook wb2 = null;
try {
- wb = XSSFTestDataSamples.writeOutAndReadBack(wb);
- if (access == PackageAccess.READ)
+ wb2 = XSSFTestDataSamples.writeOutAndReadBack(wb1);
+ if (access == PackageAccess.READ) {
fail("Shouln't be able to write from read-only mode");
+ }
+
+ // Check again
+ s = wb2.getSheetAt(0);
+ assertEquals("1", fmt.formatCellValue(s.getRow(0).getCell(0)));
+ assertEquals("11", fmt.formatCellValue(s.getRow(0).getCell(1)));
+ assertEquals("5", fmt.formatCellValue(s.getRow(4).getCell(0)));
+ assertEquals("Testing", fmt.formatCellValue(s.getRow(0).getCell(3)));
+
} catch (InvalidOperationException e) {
- if (access == PackageAccess.READ) {
- // Expected
- } else {
+ if (access == PackageAccess.READ_WRITE) {
// Shouldn't occur in write-mode
throw e;
}
+ } finally {
+ if (wb2 != null) {
+ wb2.getPackage().revert();
+ }
}
-
- // Check again
- s = wb.getSheetAt(0);
- assertEquals("1", fmt.formatCellValue(s.getRow(0).getCell(0)));
- assertEquals("11", fmt.formatCellValue(s.getRow(0).getCell(1)));
- assertEquals("5", fmt.formatCellValue(s.getRow(4).getCell(0)));
- assertEquals("Testing", fmt.formatCellValue(s.getRow(0).getCell(3)));
+
+ wb1.getPackage().revert();
} finally {
pkg.revert();
}
@@ -2154,7 +2192,7 @@ public final class TestXSSFBugs extends BaseTestBugzillaIssues {
* "Unknown error type: -60" fetching formula error value
*/
@Test
- public void bug57535() throws Exception {
+ public void bug57535() throws IOException {
Workbook wb = XSSFTestDataSamples.openSampleWorkbook("57535.xlsx");
FormulaEvaluator evaluator = wb.getCreationHelper().createFormulaEvaluator();
evaluator.clearAllCachedResultValues();
@@ -2334,7 +2372,7 @@ public final class TestXSSFBugs extends BaseTestBugzillaIssues {
*/
@Test
@Ignore("XMLBeans namespace mis-match on ooxml-strict files")
- public void test57699() throws Exception {
+ public void test57699() throws IOException {
XSSFWorkbook wb = XSSFTestDataSamples.openSampleWorkbook("sample.strict.xlsx");
assertEquals(3, wb.getNumberOfSheets());
// TODO Check sheet contents
@@ -2400,7 +2438,7 @@ public final class TestXSSFBugs extends BaseTestBugzillaIssues {
* Excel treats this as not-bulleted, so now do we
*/
@Test
- public void testBug57826() throws Exception {
+ public void testBug57826() throws IOException {
XSSFWorkbook workbook = XSSFTestDataSamples.openSampleWorkbook("57826.xlsx");
assertTrue("no sheets in workbook", workbook.getNumberOfSheets() >= 1);
@@ -2440,7 +2478,7 @@ public final class TestXSSFBugs extends BaseTestBugzillaIssues {
}
@Test
- public void bug57642() throws Exception {
+ public void bug57642() throws IOException {
XSSFWorkbook wb = new XSSFWorkbook();
XSSFSheet s = wb.createSheet("TestSheet");
XSSFCell c = s.createRow(0).createCell(0);
@@ -2460,9 +2498,10 @@ public final class TestXSSFBugs extends BaseTestBugzillaIssues {
/**
* .xlsx supports 64000 cell styles, the style indexes after
* 32,767 must not be -32,768, then -32,767, -32,766
+ * @throws InvalidFormatException
*/
@Test
- public void bug57880() throws Exception {
+ public void bug57880() throws IOException, InvalidFormatException {
int numStyles = 33000;
XSSFWorkbook wb = new XSSFWorkbook();
//XSSFSheet s = wb.createSheet("TestSheet");
@@ -2529,10 +2568,8 @@ public final class TestXSSFBugs extends BaseTestBugzillaIssues {
data.put("4", new Object[] {4, "John", "Adwards"});
data.put("5", new Object[] {2, "Brian", "Schultz"});
- Set<String> keyset = data.keySet();
int rownum = 1;
- for (String key : keyset)
- {
+ for (Map.Entry<String,Object[]> me : data.entrySet()) {
final Row row;
if(createRow) {
row = sheet.createRow(rownum++);
@@ -2541,10 +2578,8 @@ public final class TestXSSFBugs extends BaseTestBugzillaIssues {
}
assertNotNull(row);
- Object [] objArr = data.get(key);
int cellnum = 0;
- for (Object obj : objArr)
- {
+ for (Object obj : me.getValue()) {
Cell cell = row.getCell(cellnum);
if(cell == null){
cell = row.createCell(cellnum);
@@ -2577,13 +2612,6 @@ public final class TestXSSFBugs extends BaseTestBugzillaIssues {
assertFalse(calc.getR().equals("A6"));
}
- /*FileOutputStream out = new FileOutputStream(new File("C:\\temp\\56574.xlsx"));
- try {
- wb.write(out);
- } finally {
- out.close();
- }*/
-
Workbook wbBack = XSSFTestDataSamples.writeOutAndReadBack(wb);
Sheet sheetBack = wbBack.getSheet("Func");
assertNotNull(sheetBack);
@@ -2607,14 +2635,14 @@ public final class TestXSSFBugs extends BaseTestBugzillaIssues {
* Excel 2007 generated Macro-Enabled .xlsm file
*/
@Test
- public void bug57181() throws Exception {
+ public void bug57181() throws IOException {
XSSFWorkbook wb = XSSFTestDataSamples.openSampleWorkbook("57181.xlsm");
assertEquals(9, wb.getNumberOfSheets());
wb.close();
}
@Test
- public void bug52111() throws Exception {
+ public void bug52111() throws IOException {
Workbook wb = XSSFTestDataSamples.openSampleWorkbook("Intersection-52111-xssf.xlsx");
Sheet s = wb.getSheetAt(0);
assertFormula(wb, s.getRow(2).getCell(0), "(C2:D3 D3:E4)", "4.0");
@@ -2641,7 +2669,7 @@ public final class TestXSSFBugs extends BaseTestBugzillaIssues {
}
@Test
- public void test48962() throws Exception {
+ public void test48962() throws IOException {
Workbook wb = XSSFTestDataSamples.openSampleWorkbook("48962.xlsx");
Sheet sh = wb.getSheetAt(0);
Row row = sh.getRow(1);
@@ -2666,7 +2694,7 @@ public final class TestXSSFBugs extends BaseTestBugzillaIssues {
}
@Test
- public void test50755_workday_formula_example() throws Exception {
+ public void test50755_workday_formula_example() throws IOException {
Workbook wb = XSSFTestDataSamples.openSampleWorkbook("50755_workday_formula_example.xlsx");
Sheet sheet = wb.getSheet("Sheet1");
for(Row aRow : sheet) {
@@ -2684,7 +2712,7 @@ public final class TestXSSFBugs extends BaseTestBugzillaIssues {
}
@Test
- public void test51626() throws Exception {
+ public void test51626() throws IOException, InvalidFormatException {
Workbook wb = XSSFTestDataSamples.openSampleWorkbook("51626.xlsx");
assertNotNull(wb);
wb.close();
@@ -2765,7 +2793,7 @@ public final class TestXSSFBugs extends BaseTestBugzillaIssues {
}
@Test
- public void test55406() throws Exception {
+ public void test55406() throws IOException {
Workbook wb = XSSFTestDataSamples.openSampleWorkbook("55406_Conditional_formatting_sample.xlsx");
Sheet sheet = wb.getSheetAt(0);
Cell cellA1 = sheet.getRow(0).getCell(0);
diff --git a/src/ooxml/testcases/org/apache/poi/xssf/usermodel/TestXSSFCellStyle.java b/src/ooxml/testcases/org/apache/poi/xssf/usermodel/TestXSSFCellStyle.java
index 6c7893ed56..78b624fd68 100644
--- a/src/ooxml/testcases/org/apache/poi/xssf/usermodel/TestXSSFCellStyle.java
+++ b/src/ooxml/testcases/org/apache/poi/xssf/usermodel/TestXSSFCellStyle.java
@@ -17,9 +17,15 @@
package org.apache.poi.xssf.usermodel;
-import java.io.IOException;
+import static org.junit.Assert.assertEquals;
+import static org.junit.Assert.assertFalse;
+import static org.junit.Assert.assertNotEquals;
+import static org.junit.Assert.assertNotNull;
+import static org.junit.Assert.assertNull;
+import static org.junit.Assert.assertSame;
+import static org.junit.Assert.assertTrue;
-import junit.framework.TestCase;
+import java.io.IOException;
import org.apache.poi.hssf.usermodel.HSSFCellStyle;
import org.apache.poi.hssf.usermodel.HSSFWorkbook;
@@ -36,10 +42,20 @@ import org.apache.poi.xssf.XSSFTestDataSamples;
import org.apache.poi.xssf.model.StylesTable;
import org.apache.poi.xssf.usermodel.extensions.XSSFCellBorder;
import org.apache.poi.xssf.usermodel.extensions.XSSFCellFill;
+import org.junit.Before;
import org.junit.Test;
-import org.openxmlformats.schemas.spreadsheetml.x2006.main.*;
-
-public class TestXSSFCellStyle extends TestCase {
+import org.openxmlformats.schemas.spreadsheetml.x2006.main.CTBorder;
+import org.openxmlformats.schemas.spreadsheetml.x2006.main.CTCellXfs;
+import org.openxmlformats.schemas.spreadsheetml.x2006.main.CTFill;
+import org.openxmlformats.schemas.spreadsheetml.x2006.main.CTFont;
+import org.openxmlformats.schemas.spreadsheetml.x2006.main.CTStylesheet;
+import org.openxmlformats.schemas.spreadsheetml.x2006.main.CTXf;
+import org.openxmlformats.schemas.spreadsheetml.x2006.main.STBorderStyle;
+import org.openxmlformats.schemas.spreadsheetml.x2006.main.STHorizontalAlignment;
+import org.openxmlformats.schemas.spreadsheetml.x2006.main.STPatternType;
+import org.openxmlformats.schemas.spreadsheetml.x2006.main.STVerticalAlignment;
+
+public class TestXSSFCellStyle {
private StylesTable stylesTable;
private CTBorder ctBorderA;
private CTFill ctFill;
@@ -50,8 +66,8 @@ public class TestXSSFCellStyle extends TestCase {
private XSSFCellStyle cellStyle;
private CTStylesheet ctStylesheet;
- @Override
- protected void setUp() {
+ @Before
+ public void setUp() {
stylesTable = new StylesTable();
ctStylesheet = stylesTable.getCTStylesheet();
@@ -93,6 +109,7 @@ public class TestXSSFCellStyle extends TestCase {
assertEquals(STPatternType.INT_DARK_GRAY, stylesTable.getFillAt(1).getCTFill().getPatternFill().getPatternType().intValue());
}
+ @Test
public void testGetSetBorderBottom() {
//default values
assertEquals(CellStyle.BORDER_NONE, cellStyle.getBorderBottom());
@@ -127,6 +144,7 @@ public class TestXSSFCellStyle extends TestCase {
assertFalse(ctBorder.isSetBottom());
}
+ @Test
public void testGetSetBorderRight() {
//default values
assertEquals(CellStyle.BORDER_NONE, cellStyle.getBorderRight());
@@ -161,7 +179,8 @@ public class TestXSSFCellStyle extends TestCase {
assertFalse(ctBorder.isSetRight());
}
- public void testGetSetBorderLeft() {
+ @Test
+ public void testGetSetBorderLeft() {
//default values
assertEquals(CellStyle.BORDER_NONE, cellStyle.getBorderLeft());
@@ -195,7 +214,8 @@ public class TestXSSFCellStyle extends TestCase {
assertFalse(ctBorder.isSetLeft());
}
- public void testGetSetBorderTop() {
+ @Test
+ public void testGetSetBorderTop() {
//default values
assertEquals(CellStyle.BORDER_NONE, cellStyle.getBorderTop());
@@ -229,7 +249,8 @@ public class TestXSSFCellStyle extends TestCase {
assertFalse(ctBorder.isSetTop());
}
- public void testGetSetBorderThin() {
+ @Test
+ public void testGetSetBorderThin() {
cellStyle.setBorderTop(CellStyle.BORDER_THIN);
assertEquals(CellStyle.BORDER_THIN, cellStyle.getBorderTop());
int borderId = (int)cellStyle.getCoreXf().getBorderId();
@@ -239,7 +260,8 @@ public class TestXSSFCellStyle extends TestCase {
assertEquals(STBorderStyle.THIN, ctBorder.getTop().getStyle());
}
- public void testGetSetBorderMedium() {
+ @Test
+ public void testGetSetBorderMedium() {
cellStyle.setBorderTop(CellStyle.BORDER_MEDIUM);
assertEquals(CellStyle.BORDER_MEDIUM, cellStyle.getBorderTop());
int borderId = (int)cellStyle.getCoreXf().getBorderId();
@@ -249,7 +271,8 @@ public class TestXSSFCellStyle extends TestCase {
assertEquals(STBorderStyle.MEDIUM, ctBorder.getTop().getStyle());
}
- public void testGetSetBorderThick() {
+ @Test
+ public void testGetSetBorderThick() {
cellStyle.setBorderTop(CellStyle.BORDER_THICK);
assertEquals(CellStyle.BORDER_THICK, cellStyle.getBorderTop());
int borderId = (int)cellStyle.getCoreXf().getBorderId();
@@ -259,7 +282,8 @@ public class TestXSSFCellStyle extends TestCase {
assertEquals(STBorderStyle.THICK, ctBorder.getTop().getStyle());
}
- public void testGetSetBorderHair() {
+ @Test
+ public void testGetSetBorderHair() {
cellStyle.setBorderTop(CellStyle.BORDER_HAIR);
assertEquals(CellStyle.BORDER_HAIR, cellStyle.getBorderTop());
int borderId = (int)cellStyle.getCoreXf().getBorderId();
@@ -269,7 +293,8 @@ public class TestXSSFCellStyle extends TestCase {
assertEquals(STBorderStyle.HAIR, ctBorder.getTop().getStyle());
}
- public void testGetSetBorderDotted() {
+ @Test
+ public void testGetSetBorderDotted() {
cellStyle.setBorderTop(CellStyle.BORDER_DOTTED);
assertEquals(CellStyle.BORDER_DOTTED, cellStyle.getBorderTop());
int borderId = (int)cellStyle.getCoreXf().getBorderId();
@@ -279,7 +304,8 @@ public class TestXSSFCellStyle extends TestCase {
assertEquals(STBorderStyle.DOTTED, ctBorder.getTop().getStyle());
}
- public void testGetSetBorderDashed() {
+ @Test
+ public void testGetSetBorderDashed() {
cellStyle.setBorderTop(CellStyle.BORDER_DASHED);
assertEquals(CellStyle.BORDER_DASHED, cellStyle.getBorderTop());
int borderId = (int)cellStyle.getCoreXf().getBorderId();
@@ -289,7 +315,8 @@ public class TestXSSFCellStyle extends TestCase {
assertEquals(STBorderStyle.DASHED, ctBorder.getTop().getStyle());
}
- public void testGetSetBorderDashDot() {
+ @Test
+ public void testGetSetBorderDashDot() {
cellStyle.setBorderTop(CellStyle.BORDER_DASH_DOT);
assertEquals(CellStyle.BORDER_DASH_DOT, cellStyle.getBorderTop());
int borderId = (int)cellStyle.getCoreXf().getBorderId();
@@ -299,7 +326,8 @@ public class TestXSSFCellStyle extends TestCase {
assertEquals(STBorderStyle.DASH_DOT, ctBorder.getTop().getStyle());
}
- public void testGetSetBorderDashDotDot() {
+ @Test
+ public void testGetSetBorderDashDotDot() {
cellStyle.setBorderTop(CellStyle.BORDER_DASH_DOT_DOT);
assertEquals(CellStyle.BORDER_DASH_DOT_DOT, cellStyle.getBorderTop());
int borderId = (int)cellStyle.getCoreXf().getBorderId();
@@ -309,7 +337,8 @@ public class TestXSSFCellStyle extends TestCase {
assertEquals(STBorderStyle.DASH_DOT_DOT, ctBorder.getTop().getStyle());
}
- public void testGetSetBorderMediumDashDot() {
+ @Test
+ public void testGetSetBorderMediumDashDot() {
cellStyle.setBorderTop(CellStyle.BORDER_MEDIUM_DASH_DOT);
assertEquals(CellStyle.BORDER_MEDIUM_DASH_DOT, cellStyle.getBorderTop());
int borderId = (int)cellStyle.getCoreXf().getBorderId();
@@ -319,7 +348,8 @@ public class TestXSSFCellStyle extends TestCase {
assertEquals(STBorderStyle.MEDIUM_DASH_DOT, ctBorder.getTop().getStyle());
}
- public void testGetSetBorderMediumDashDotDot() {
+ @Test
+ public void testGetSetBorderMediumDashDotDot() {
cellStyle.setBorderTop(CellStyle.BORDER_MEDIUM_DASH_DOT_DOT);
assertEquals(CellStyle.BORDER_MEDIUM_DASH_DOT_DOT, cellStyle.getBorderTop());
int borderId = (int)cellStyle.getCoreXf().getBorderId();
@@ -329,7 +359,8 @@ public class TestXSSFCellStyle extends TestCase {
assertEquals(STBorderStyle.MEDIUM_DASH_DOT_DOT, ctBorder.getTop().getStyle());
}
- public void testGetSetBorderMediumDashed() {
+ @Test
+ public void testGetSetBorderMediumDashed() {
cellStyle.setBorderTop(CellStyle.BORDER_MEDIUM_DASHED);
assertEquals(CellStyle.BORDER_MEDIUM_DASHED, cellStyle.getBorderTop());
int borderId = (int)cellStyle.getCoreXf().getBorderId();
@@ -339,7 +370,8 @@ public class TestXSSFCellStyle extends TestCase {
assertEquals(STBorderStyle.MEDIUM_DASHED, ctBorder.getTop().getStyle());
}
- public void testGetSetBorderSlantDashDot() {
+ @Test
+ public void testGetSetBorderSlantDashDot() {
cellStyle.setBorderTop(CellStyle.BORDER_SLANTED_DASH_DOT);
assertEquals(CellStyle.BORDER_SLANTED_DASH_DOT, cellStyle.getBorderTop());
int borderId = (int)cellStyle.getCoreXf().getBorderId();
@@ -349,7 +381,8 @@ public class TestXSSFCellStyle extends TestCase {
assertEquals(STBorderStyle.SLANT_DASH_DOT, ctBorder.getTop().getStyle());
}
- public void testGetSetBorderDouble() {
+ @Test
+ public void testGetSetBorderDouble() {
cellStyle.setBorderTop(CellStyle.BORDER_DOUBLE);
assertEquals(CellStyle.BORDER_DOUBLE, cellStyle.getBorderTop());
int borderId = (int)cellStyle.getCoreXf().getBorderId();
@@ -359,7 +392,8 @@ public class TestXSSFCellStyle extends TestCase {
assertEquals(STBorderStyle.DOUBLE, ctBorder.getTop().getStyle());
}
- public void testGetSetBottomBorderColor() {
+ @Test
+ public void testGetSetBottomBorderColor() {
//defaults
assertEquals(IndexedColors.BLACK.getIndex(), cellStyle.getBottomBorderColor());
assertNull(cellStyle.getBottomBorderXSSFColor());
@@ -389,7 +423,7 @@ public class TestXSSFCellStyle extends TestCase {
clr = new XSSFColor(java.awt.Color.CYAN);
cellStyle.setBottomBorderColor(clr);
assertEquals(clr.getCTColor().toString(), cellStyle.getBottomBorderXSSFColor().getCTColor().toString());
- byte[] rgb = cellStyle.getBottomBorderXSSFColor().getRgb();
+ byte[] rgb = cellStyle.getBottomBorderXSSFColor().getRGB();
assertEquals(java.awt.Color.CYAN, new java.awt.Color(rgb[0] & 0xFF, rgb[1] & 0xFF, rgb[2] & 0xFF));
//another border was added to the styles table
assertEquals(num + 1, stylesTable.getBorders().size());
@@ -399,7 +433,8 @@ public class TestXSSFCellStyle extends TestCase {
assertNull(cellStyle.getBottomBorderXSSFColor());
}
- public void testGetSetTopBorderColor() {
+ @Test
+ public void testGetSetTopBorderColor() {
//defaults
assertEquals(IndexedColors.BLACK.getIndex(), cellStyle.getTopBorderColor());
assertNull(cellStyle.getTopBorderXSSFColor());
@@ -429,7 +464,7 @@ public class TestXSSFCellStyle extends TestCase {
clr = new XSSFColor(java.awt.Color.CYAN);
cellStyle.setTopBorderColor(clr);
assertEquals(clr.getCTColor().toString(), cellStyle.getTopBorderXSSFColor().getCTColor().toString());
- byte[] rgb = cellStyle.getTopBorderXSSFColor().getRgb();
+ byte[] rgb = cellStyle.getTopBorderXSSFColor().getRGB();
assertEquals(java.awt.Color.CYAN, new java.awt.Color(rgb[0] & 0xFF, rgb[1] & 0xFF, rgb[2] & 0xFF));
//another border was added to the styles table
assertEquals(num + 1, stylesTable.getBorders().size());
@@ -439,7 +474,8 @@ public class TestXSSFCellStyle extends TestCase {
assertNull(cellStyle.getTopBorderXSSFColor());
}
- public void testGetSetLeftBorderColor() {
+ @Test
+ public void testGetSetLeftBorderColor() {
//defaults
assertEquals(IndexedColors.BLACK.getIndex(), cellStyle.getLeftBorderColor());
assertNull(cellStyle.getLeftBorderXSSFColor());
@@ -469,7 +505,7 @@ public class TestXSSFCellStyle extends TestCase {
clr = new XSSFColor(java.awt.Color.CYAN);
cellStyle.setLeftBorderColor(clr);
assertEquals(clr.getCTColor().toString(), cellStyle.getLeftBorderXSSFColor().getCTColor().toString());
- byte[] rgb = cellStyle.getLeftBorderXSSFColor().getRgb();
+ byte[] rgb = cellStyle.getLeftBorderXSSFColor().getRGB();
assertEquals(java.awt.Color.CYAN, new java.awt.Color(rgb[0] & 0xFF, rgb[1] & 0xFF, rgb[2] & 0xFF));
//another border was added to the styles table
assertEquals(num + 1, stylesTable.getBorders().size());
@@ -479,7 +515,8 @@ public class TestXSSFCellStyle extends TestCase {
assertNull(cellStyle.getLeftBorderXSSFColor());
}
- public void testGetSetRightBorderColor() {
+ @Test
+ public void testGetSetRightBorderColor() {
//defaults
assertEquals(IndexedColors.BLACK.getIndex(), cellStyle.getRightBorderColor());
assertNull(cellStyle.getRightBorderXSSFColor());
@@ -509,7 +546,7 @@ public class TestXSSFCellStyle extends TestCase {
clr = new XSSFColor(java.awt.Color.CYAN);
cellStyle.setRightBorderColor(clr);
assertEquals(clr.getCTColor().toString(), cellStyle.getRightBorderXSSFColor().getCTColor().toString());
- byte[] rgb = cellStyle.getRightBorderXSSFColor().getRgb();
+ byte[] rgb = cellStyle.getRightBorderXSSFColor().getRGB();
assertEquals(java.awt.Color.CYAN, new java.awt.Color(rgb[0] & 0xFF, rgb[1] & 0xFF, rgb[2] & 0xFF));
//another border was added to the styles table
assertEquals(num + 1, stylesTable.getBorders().size());
@@ -519,7 +556,8 @@ public class TestXSSFCellStyle extends TestCase {
assertNull(cellStyle.getRightBorderXSSFColor());
}
- public void testGetSetFillBackgroundColor() {
+ @Test
+ public void testGetSetFillBackgroundColor() {
assertEquals(IndexedColors.AUTOMATIC.getIndex(), cellStyle.getFillBackgroundColor());
assertNull(cellStyle.getFillBackgroundXSSFColor());
@@ -541,15 +579,15 @@ public class TestXSSFCellStyle extends TestCase {
int fillId = (int)cellStyle.getCoreXf().getFillId();
assertTrue(fillId > 0);
//check changes in the underlying xml bean
- CTFill ctFill = stylesTable.getFillAt(fillId).getCTFill();
- assertEquals(IndexedColors.RED.getIndex(), ctFill.getPatternFill().getBgColor().getIndexed());
+ CTFill ctFill2 = stylesTable.getFillAt(fillId).getCTFill();
+ assertEquals(IndexedColors.RED.getIndex(), ctFill2.getPatternFill().getBgColor().getIndexed());
//setting XSSFColor
num = stylesTable.getFills().size();
clr = new XSSFColor(java.awt.Color.CYAN);
cellStyle.setFillBackgroundColor(clr);
assertEquals(clr.getCTColor().toString(), cellStyle.getFillBackgroundXSSFColor().getCTColor().toString());
- byte[] rgb = cellStyle.getFillBackgroundXSSFColor().getRgb();
+ byte[] rgb = cellStyle.getFillBackgroundXSSFColor().getRGB();
assertEquals(java.awt.Color.CYAN, new java.awt.Color(rgb[0] & 0xFF, rgb[1] & 0xFF, rgb[2] & 0xFF));
//another border was added to the styles table
assertEquals(num + 1, stylesTable.getFills().size());
@@ -560,7 +598,8 @@ public class TestXSSFCellStyle extends TestCase {
assertEquals(IndexedColors.AUTOMATIC.getIndex(), cellStyle.getFillBackgroundColor());
}
- public void testDefaultStyles() throws IOException {
+ @Test
+ public void testDefaultStyles() throws IOException {
XSSFWorkbook wb1 = new XSSFWorkbook();
@@ -569,6 +608,7 @@ public class TestXSSFCellStyle extends TestCase {
assertNull(style1.getFillBackgroundXSSFColor());
assertNotNull(XSSFTestDataSamples.writeOutAndReadBack(wb1));
+ wb1.close();
//compatibility with HSSF
HSSFWorkbook wb2 = new HSSFWorkbook();
@@ -589,8 +629,8 @@ public class TestXSSFCellStyle extends TestCase {
wb2.close();
}
-
- public void testGetFillForegroundColor() {
+ @Test
+ public void testGetFillForegroundColor() throws IOException {
XSSFWorkbook wb = new XSSFWorkbook();
StylesTable styles = wb.getStylesSource();
assertEquals(1, wb.getNumCellStyles());
@@ -624,9 +664,11 @@ public class TestXSSFCellStyle extends TestCase {
}
assertNotNull(XSSFTestDataSamples.writeOutAndReadBack(wb));
+ wb.close();
}
- public void testGetFillPattern() {
+ @Test
+ public void testGetFillPattern() {
assertEquals(STPatternType.INT_DARK_GRAY-1, cellStyle.getFillPattern());
@@ -637,8 +679,8 @@ public class TestXSSFCellStyle extends TestCase {
int fillId = (int)cellStyle.getCoreXf().getFillId();
assertTrue(fillId > 0);
//check changes in the underlying xml bean
- CTFill ctFill = stylesTable.getFillAt(fillId).getCTFill();
- assertEquals(STPatternType.SOLID, ctFill.getPatternFill().getPatternType());
+ CTFill ctFill2 = stylesTable.getFillAt(fillId).getCTFill();
+ assertEquals(STPatternType.SOLID, ctFill2.getPatternFill().getPatternType());
//setting the same fill multiple time does not update the styles table
for (int i = 0; i < 3; i++) {
@@ -649,16 +691,18 @@ public class TestXSSFCellStyle extends TestCase {
cellStyle.setFillPattern(CellStyle.NO_FILL);
assertEquals(CellStyle.NO_FILL, cellStyle.getFillPattern());
fillId = (int)cellStyle.getCoreXf().getFillId();
- ctFill = stylesTable.getFillAt(fillId).getCTFill();
- assertFalse(ctFill.getPatternFill().isSetPatternType());
+ ctFill2 = stylesTable.getFillAt(fillId).getCTFill();
+ assertFalse(ctFill2.getPatternFill().isSetPatternType());
}
- public void testGetFont() {
+ @Test
+ public void testGetFont() {
assertNotNull(cellStyle.getFont());
}
- public void testGetSetHidden() {
+ @Test
+ public void testGetSetHidden() {
assertFalse(cellStyle.getHidden());
cellStyle.setHidden(true);
assertTrue(cellStyle.getHidden());
@@ -666,7 +710,8 @@ public class TestXSSFCellStyle extends TestCase {
assertFalse(cellStyle.getHidden());
}
- public void testGetSetLocked() {
+ @Test
+ public void testGetSetLocked() {
assertTrue(cellStyle.getLocked());
cellStyle.setLocked(true);
assertTrue(cellStyle.getLocked());
@@ -674,7 +719,8 @@ public class TestXSSFCellStyle extends TestCase {
assertFalse(cellStyle.getLocked());
}
- public void testGetSetIndent() {
+ @Test
+ public void testGetSetIndent() {
assertEquals((short)0, cellStyle.getIndention());
cellStyle.setIndention((short)3);
assertEquals((short)3, cellStyle.getIndention());
@@ -682,7 +728,8 @@ public class TestXSSFCellStyle extends TestCase {
assertEquals((short)13, cellStyle.getIndention());
}
- public void testGetSetAlignement() {
+ @Test
+ public void testGetSetAlignement() {
assertNull(cellStyle.getCellAlignment().getCTCellAlignment().getHorizontal());
assertEquals(HorizontalAlignment.GENERAL, cellStyle.getAlignmentEnum());
@@ -702,7 +749,8 @@ public class TestXSSFCellStyle extends TestCase {
assertEquals(STHorizontalAlignment.CENTER, cellStyle.getCellAlignment().getCTCellAlignment().getHorizontal());
}
- public void testGetSetVerticalAlignment() {
+ @Test
+ public void testGetSetVerticalAlignment() {
assertEquals(VerticalAlignment.BOTTOM, cellStyle.getVerticalAlignmentEnum());
assertEquals(XSSFCellStyle.VERTICAL_BOTTOM, cellStyle.getVerticalAlignment());
assertNull(cellStyle.getCellAlignment().getCTCellAlignment().getVertical());
@@ -718,7 +766,8 @@ public class TestXSSFCellStyle extends TestCase {
assertEquals(STVerticalAlignment.JUSTIFY, cellStyle.getCellAlignment().getCTCellAlignment().getVertical());
}
- public void testGetSetWrapText() {
+ @Test
+ public void testGetSetWrapText() {
assertFalse(cellStyle.getWrapText());
cellStyle.setWrapText(true);
assertTrue(cellStyle.getWrapText());
@@ -729,7 +778,8 @@ public class TestXSSFCellStyle extends TestCase {
/**
* Cloning one XSSFCellStyle onto Another, same XSSFWorkbook
*/
- public void testCloneStyleSameWB() {
+ @Test
+ public void testCloneStyleSameWB() throws IOException {
XSSFWorkbook wb = new XSSFWorkbook();
assertEquals(1, wb.getNumberOfFonts());
@@ -757,13 +807,18 @@ public class TestXSSFCellStyle extends TestCase {
assertTrue(18 == clone.getDataFormat());
assertEquals(2, wb.getNumberOfFonts());
- assertNotNull(XSSFTestDataSamples.writeOutAndReadBack(wb));
+ XSSFWorkbook wb2 = XSSFTestDataSamples.writeOutAndReadBack(wb);
+ assertNotNull(wb2);
+ wb2.close();
+
+ wb.close();
}
/**
* Cloning one XSSFCellStyle onto Another, different XSSFWorkbooks
*/
- public void testCloneStyleDiffWB() {
+ @Test
+ public void testCloneStyleDiffWB() throws IOException {
XSSFWorkbook wbOrig = new XSSFWorkbook();
assertEquals(1, wbOrig.getNumberOfFonts());
assertEquals(0, wbOrig.getStylesSource().getNumberFormats().size());
@@ -803,7 +858,7 @@ public class TestXSSFCellStyle extends TestCase {
assertEquals(0, wbClone.getStylesSource().getNumberFormats().size());
assertFalse(HSSFCellStyle.ALIGN_RIGHT == clone.getAlignment());
- assertFalse("TestingFont" == clone.getFont().getFontName());
+ assertNotEquals("TestingFont", clone.getFont().getFontName());
clone.cloneStyleFrom(orig);
@@ -828,15 +883,25 @@ public class TestXSSFCellStyle extends TestCase {
assertEquals(fmtClone.getFormat("Test##"), reload.getDataFormat());
assertFalse(fmtClone.getFormat("Test##") == fmt.getFormat("Test##"));
- assertNotNull(XSSFTestDataSamples.writeOutAndReadBack(wbOrig));
- assertNotNull(XSSFTestDataSamples.writeOutAndReadBack(wbClone));
+ XSSFWorkbook wbOrig2 = XSSFTestDataSamples.writeOutAndReadBack(wbOrig);
+ assertNotNull(wbOrig2);
+ wbOrig2.close();
+
+ XSSFWorkbook wbClone2 = XSSFTestDataSamples.writeOutAndReadBack(wbClone);
+ assertNotNull(wbClone2);
+ wbClone2.close();
+
+ wbReload.close();
+ wbClone.close();
+ wbOrig.close();
}
/**
* Avoid ArrayIndexOutOfBoundsException when creating cell style
* in a workbook that has an empty xf table.
*/
- public void testBug52348() {
+ @Test
+ public void testBug52348() throws IOException {
XSSFWorkbook workbook = XSSFTestDataSamples.openSampleWorkbook("52348.xlsx");
StylesTable st = workbook.getStylesSource();
assertEquals(0, st._getStyleXfsSize());
@@ -844,14 +909,18 @@ public class TestXSSFCellStyle extends TestCase {
XSSFCellStyle style = workbook.createCellStyle(); // no exception at this point
assertNull(style.getStyleXf());
- assertNotNull(XSSFTestDataSamples.writeOutAndReadBack(workbook));
+ XSSFWorkbook wb2 = XSSFTestDataSamples.writeOutAndReadBack(workbook);
+ assertNotNull(wb2);
+ wb2.close();
+ workbook.close();
}
/**
* Avoid ArrayIndexOutOfBoundsException when getting cell style
* in a workbook that has an empty xf table.
*/
- public void testBug55650() {
+ @Test
+ public void testBug55650() throws IOException {
XSSFWorkbook workbook = XSSFTestDataSamples.openSampleWorkbook("52348.xlsx");
StylesTable st = workbook.getStylesSource();
assertEquals(0, st._getStyleXfsSize());
@@ -860,40 +929,55 @@ public class TestXSSFCellStyle extends TestCase {
XSSFCellStyle style = workbook.getSheetAt(0).getRow(0).getCell(0).getCellStyle();
assertNull(style.getStyleXf());
- assertNotNull(XSSFTestDataSamples.writeOutAndReadBack(workbook));
+ XSSFWorkbook wb2 = XSSFTestDataSamples.writeOutAndReadBack(workbook);
+ assertNotNull(wb2);
+ wb2.close();
+
+ workbook.close();
}
- public void testShrinkToFit() {
+ @Test
+ public void testShrinkToFit() throws IOException {
// Existing file
- XSSFWorkbook wb = XSSFTestDataSamples.openSampleWorkbook("ShrinkToFit.xlsx");
- Sheet s = wb.getSheetAt(0);
+ XSSFWorkbook wb1 = XSSFTestDataSamples.openSampleWorkbook("ShrinkToFit.xlsx");
+ Sheet s = wb1.getSheetAt(0);
Row r = s.getRow(0);
CellStyle cs = r.getCell(0).getCellStyle();
assertEquals(true, cs.getShrinkToFit());
// New file
- XSSFWorkbook wbOrig = new XSSFWorkbook();
- s = wbOrig.createSheet();
+ XSSFWorkbook wb2 = new XSSFWorkbook();
+ s = wb2.createSheet();
r = s.createRow(0);
- cs = wbOrig.createCellStyle();
+ cs = wb2.createCellStyle();
cs.setShrinkToFit(false);
r.createCell(0).setCellStyle(cs);
- cs = wbOrig.createCellStyle();
+ cs = wb2.createCellStyle();
cs.setShrinkToFit(true);
r.createCell(1).setCellStyle(cs);
// Write out, read, and check
- wb = XSSFTestDataSamples.writeOutAndReadBack(wbOrig);
- s = wb.getSheetAt(0);
+ XSSFWorkbook wb3 = XSSFTestDataSamples.writeOutAndReadBack(wb2);
+ s = wb3.getSheetAt(0);
r = s.getRow(0);
assertEquals(false, r.getCell(0).getCellStyle().getShrinkToFit());
assertEquals(true, r.getCell(1).getCellStyle().getShrinkToFit());
- assertNotNull(XSSFTestDataSamples.writeOutAndReadBack(wb));
- assertNotNull(XSSFTestDataSamples.writeOutAndReadBack(wbOrig));
+ XSSFWorkbook wb4 = XSSFTestDataSamples.writeOutAndReadBack(wb2);
+ assertNotNull(wb4);
+ wb4.close();
+
+ XSSFWorkbook wb5 = XSSFTestDataSamples.writeOutAndReadBack(wb3);
+ assertNotNull(wb5);
+ wb5.close();
+
+ wb3.close();
+ wb2.close();
+ wb1.close();
+
}
@Test
@@ -902,31 +986,23 @@ public class TestXSSFCellStyle extends TestCase {
Sheet sheet = wb.createSheet();
Row row = sheet.createRow(0);
- //CreationHelper ch = wb.getCreationHelper();
DataFormat format = wb.createDataFormat();
Cell cell = row.createCell(1);
cell.setCellValue("somevalue");
- CellStyle cellStyle = wb.createCellStyle();
+ CellStyle cellStyle2 = wb.createCellStyle();
- cellStyle.setDataFormat(format.getFormat("###0"));
+ cellStyle2.setDataFormat(format.getFormat("###0"));
- cellStyle.setFillBackgroundColor(IndexedColors.DARK_BLUE.getIndex());
- cellStyle.setFillForegroundColor(IndexedColors.DARK_BLUE.getIndex());
- cellStyle.setFillPattern(CellStyle.SOLID_FOREGROUND);
+ cellStyle2.setFillBackgroundColor(IndexedColors.DARK_BLUE.getIndex());
+ cellStyle2.setFillForegroundColor(IndexedColors.DARK_BLUE.getIndex());
+ cellStyle2.setFillPattern(CellStyle.SOLID_FOREGROUND);
- cellStyle.setAlignment(CellStyle.ALIGN_RIGHT);
- cellStyle.setVerticalAlignment(CellStyle.VERTICAL_TOP);
+ cellStyle2.setAlignment(CellStyle.ALIGN_RIGHT);
+ cellStyle2.setVerticalAlignment(CellStyle.VERTICAL_TOP);
- cell.setCellStyle(cellStyle);
+ cell.setCellStyle(cellStyle2);
- /*OutputStream stream = new FileOutputStream("C:\\temp\\CellColor.xlsx");
- try {
- wb.write(stream);
- } finally {
- stream.close();
- }*/
-
Workbook wbBack = XSSFTestDataSamples.writeOutAndReadBack(wb);
Cell cellBack = wbBack.getSheetAt(0).getRow(0).getCell(1);
assertNotNull(cellBack);
diff --git a/src/ooxml/testcases/org/apache/poi/xssf/usermodel/TestXSSFColor.java b/src/ooxml/testcases/org/apache/poi/xssf/usermodel/TestXSSFColor.java
index 6f31cc49f4..ef8b81dce6 100644
--- a/src/ooxml/testcases/org/apache/poi/xssf/usermodel/TestXSSFColor.java
+++ b/src/ooxml/testcases/org/apache/poi/xssf/usermodel/TestXSSFColor.java
@@ -17,11 +17,16 @@
package org.apache.poi.xssf.usermodel;
-import junit.framework.TestCase;
+import static org.junit.Assert.*;
+
+import java.io.IOException;
import org.apache.poi.xssf.XSSFTestDataSamples;
+import org.junit.Test;
-public final class TestXSSFColor extends TestCase {
+public final class TestXSSFColor {
+
+ @Test
public void testIndexedColour() throws Exception {
XSSFWorkbook wb = XSSFTestDataSamples.openSampleWorkbook("48779.xlsx");
@@ -35,8 +40,8 @@ public final class TestXSSFColor extends TestCase {
// Now check the XSSFColor
// Note - 64 is a special "auto" one with no rgb equiv
assertEquals(64, indexed.getIndexed());
- assertEquals(null, indexed.getRgb());
- assertEquals(null, indexed.getRgbWithTint());
+ assertEquals(null, indexed.getRGB());
+ assertEquals(null, indexed.getRGBWithTint());
assertEquals(null, indexed.getARGBHex());
// Now move to one with indexed rgb values
@@ -49,22 +54,25 @@ public final class TestXSSFColor extends TestCase {
assertEquals(59, indexed.getIndexed());
assertEquals("FF333300", indexed.getARGBHex());
- assertEquals(3, indexed.getRgb().length);
- assertEquals(0x33, indexed.getRgb()[0]);
- assertEquals(0x33, indexed.getRgb()[1]);
- assertEquals(0x00, indexed.getRgb()[2]);
+ assertEquals(3, indexed.getRGB().length);
+ assertEquals(0x33, indexed.getRGB()[0]);
+ assertEquals(0x33, indexed.getRGB()[1]);
+ assertEquals(0x00, indexed.getRGB()[2]);
- assertEquals(4, indexed.getARgb().length);
- assertEquals(-1, indexed.getARgb()[0]);
- assertEquals(0x33, indexed.getARgb()[1]);
- assertEquals(0x33, indexed.getARgb()[2]);
- assertEquals(0x00, indexed.getARgb()[3]);
+ assertEquals(4, indexed.getARGB().length);
+ assertEquals(-1, indexed.getARGB()[0]);
+ assertEquals(0x33, indexed.getARGB()[1]);
+ assertEquals(0x33, indexed.getARGB()[2]);
+ assertEquals(0x00, indexed.getARGB()[3]);
// You don't get tinted indexed colours, sorry...
- assertEquals(null, indexed.getRgbWithTint());
+ assertEquals(null, indexed.getRGBWithTint());
+
+ wb.close();
}
- public void testRGBColour() throws Exception {
+ @Test
+ public void testRGBColour() throws IOException {
XSSFWorkbook wb = XSSFTestDataSamples.openSampleWorkbook("50299.xlsx");
// Check the CTColor is as expected
@@ -81,42 +89,45 @@ public final class TestXSSFColor extends TestCase {
assertEquals(-0.34999, rgb3.getTint(), 0.00001);
assertEquals("FFFFFFFF", rgb3.getARGBHex());
- assertEquals(3, rgb3.getRgb().length);
- assertEquals(-1, rgb3.getRgb()[0]);
- assertEquals(-1, rgb3.getRgb()[1]);
- assertEquals(-1, rgb3.getRgb()[2]);
+ assertEquals(3, rgb3.getRGB().length);
+ assertEquals(-1, rgb3.getRGB()[0]);
+ assertEquals(-1, rgb3.getRGB()[1]);
+ assertEquals(-1, rgb3.getRGB()[2]);
- assertEquals(4, rgb3.getARgb().length);
- assertEquals(-1, rgb3.getARgb()[0]);
- assertEquals(-1, rgb3.getARgb()[1]);
- assertEquals(-1, rgb3.getARgb()[2]);
- assertEquals(-1, rgb3.getARgb()[3]);
+ assertEquals(4, rgb3.getARGB().length);
+ assertEquals(-1, rgb3.getARGB()[0]);
+ assertEquals(-1, rgb3.getARGB()[1]);
+ assertEquals(-1, rgb3.getARGB()[2]);
+ assertEquals(-1, rgb3.getARGB()[3]);
// Tint doesn't have the alpha
// tint = -0.34999
// 255 * (1 + tint) = 165 truncated
// or (byte) -91 (which is 165 - 256)
- assertEquals(3, rgb3.getRgbWithTint().length);
- assertEquals(-91, rgb3.getRgbWithTint()[0]);
- assertEquals(-91, rgb3.getRgbWithTint()[1]);
- assertEquals(-91, rgb3.getRgbWithTint()[2]);
+ assertEquals(3, rgb3.getRGBWithTint().length);
+ assertEquals(-91, rgb3.getRGBWithTint()[0]);
+ assertEquals(-91, rgb3.getRGBWithTint()[1]);
+ assertEquals(-91, rgb3.getRGBWithTint()[2]);
// Set the color to black (no theme).
- rgb3.setRgb(new byte[] {0, 0, 0});
+ rgb3.setRGB(new byte[] {0, 0, 0});
assertEquals("FF000000", rgb3.getARGBHex());
assertEquals(0, rgb3.getCTColor().getRgb()[0]);
assertEquals(0, rgb3.getCTColor().getRgb()[1]);
assertEquals(0, rgb3.getCTColor().getRgb()[2]);
// Set another, is fine
- rgb3.setRgb(new byte[] {16,17,18});
+ rgb3.setRGB(new byte[] {16,17,18});
assertEquals("FF101112", rgb3.getARGBHex());
assertEquals(0x10, rgb3.getCTColor().getRgb()[0]);
assertEquals(0x11, rgb3.getCTColor().getRgb()[1]);
assertEquals(0x12, rgb3.getCTColor().getRgb()[2]);
+
+ wb.close();
}
- public void testARGBColour() throws Exception {
+ @Test
+ public void testARGBColour() throws IOException {
XSSFWorkbook wb = XSSFTestDataSamples.openSampleWorkbook("48779.xlsx");
// Check the CTColor is as expected
@@ -128,35 +139,37 @@ public final class TestXSSFColor extends TestCase {
// Now check the XSSFColor
assertEquals(0, rgb4.getIndexed());
- assertEquals(0.0, rgb4.getTint());
+ assertEquals(0.0, rgb4.getTint(), 0);
assertEquals("FFFF0000", rgb4.getARGBHex());
- assertEquals(3, rgb4.getRgb().length);
- assertEquals(-1, rgb4.getRgb()[0]);
- assertEquals(0, rgb4.getRgb()[1]);
- assertEquals(0, rgb4.getRgb()[2]);
+ assertEquals(3, rgb4.getRGB().length);
+ assertEquals(-1, rgb4.getRGB()[0]);
+ assertEquals(0, rgb4.getRGB()[1]);
+ assertEquals(0, rgb4.getRGB()[2]);
- assertEquals(4, rgb4.getARgb().length);
- assertEquals(-1, rgb4.getARgb()[0]);
- assertEquals(-1, rgb4.getARgb()[1]);
- assertEquals(0, rgb4.getARgb()[2]);
- assertEquals(0, rgb4.getARgb()[3]);
+ assertEquals(4, rgb4.getARGB().length);
+ assertEquals(-1, rgb4.getARGB()[0]);
+ assertEquals(-1, rgb4.getARGB()[1]);
+ assertEquals(0, rgb4.getARGB()[2]);
+ assertEquals(0, rgb4.getARGB()[3]);
// Tint doesn't have the alpha
- assertEquals(3, rgb4.getRgbWithTint().length);
- assertEquals(-1, rgb4.getRgbWithTint()[0]);
- assertEquals(0, rgb4.getRgbWithTint()[1]);
- assertEquals(0, rgb4.getRgbWithTint()[2]);
+ assertEquals(3, rgb4.getRGBWithTint().length);
+ assertEquals(-1, rgb4.getRGBWithTint()[0]);
+ assertEquals(0, rgb4.getRGBWithTint()[1]);
+ assertEquals(0, rgb4.getRGBWithTint()[2]);
// Turn on tinting, and check it behaves
// TODO These values are suspected to be wrong...
rgb4.setTint(0.4);
- assertEquals(0.4, rgb4.getTint());
-
- assertEquals(3, rgb4.getRgbWithTint().length);
- assertEquals(-1, rgb4.getRgbWithTint()[0]);
- assertEquals(102, rgb4.getRgbWithTint()[1]);
- assertEquals(102, rgb4.getRgbWithTint()[2]);
+ assertEquals(0.4, rgb4.getTint(), 0);
+
+ assertEquals(3, rgb4.getRGBWithTint().length);
+ assertEquals(-1, rgb4.getRGBWithTint()[0]);
+ assertEquals(102, rgb4.getRGBWithTint()[1]);
+ assertEquals(102, rgb4.getRGBWithTint()[2]);
+
+ wb.close();
}
}
diff --git a/src/ooxml/testcases/org/apache/poi/xssf/usermodel/extensions/TestXSSFCellFill.java b/src/ooxml/testcases/org/apache/poi/xssf/usermodel/extensions/TestXSSFCellFill.java
index b268410bfa..832d6bfb2b 100644
--- a/src/ooxml/testcases/org/apache/poi/xssf/usermodel/extensions/TestXSSFCellFill.java
+++ b/src/ooxml/testcases/org/apache/poi/xssf/usermodel/extensions/TestXSSFCellFill.java
@@ -18,20 +18,26 @@
package org.apache.poi.xssf.usermodel.extensions;
+import static org.junit.Assert.assertEquals;
+import static org.junit.Assert.assertNotNull;
+
+import java.io.IOException;
+
+import org.apache.poi.ss.usermodel.FillPatternType;
import org.apache.poi.xssf.XSSFTestDataSamples;
import org.apache.poi.xssf.usermodel.XSSFCell;
import org.apache.poi.xssf.usermodel.XSSFColor;
import org.apache.poi.xssf.usermodel.XSSFWorkbook;
+import org.junit.Test;
import org.openxmlformats.schemas.spreadsheetml.x2006.main.CTColor;
import org.openxmlformats.schemas.spreadsheetml.x2006.main.CTFill;
import org.openxmlformats.schemas.spreadsheetml.x2006.main.CTPatternFill;
import org.openxmlformats.schemas.spreadsheetml.x2006.main.STPatternType;
-import junit.framework.TestCase;
-
-public class TestXSSFCellFill extends TestCase {
+public class TestXSSFCellFill {
+ @Test
public void testGetFillBackgroundColor() {
CTFill ctFill = CTFill.Factory.newInstance();
XSSFCellFill cellFill = new XSSFCellFill(ctFill);
@@ -42,6 +48,7 @@ public class TestXSSFCellFill extends TestCase {
assertEquals(2, cellFill.getFillBackgroundColor().getIndexed());
}
+ @Test
public void testGetFillForegroundColor() {
CTFill ctFill = CTFill.Factory.newInstance();
XSSFCellFill cellFill = new XSSFCellFill(ctFill);
@@ -52,14 +59,16 @@ public class TestXSSFCellFill extends TestCase {
assertEquals(8, cellFill.getFillForegroundColor().getIndexed());
}
+ @Test
public void testGetSetPatternType() {
CTFill ctFill = CTFill.Factory.newInstance();
XSSFCellFill cellFill = new XSSFCellFill(ctFill);
CTPatternFill ctPatternFill = ctFill.addNewPatternFill();
ctPatternFill.setPatternType(STPatternType.SOLID);
- //assertEquals(FillPatternType.SOLID_FOREGROUND.ordinal(), cellFill.getPatternType().ordinal());
+ assertEquals(FillPatternType.SOLID_FOREGROUND.ordinal(), cellFill.getPatternType().intValue()-1);
}
+ @Test
public void testGetNotModifies() {
CTFill ctFill = CTFill.Factory.newInstance();
XSSFCellFill cellFill = new XSSFCellFill(ctFill);
@@ -68,13 +77,14 @@ public class TestXSSFCellFill extends TestCase {
assertEquals(8, cellFill.getPatternType().intValue());
}
- public void testColorFromTheme() {
+ @Test
+ public void testColorFromTheme() throws IOException {
XSSFWorkbook wb = XSSFTestDataSamples.openSampleWorkbook("styles.xlsx");
XSSFCell cellWithThemeColor = wb.getSheetAt(0).getRow(10).getCell(0);
//color RGB will be extracted from theme
XSSFColor foregroundColor = cellWithThemeColor.getCellStyle().getFillForegroundXSSFColor();
- byte[] rgb = foregroundColor.getRgb();
- byte[] rgbWithTint = foregroundColor.getRgbWithTint();
+ byte[] rgb = foregroundColor.getRGB();
+ byte[] rgbWithTint = foregroundColor.getRGBWithTint();
// Dk2
assertEquals(rgb[0],31);
assertEquals(rgb[1],73);
@@ -86,5 +96,6 @@ public class TestXSSFCellFill extends TestCase {
assertEquals(rgbWithTint[0],120);
assertEquals(rgbWithTint[1],-111);
assertEquals(rgbWithTint[2],-80);
+ wb.close();
}
}
diff --git a/src/scratchpad/src/org/apache/poi/hwpf/extractor/Word6Extractor.java b/src/scratchpad/src/org/apache/poi/hwpf/extractor/Word6Extractor.java
index 5807740d7d..2cf1ebb8fe 100644
--- a/src/scratchpad/src/org/apache/poi/hwpf/extractor/Word6Extractor.java
+++ b/src/scratchpad/src/org/apache/poi/hwpf/extractor/Word6Extractor.java
@@ -104,8 +104,8 @@ public final class Word6Extractor extends POIOLE2TextExtractor {
ret[i] = doc.getTextTable().getTextPieces().get(i).getStringBuilder().toString();
// Fix the line endings
- ret[i].replaceAll("\r", "\ufffe");
- ret[i].replaceAll("\ufffe","\r\n");
+ ret[i] = ret[i].replaceAll("\r", "\ufffe");
+ ret[i] = ret[i].replaceAll("\ufffe","\r\n");
}
}
diff --git a/src/testcases/org/apache/poi/hssf/usermodel/TestEscherGraphics.java b/src/testcases/org/apache/poi/hssf/usermodel/TestEscherGraphics.java
index afeee14eda..e6d5693846 100644
--- a/src/testcases/org/apache/poi/hssf/usermodel/TestEscherGraphics.java
+++ b/src/testcases/org/apache/poi/hssf/usermodel/TestEscherGraphics.java
@@ -17,11 +17,20 @@
package org.apache.poi.hssf.usermodel;
-import junit.framework.TestCase;
+import static org.junit.Assert.assertEquals;
+import static org.junit.Assert.assertNotNull;
+import static org.junit.Assert.assertTrue;
-import java.awt.*;
+import java.awt.Color;
+import java.awt.Font;
+import java.awt.FontMetrics;
import java.io.ByteArrayInputStream;
import java.io.ByteArrayOutputStream;
+import java.io.IOException;
+
+import org.junit.After;
+import org.junit.Before;
+import org.junit.Test;
/**
* Tests the capabilities of the EscherGraphics class.
@@ -29,55 +38,62 @@ import java.io.ByteArrayOutputStream;
* All tests have two escher groups available to them,
* one anchored at 0,0,1022,255 and another anchored
* at 20,30,500,200
- *
- * @author Glen Stampoultzis (glens at apache.org)
*/
-public final class TestEscherGraphics extends TestCase {
+public final class TestEscherGraphics {
private HSSFWorkbook workbook;
private HSSFPatriarch patriarch;
private HSSFShapeGroup escherGroupA;
- private HSSFShapeGroup escherGroupB;
private EscherGraphics graphics;
- protected void setUp() throws Exception
- {
+ @Before
+ public void setUp() throws IOException {
workbook = new HSSFWorkbook();
HSSFSheet sheet = workbook.createSheet("test");
patriarch = sheet.createDrawingPatriarch();
escherGroupA = patriarch.createGroup(new HSSFClientAnchor(0,0,1022,255,(short)0,0,(short) 0,0));
- escherGroupB = patriarch.createGroup(new HSSFClientAnchor(20,30,500,200,(short)0,0,(short) 0,0));
-// escherGroup = new HSSFShapeGroup(null, new HSSFChildAnchor());
- graphics = new EscherGraphics(this.escherGroupA, workbook, Color.black, 1.0f);
- super.setUp();
+ patriarch.createGroup(new HSSFClientAnchor(20,30,500,200,(short)0,0,(short) 0,0));
+ graphics = new EscherGraphics(escherGroupA, workbook, Color.black, 1.0f);
+ }
+
+ @After
+ public void closeResources() throws IOException {
+ workbook.close();
}
+ @Test
public void testGetFont() {
Font f = graphics.getFont();
- if (f.toString().indexOf("dialog") == -1 && f.toString().indexOf("Dialog") == -1)
+ if (f.toString().indexOf("dialog") == -1 && f.toString().indexOf("Dialog") == -1) {
assertEquals("java.awt.Font[family=Arial,name=Arial,style=plain,size=10]", f.toString());
+ }
}
+ @Test
public void testGetFontMetrics() {
Font f = graphics.getFont();
- if (f.toString().indexOf("dialog") != -1 || f.toString().indexOf("Dialog") != -1)
+ if (f.toString().indexOf("dialog") != -1 || f.toString().indexOf("Dialog") != -1) {
return;
+ }
FontMetrics fontMetrics = graphics.getFontMetrics(graphics.getFont());
assertEquals(7, fontMetrics.charWidth('X'));
assertEquals("java.awt.Font[family=Arial,name=Arial,style=plain,size=10]", fontMetrics.getFont().toString());
}
+ @Test
public void testSetFont() {
Font f = new Font("Helvetica", 0, 12);
graphics.setFont(f);
assertEquals(f, graphics.getFont());
}
+ @Test
public void testSetColor() {
graphics.setColor(Color.red);
assertEquals(Color.red, graphics.getColor());
}
+ @Test
public void testFillRect() {
graphics.fillRect( 10, 10, 20, 20 );
HSSFSimpleShape s = (HSSFSimpleShape) escherGroupA.getChildren().get(0);
@@ -88,12 +104,14 @@ public final class TestEscherGraphics extends TestCase {
assertEquals(30, s.getAnchor().getDx2());
}
+ @Test
public void testDrawString() {
graphics.drawString("This is a test", 10, 10);
HSSFTextbox t = (HSSFTextbox) escherGroupA.getChildren().get(0);
assertEquals("This is a test", t.getString().getString());
}
+ @Test
public void testGetDataBackAgain() throws Exception {
HSSFSheet s;
HSSFShapeGroup s1;
@@ -284,6 +302,6 @@ public final class TestEscherGraphics extends TestCase {
assertEquals(200, s2.getAnchor().getDy2());
// Not working just yet
- //assertEquals("I am text box 1", tbox1.getString().getString());
+ assertEquals("I am text box 1", tbox1.getString().getString());
}
}
diff --git a/src/testcases/org/apache/poi/hssf/usermodel/TestEscherGraphics2d.java b/src/testcases/org/apache/poi/hssf/usermodel/TestEscherGraphics2d.java
index dc3d5f42ce..b0b4293a74 100644
--- a/src/testcases/org/apache/poi/hssf/usermodel/TestEscherGraphics2d.java
+++ b/src/testcases/org/apache/poi/hssf/usermodel/TestEscherGraphics2d.java
@@ -17,30 +17,44 @@
package org.apache.poi.hssf.usermodel;
-import junit.framework.TestCase;
+import static org.junit.Assert.assertEquals;
+import static org.junit.Assert.assertTrue;
+import static org.junit.Assert.fail;
-import java.awt.*;
+import java.awt.Color;
+import java.awt.Font;
+import java.awt.FontMetrics;
import java.awt.geom.Line2D;
+import java.io.IOException;
+
+import org.junit.After;
+import org.junit.Before;
+import org.junit.Test;
/**
* Tests the Graphics2d drawing capability.
- *
- * @author Glen Stampoultzis (glens at apache.org)
*/
-public final class TestEscherGraphics2d extends TestCase {
+public final class TestEscherGraphics2d {
+ private HSSFWorkbook workbook;
private HSSFShapeGroup escherGroup;
private EscherGraphics2d graphics;
- @Override
- protected void setUp() {
- HSSFWorkbook workbook = new HSSFWorkbook();
+ @Before
+ public void setUp() {
+ workbook = new HSSFWorkbook();
HSSFSheet sheet = workbook.createSheet("test");
escherGroup = sheet.createDrawingPatriarch().createGroup(new HSSFClientAnchor(0,0,1023,255,(short)0,0,(short) 0,0));
escherGroup = new HSSFShapeGroup(null, new HSSFChildAnchor());
- EscherGraphics g = new EscherGraphics(this.escherGroup, workbook, Color.black, 1.0f);
+ EscherGraphics g = new EscherGraphics(escherGroup, workbook, Color.black, 1.0f);
graphics = new EscherGraphics2d(g);
}
+
+ @After
+ public void closeResources() throws IOException {
+ workbook.close();
+ }
+ @Test
public void testDrawString() {
graphics.drawString("This is a test", 10, 10);
HSSFTextbox t = (HSSFTextbox) escherGroup.getChildren().get(0);
@@ -71,7 +85,8 @@ public final class TestEscherGraphics2d extends TestCase {
}
}
- public void testFillRect() {
+ @Test
+ public void testFillRect() {
graphics.fillRect( 10, 10, 20, 20 );
HSSFSimpleShape s = (HSSFSimpleShape) escherGroup.getChildren().get(0);
assertEquals(HSSFSimpleShape.OBJECT_TYPE_RECTANGLE, s.getShapeType());
@@ -81,29 +96,37 @@ public final class TestEscherGraphics2d extends TestCase {
assertEquals(30, s.getAnchor().getDx2());
}
- public void testGetFontMetrics() {
+ @Test
+ public void testGetFontMetrics() {
FontMetrics fontMetrics = graphics.getFontMetrics(graphics.getFont());
- if (isDialogPresent()) // if dialog is returned we can't run the test properly.
+ if (isDialogPresent()) {
+ // if dialog is returned we can't run the test properly.
return;
+ }
assertEquals(7, fontMetrics.charWidth('X'));
assertEquals("java.awt.Font[family=Arial,name=Arial,style=plain,size=10]", fontMetrics.getFont().toString());
}
- public void testSetFont() {
+ @Test
+ public void testSetFont() {
Font f = new Font("Helvetica", 0, 12);
graphics.setFont(f);
assertEquals(f, graphics.getFont());
}
- public void testSetColor() {
+ @Test
+ public void testSetColor() {
graphics.setColor(Color.red);
assertEquals(Color.red, graphics.getColor());
}
- public void testGetFont() {
+ @Test
+ public void testGetFont() {
Font f = graphics.getFont();
- if (isDialogPresent()) // if dialog is returned we can't run the test properly.
+ if (isDialogPresent()) {
+ // if dialog is returned we can't run the test properly.
return;
+ }
assertEquals("java.awt.Font[family=Arial,name=Arial,style=plain,size=10]", f.toString());
}
@@ -113,7 +136,8 @@ public final class TestEscherGraphics2d extends TestCase {
return fontDebugStr.indexOf("dialog") != -1 || fontDebugStr.indexOf("Dialog") != -1;
}
- public void testDraw() {
+ @Test
+ public void testDraw() {
graphics.draw(new Line2D.Double(10,10,20,20));
HSSFSimpleShape s = (HSSFSimpleShape) escherGroup.getChildren().get(0);
assertTrue(s.getShapeType() == HSSFSimpleShape.OBJECT_TYPE_LINE);
diff --git a/src/testcases/org/apache/poi/ss/usermodel/BaseTestBugzillaIssues.java b/src/testcases/org/apache/poi/ss/usermodel/BaseTestBugzillaIssues.java
index eff708ee00..945bdf86a8 100644
--- a/src/testcases/org/apache/poi/ss/usermodel/BaseTestBugzillaIssues.java
+++ b/src/testcases/org/apache/poi/ss/usermodel/BaseTestBugzillaIssues.java
@@ -68,7 +68,7 @@ public abstract class BaseTestBugzillaIssues {
* Also tests bug 15353 (problems with hyperlinks to Google)
*/
@Test
- public final void bug23094() throws Exception {
+ public final void bug23094() throws IOException {
Workbook wb1 = _testDataProvider.createWorkbook();
Sheet s = wb1.createSheet();
Row r = s.createRow(0);
@@ -92,7 +92,7 @@ public abstract class BaseTestBugzillaIssues {
* open resulting file in Excel to check results!
* @param num the number of strings to generate
*/
- public final void bug15375(int num) throws Exception {
+ public final void bug15375(int num) throws IOException {
Workbook wb1 = _testDataProvider.createWorkbook();
Sheet sheet = wb1.createSheet();
CreationHelper factory = wb1.getCreationHelper();
@@ -137,7 +137,7 @@ public abstract class BaseTestBugzillaIssues {
* Merged regions were being removed from the parent in cloned sheets
*/
@Test
- public void bug22720() throws Exception {
+ public void bug22720() throws IOException {
Workbook wb = _testDataProvider.createWorkbook();
wb.createSheet("TEST");
Sheet template = wb.getSheetAt(0);
@@ -165,7 +165,7 @@ public abstract class BaseTestBugzillaIssues {
}
@Test
- public final void bug28031() throws Exception {
+ public final void bug28031() throws IOException {
Workbook wb1 = _testDataProvider.createWorkbook();
Sheet sheet = wb1.createSheet();
wb1.setSheetName(0, "Sheet1");
@@ -191,7 +191,7 @@ public abstract class BaseTestBugzillaIssues {
* {=SUM(IF(FREQUENCY(IF(LEN(V4:V220)>0,MATCH(V4:V220,V4:V220,0),""),IF(LEN(V4:V220)>0,MATCH(V4:V220,V4:V220,0),""))>0,1))}
*/
@Test
- public final void bug21334() throws Exception {
+ public final void bug21334() throws IOException {
Workbook wb1 = _testDataProvider.createWorkbook();
Sheet sh = wb1.createSheet();
Cell cell = sh.createRow(0).createCell(0);
@@ -208,7 +208,7 @@ public abstract class BaseTestBugzillaIssues {
/** another test for the number of unique strings issue
*test opening the resulting file in Excel*/
@Test
- public final void bug22568() throws Exception {
+ public final void bug22568() throws IOException {
int r=2000;int c=3;
Workbook wb1 = _testDataProvider.createWorkbook();
@@ -260,7 +260,7 @@ public abstract class BaseTestBugzillaIssues {
* Bug 42448: Can't parse SUMPRODUCT(A!C7:A!C67, B8:B68) / B69
*/
@Test
- public final void bug42448() throws Exception {
+ public final void bug42448() throws IOException {
Workbook wb = _testDataProvider.createWorkbook();
Cell cell = wb.createSheet().createRow(0).createCell(0);
cell.setCellFormula("SUMPRODUCT(A!C7:A!C67, B8:B68) / B69");
@@ -269,7 +269,7 @@ public abstract class BaseTestBugzillaIssues {
}
@Test
- public void bug18800() throws Exception {
+ public void bug18800() throws IOException {
Workbook wb1 = _testDataProvider.createWorkbook();
wb1.createSheet("TEST");
Sheet sheet = wb1.cloneSheet(0);
@@ -300,7 +300,7 @@ public abstract class BaseTestBugzillaIssues {
}
@Test
- public void bug43093() throws Exception {
+ public void bug43093() throws IOException {
Workbook xlw = _testDataProvider.createWorkbook();
addNewSheetWithCellsA1toD4(xlw, 1);
@@ -322,7 +322,7 @@ public abstract class BaseTestBugzillaIssues {
}
@Test
- public void bug46729_testMaxFunctionArguments() throws Exception {
+ public void bug46729_testMaxFunctionArguments() throws IOException {
String[] func = {"COUNT", "AVERAGE", "MAX", "MIN", "OR", "SUBTOTAL", "SKEW"};
SpreadsheetVersion ssVersion = _testDataProvider.getSpreadsheetVersion();
@@ -362,7 +362,7 @@ public abstract class BaseTestBugzillaIssues {
}
@Test
- public final void bug50681_testAutoSize() throws Exception {
+ public final void bug50681_testAutoSize() throws IOException {
Workbook wb = _testDataProvider.createWorkbook();
BaseTestSheetAutosizeColumn.fixFonts(wb);
Sheet sheet = wb.createSheet("Sheet1");
@@ -456,7 +456,7 @@ public abstract class BaseTestBugzillaIssues {
* CreateFreezePane column/row order check
*/
@Test
- public void bug49381() throws Exception {
+ public void bug49381() throws IOException {
Workbook wb = _testDataProvider.createWorkbook();
int colSplit = 1;
int rowSplit = 2;
@@ -510,7 +510,7 @@ public abstract class BaseTestBugzillaIssues {
* open resulting file in excel, and check that there is a link to Google
*/
@Test
- public void bug15353() throws Exception {
+ public void bug15353() throws IOException {
String hyperlinkF = "HYPERLINK(\"http://google.com\",\"Google\")";
Workbook wb1 = _testDataProvider.createWorkbook();
@@ -536,7 +536,7 @@ public abstract class BaseTestBugzillaIssues {
* HLookup and VLookup with optional arguments
*/
@Test
- public void bug51024() throws Exception {
+ public void bug51024() throws IOException {
Workbook wb = _testDataProvider.createWorkbook();
Sheet s = wb.createSheet();
Row r1 = s.createRow(0);
@@ -573,7 +573,7 @@ public abstract class BaseTestBugzillaIssues {
}
@Test
- public void stackoverflow23114397() throws Exception {
+ public void stackoverflow23114397() throws IOException {
Workbook wb = _testDataProvider.createWorkbook();
DataFormat format = wb.getCreationHelper().createDataFormat();
@@ -642,7 +642,7 @@ public abstract class BaseTestBugzillaIssues {
* =ISNUMBER(SEARCH("AM",A1)) evaluation
*/
@Test
- public void stackoverflow26437323() throws Exception {
+ public void stackoverflow26437323() throws IOException {
Workbook wb = _testDataProvider.createWorkbook();
Sheet s = wb.createSheet();
Row r1 = s.createRow(0);
@@ -799,7 +799,7 @@ public abstract class BaseTestBugzillaIssues {
*/
@Ignore("Fix this to evaluate for XSSF, Fix this to work at all for HSSF")
@Test
- public void bug46670() throws Exception {
+ public void bug46670() throws IOException {
Workbook wb1 = _testDataProvider.createWorkbook();
Sheet s = wb1.createSheet();
Row r1 = s.createRow(0);
@@ -925,7 +925,7 @@ public abstract class BaseTestBugzillaIssues {
* that it now is again
*/
@Test
- public void bug48718() throws Exception {
+ public void bug48718() throws IOException {
Workbook wb = _testDataProvider.createWorkbook();
int startingFonts = wb instanceof HSSFWorkbook ? 4 : 1;
@@ -947,7 +947,7 @@ public abstract class BaseTestBugzillaIssues {
}
@Test
- public void bug57430() throws Exception {
+ public void bug57430() throws IOException {
Workbook wb = _testDataProvider.createWorkbook();
wb.createSheet("Sheet1");
@@ -1050,7 +1050,7 @@ public abstract class BaseTestBugzillaIssues {
* kind of value from a Formula cell
*/
@Test
- public void bug47815() throws Exception {
+ public void bug47815() throws IOException {
Workbook wb = _testDataProvider.createWorkbook();
Sheet s = wb.createSheet();
Row r = s.createRow(0);
@@ -1109,7 +1109,7 @@ public abstract class BaseTestBugzillaIssues {
}
@Test
- public void test58113() throws Exception {
+ public void test58113() throws IOException {
Workbook wb = _testDataProvider.createWorkbook();
Sheet sheet = wb.createSheet( "Test" );
@@ -1155,7 +1155,7 @@ public abstract class BaseTestBugzillaIssues {
* Mid in it, can give #VALUE in Excel
*/
@Test
- public void bug55747() throws Exception {
+ public void bug55747() throws IOException {
Workbook wb1 = _testDataProvider.createWorkbook();
FormulaEvaluator ev = wb1.getCreationHelper().createFormulaEvaluator();
Sheet s = wb1.createSheet();