+ * Shapes drawn with the "Freeform" tool have cubic bezier curve segments in the smooth sections
+ * and straight-line segments in the straight sections. This object closely corresponds to java.awt.geom.GeneralPath
.
+ *
EscherSpContainer
container which holds information about this shape
+ * @param parent the parent of the shape
+ */
+ protected Freeform(EscherContainerRecord escherRecord, Shape parent){
+ super(escherRecord, parent);
+
+ }
+
+ /**
+ * Create a new Freeform. This constructor is used when a new shape is created.
+ *
+ * @param parent the parent of this Shape. For example, if this text box is a cell
+ * in a table then the parent is Table.
+ */
+ public Freeform(Shape parent){
+ super(null, parent);
+ _escherContainer = createSpContainer(ShapeTypes.NotPrimitive, parent instanceof ShapeGroup);
+ }
+
+ /**
+ * Create a new Freeform. This constructor is used when a new shape is created.
+ *
+ */
+ public Freeform(){
+ this(null);
+ }
+
+ /**
+ * Set the shape path
+ *
+ * @param path
+ */
+ public void setPath(GeneralPath path)
+ {
+ Rectangle2D bounds = path.getBounds2D();
+ PathIterator it = path.getPathIterator(new AffineTransform());
+
+ ArrayList segInfo = new ArrayList();
+ ArrayList pntInfo = new ArrayList();
+ boolean isClosed = false;
+ while (!it.isDone()) {
+ double[] vals = new double[6];
+ int type = it.currentSegment(vals);
+ switch (type) {
+ case PathIterator.SEG_MOVETO:
+ pntInfo.add(new Point2D.Double(vals[0], vals[1]));
+ segInfo.add(new byte[]{0x00, 0x40});
+ break;
+ case PathIterator.SEG_LINETO:
+ pntInfo.add(new Point2D.Double(vals[0], vals[1]));
+ segInfo.add(new byte[]{0x00, (byte)0xAC});
+ segInfo.add(new byte[]{0x01, 0x00 });
+ break;
+ case PathIterator.SEG_CUBICTO:
+ pntInfo.add(new Point2D.Double(vals[0], vals[1]));
+ pntInfo.add(new Point2D.Double(vals[2], vals[3]));
+ pntInfo.add(new Point2D.Double(vals[4], vals[5]));
+ segInfo.add(new byte[]{0x00, (byte)0xAD});
+ segInfo.add(new byte[]{0x01, 0x20 });
+ break;
+ case PathIterator.SEG_QUADTO:
+ System.err.println("SEG_QUADTO is not supported");
+ break;
+ case PathIterator.SEG_CLOSE:
+ pntInfo.add(pntInfo.get(0));
+ segInfo.add(new byte[]{0x00, (byte)0xAC});
+ segInfo.add(new byte[]{0x01, 0x00 });
+ segInfo.add(new byte[]{0x00, (byte)0xAC});
+ segInfo.add(new byte[]{0x01, (byte)0x60});
+ isClosed = true;
+ break;
+ }
+
+ it.next();
+ }
+ if(!isClosed) segInfo.add(new byte[]{0x00, (byte)0xAC});
+ segInfo.add(new byte[]{0x00, (byte)0x80});
+
+ EscherOptRecord opt = (EscherOptRecord)getEscherChild(_escherContainer, EscherOptRecord.RECORD_ID);
+ opt.addEscherProperty(new EscherSimpleProperty(EscherProperties.GEOMETRY__SHAPEPATH, 0x4));
+
+ EscherArrayProperty verticesProp = new EscherArrayProperty((short)(EscherProperties.GEOMETRY__VERTICES + 0x4000), false, null);
+ verticesProp.setNumberOfElementsInArray(pntInfo.size());
+ verticesProp.setNumberOfElementsInMemory(pntInfo.size());
+ verticesProp.setSizeOfElements(0xFFF0);
+ for (int i = 0; i < pntInfo.size(); i++) {
+ Point2D.Double pnt = (Point2D.Double)pntInfo.get(i);
+ byte[] data = new byte[4];
+ LittleEndian.putShort(data, 0, (short)((pnt.getX() - bounds.getX())*MASTER_DPI/POINT_DPI));
+ LittleEndian.putShort(data, 2, (short)((pnt.getY() - bounds.getY())*MASTER_DPI/POINT_DPI));
+ verticesProp.setElement(i, data);
+ }
+ opt.addEscherProperty(verticesProp);
+
+ EscherArrayProperty segmentsProp = new EscherArrayProperty((short)(EscherProperties.GEOMETRY__SEGMENTINFO + 0x4000), false, null);
+ segmentsProp.setNumberOfElementsInArray(segInfo.size());
+ segmentsProp.setNumberOfElementsInMemory(segInfo.size());
+ segmentsProp.setSizeOfElements(0x2);
+ for (int i = 0; i < segInfo.size(); i++) {
+ byte[] seg = (byte[])segInfo.get(i);
+ segmentsProp.setElement(i, seg);
+ }
+ opt.addEscherProperty(segmentsProp);
+
+ opt.addEscherProperty(new EscherSimpleProperty(EscherProperties.GEOMETRY__RIGHT, (int)(bounds.getWidth()*MASTER_DPI/POINT_DPI)));
+ opt.addEscherProperty(new EscherSimpleProperty(EscherProperties.GEOMETRY__BOTTOM, (int)(bounds.getHeight()*MASTER_DPI/POINT_DPI)));
+
+ opt.sortProperties();
+
+ setAnchor(bounds);
+ }
+}
diff --git a/src/scratchpad/src/org/apache/poi/hslf/model/PPGraphics2D.java b/src/scratchpad/src/org/apache/poi/hslf/model/PPGraphics2D.java
index 4aad44d75..cb001ccf9 100644
--- a/src/scratchpad/src/org/apache/poi/hslf/model/PPGraphics2D.java
+++ b/src/scratchpad/src/org/apache/poi/hslf/model/PPGraphics2D.java
@@ -53,11 +53,6 @@ public class PPGraphics2D extends Graphics2D implements Cloneable {
private Color background;
private RenderingHints hints;
- /**
- * the maximum distance that the line segments used to approximate the curved segments
- */
- public static final float FLATNESS = 0.1f;
-
/**
* Construct Java Graphics object which translates graphic calls in ppt drawing layer.
*
@@ -218,29 +213,12 @@ public class PPGraphics2D extends Graphics2D implements Cloneable {
* @see #setComposite
*/
public void draw(Shape shape){
-
- PathIterator it = shape.getPathIterator(transform, FLATNESS);
- double[] prev = null;
- double[] coords = new double[6];
- double[] first = new double[6];
- if(!it.isDone()) it.currentSegment(first); //first point
- while(!it.isDone()){
- int type = it.currentSegment(coords);
- if (prev != null ){
- Line line = new Line(group);
- applyPaint(line);
- applyStroke(line);
- if (type == PathIterator.SEG_LINETO) {
- line.setAnchor(new Rectangle2D.Double(prev[0], prev[1], (coords[0] - prev[0]), (coords[1] - prev[1])));
- } else if (type == PathIterator.SEG_CLOSE){
- line.setAnchor(new Rectangle2D.Double(coords[0], coords[1], (first[0] - coords[0]), (first[1] - coords[1])));
- }
- group.addShape(line);
- }
- prev = new double[]{coords[0], coords[1]};
- it.next();
- }
-
+ GeneralPath path = new GeneralPath(transform.createTransformedShape(shape));
+ Freeform p = new Freeform(group);
+ p.setPath(path);
+ p.getFill().setForegroundColor(null);
+ applyStroke(p);
+ group.addShape(p);
}
/**
@@ -299,7 +277,7 @@ public class PPGraphics2D extends Graphics2D implements Cloneable {
* Even if top and bottom margins are set to 0 PowerPoint
* always sets extra space between the text and its bounding box.
*
- * Approximation height = ascent*2 works good enough in most cases
+ * The approximation height = ascent*2 works good enough in most cases
*/
float height = ascent * 2;
@@ -335,28 +313,12 @@ public class PPGraphics2D extends Graphics2D implements Cloneable {
* @see #setClip
*/
public void fill(Shape shape){
- PathIterator it = shape.getPathIterator(transform, FLATNESS);
- ArrayList pnt = new ArrayList();
- double[] coords = new double[6];
- while(!it.isDone()){
- int type = it.currentSegment(coords);
- if (type != PathIterator.SEG_CLOSE) {
- pnt.add(new Point2D.Double(coords[0], coords[1]));
- }
- it.next();
- }
- if(pnt.size() > 0){
- Point2D[] points = (Point2D[])pnt.toArray(new Point2D[pnt.size()]);
- Polygon p = new Polygon(group);
- p.setPoints(points);
- applyPaint(p);
-
- p.setLineColor(null); //Fills must be "No Line"
-
- Rectangle2D bounds = transform.createTransformedShape(shape).getBounds2D();
- p.setAnchor(bounds);
- group.addShape(p);
- }
+ GeneralPath path = new GeneralPath(transform.createTransformedShape(shape));
+ Freeform p = new Freeform(group);
+ p.setPath(path);
+ applyPaint(p);
+ p.setLineColor(null); //Fills must be "No Line"
+ group.addShape(p);
}
/**
@@ -459,11 +421,8 @@ public class PPGraphics2D extends Graphics2D implements Cloneable {
*/
public void drawRoundRect(int x, int y, int width, int height,
int arcWidth, int arcHeight){
- AutoShape shape = new AutoShape(ShapeTypes.RoundRectangle, group);
- shape.setFillColor(null);
- applyStroke(shape);
- shape.setAnchor(new Rectangle2D.Double(x, y, width, height));
- group.addShape(shape);
+ RoundRectangle2D rect = new RoundRectangle2D.Float(x, y, width, height, arcWidth, arcHeight);
+ draw(rect);
}
/**
@@ -493,11 +452,8 @@ public class PPGraphics2D extends Graphics2D implements Cloneable {
* @see java.awt.Graphics#drawOval
*/
public void fillOval(int x, int y, int width, int height){
- AutoShape shape = new AutoShape(ShapeTypes.Ellipse, group);
- applyPaint(shape);
- applyStroke(shape);
- shape.setAnchor(new Rectangle2D.Double(x, y, width, height));
- group.addShape(shape);
+ Ellipse2D oval = new Ellipse2D.Float(x, y, width, height);
+ fill(oval);
}
/**
@@ -518,11 +474,9 @@ public class PPGraphics2D extends Graphics2D implements Cloneable {
*/
public void fillRoundRect(int x, int y, int width, int height,
int arcWidth, int arcHeight){
- AutoShape shape = new AutoShape(ShapeTypes.RoundRectangle, group);
- applyPaint(shape);
- applyStroke(shape);
- shape.setAnchor(new Rectangle2D.Double(x, y, width, height));
- group.addShape(shape);
+
+ RoundRectangle2D rect = new RoundRectangle2D.Float(x, y, width, height, arcWidth, arcHeight);
+ fill(rect);
}
/**
@@ -563,11 +517,8 @@ public class PPGraphics2D extends Graphics2D implements Cloneable {
*/
public void fillArc(int x, int y, int width, int height,
int startAngle, int arcAngle){
- AutoShape shape = new AutoShape(ShapeTypes.Arc, group);
- applyPaint(shape);
- applyStroke(shape);
- shape.setAnchor(new Rectangle2D.Double(x, y, width, height));
- group.addShape(shape);
+ Arc2D arc = new Arc2D.Float(x, y, width, height, startAngle, arcAngle, Arc2D.PIE);
+ fill(arc);
}
/**
@@ -609,11 +560,8 @@ public class PPGraphics2D extends Graphics2D implements Cloneable {
*/
public void drawArc(int x, int y, int width, int height,
int startAngle, int arcAngle) {
- AutoShape shape = new AutoShape(ShapeTypes.Arc, group);
- shape.setFillColor(null);
- applyStroke(shape);
- shape.setAnchor(new Rectangle2D.Double(x, y, width, height));
- group.addShape(shape);
+ Arc2D arc = new Arc2D.Float(x, y, width, height, startAngle, arcAngle, Arc2D.OPEN);
+ draw(arc);
}
@@ -659,11 +607,8 @@ public class PPGraphics2D extends Graphics2D implements Cloneable {
* @see java.awt.Graphics#fillOval
*/
public void drawOval(int x, int y, int width, int height){
- AutoShape shape = new AutoShape(ShapeTypes.Ellipse, group);
- shape.setFillColor(null);
- applyStroke(shape);
- shape.setAnchor(new Rectangle2D.Double(x, y, width, height));
- group.addShape(shape);
+ Ellipse2D oval = new Ellipse2D.Float(x, y, width, height);
+ draw(oval);
}
/**
@@ -998,11 +943,8 @@ public class PPGraphics2D extends Graphics2D implements Cloneable {
* @see java.awt.Graphics#drawRect
*/
public void fillRect(int x, int y, int width, int height){
- AutoShape shape = new AutoShape(ShapeTypes.Rectangle, group);
- applyPaint(shape);
- applyStroke(shape);
- shape.setAnchor(new Rectangle2D.Double(x, y, width, height));
- group.addShape(shape);
+ Rectangle rect = new Rectangle(x, y, width, height);
+ fill(rect);
}
/**
@@ -1022,12 +964,8 @@ public class PPGraphics2D extends Graphics2D implements Cloneable {
* @see java.awt.Graphics#clearRect
*/
public void drawRect(int x, int y, int width, int height) {
- AutoShape shape = new AutoShape(ShapeTypes.Rectangle, group);
- shape.setFillColor(null);
- applyStroke(shape);
- shape.setAnchor(new Rectangle2D.Double(x, y, width, height));
- group.addShape(shape);
-
+ Rectangle rect = new Rectangle(x, y, width, height);
+ draw(rect);
}
/**
diff --git a/src/scratchpad/src/org/apache/poi/hslf/model/Picture.java b/src/scratchpad/src/org/apache/poi/hslf/model/Picture.java
index 90efd5f3e..4866779b9 100644
--- a/src/scratchpad/src/org/apache/poi/hslf/model/Picture.java
+++ b/src/scratchpad/src/org/apache/poi/hslf/model/Picture.java
@@ -21,7 +21,6 @@ import org.apache.poi.hslf.usermodel.PictureData;
import org.apache.poi.hslf.usermodel.SlideShow;
import org.apache.poi.hslf.record.Document;
import org.apache.poi.hslf.blip.Bitmap;
-import org.apache.poi.util.POILogger;
import javax.imageio.ImageIO;
import java.awt.image.BufferedImage;
@@ -179,7 +178,7 @@ public class Picture extends SimpleShape {
List lst = bstore.getChildRecords();
int idx = getPictureIndex();
if (idx == 0){
- logger.log(POILogger.ERROR, "no reference to picture data found ");
+ log.error("no reference to picture data found ");
} else {
EscherBSERecord bse = (EscherBSERecord)lst.get(idx-1);
for ( int i = 0; i < pict.length; i++ ) {
@@ -187,7 +186,7 @@ public class Picture extends SimpleShape {
return pict[i];
}
}
- logger.log(POILogger.ERROR, "no picture found for our BSE offset " + bse.getOffset());
+ log.error("no picture found for our BSE offset " + bse.getOffset());
}
return null;
}
diff --git a/src/scratchpad/src/org/apache/poi/hslf/model/Shape.java b/src/scratchpad/src/org/apache/poi/hslf/model/Shape.java
index 2e23c5926..220a512dc 100644
--- a/src/scratchpad/src/org/apache/poi/hslf/model/Shape.java
+++ b/src/scratchpad/src/org/apache/poi/hslf/model/Shape.java
@@ -19,8 +19,8 @@ package org.apache.poi.hslf.model;
import org.apache.poi.ddf.*;
import org.apache.poi.hslf.model.ShapeTypes;
import org.apache.poi.hslf.record.ColorSchemeAtom;
-import org.apache.poi.util.POILogger;
-import org.apache.poi.util.POILogFactory;
+import org.apache.commons.logging.Log;
+import org.apache.commons.logging.LogFactory;
import java.util.Iterator;
import java.awt.*;
@@ -45,7 +45,7 @@ import java.awt.geom.Rectangle2D;
public abstract class Shape {
// For logging
- protected POILogger logger = POILogFactory.getLogger(this.getClass());
+ protected Log log = LogFactory.getLog(this.getClass());
/**
* In Escher absolute distances are specified in
@@ -89,6 +89,11 @@ public abstract class Shape {
*/
protected Sheet _sheet;
+ /**
+ * Fill
+ */
+ protected Fill _fill;
+
/**
* Create a Shape object. This constructor is used when an existing Shape is read from from a PowerPoint document.
*
@@ -344,7 +349,8 @@ public abstract class Shape {
* @return fill properties of this shape
*/
public Fill getFill(){
- return new Fill(this);
+ if(_fill == null) _fill = new Fill(this);
+ return _fill;
}
diff --git a/src/scratchpad/src/org/apache/poi/hslf/model/ShapeGroup.java b/src/scratchpad/src/org/apache/poi/hslf/model/ShapeGroup.java
index dbcc8069c..7b79ebad9 100644
--- a/src/scratchpad/src/org/apache/poi/hslf/model/ShapeGroup.java
+++ b/src/scratchpad/src/org/apache/poi/hslf/model/ShapeGroup.java
@@ -18,7 +18,6 @@ package org.apache.poi.hslf.model;
import org.apache.poi.ddf.*;
import org.apache.poi.util.LittleEndian;
-import org.apache.poi.util.POILogger;
import java.util.ArrayList;
import java.util.List;
@@ -71,7 +70,7 @@ public class ShapeGroup extends Shape{
} else {
// Should we do anything special with these non
// Container records?
- logger.log(POILogger.ERROR, "Shape contained non container escher record, was " + r.getClass().getName());
+ log.error("Shape contained non container escher record, was " + r.getClass().getName());
}
}
diff --git a/src/scratchpad/src/org/apache/poi/hslf/model/SimpleShape.java b/src/scratchpad/src/org/apache/poi/hslf/model/SimpleShape.java
index 58fc33305..85d672fe8 100644
--- a/src/scratchpad/src/org/apache/poi/hslf/model/SimpleShape.java
+++ b/src/scratchpad/src/org/apache/poi/hslf/model/SimpleShape.java
@@ -187,26 +187,7 @@ public class SimpleShape extends Shape {
* The color used to fill this shape.
*/
public Color getFillColor(){
- EscherOptRecord opt = (EscherOptRecord)getEscherChild(_escherContainer, EscherOptRecord.RECORD_ID);
- EscherSimpleProperty p1 = (EscherSimpleProperty)getEscherProperty(opt, EscherProperties.FILL__FILLCOLOR);
- EscherSimpleProperty p2= (EscherSimpleProperty)getEscherProperty(opt, EscherProperties.FILL__NOFILLHITTEST);
-
- int p2val = p2 == null ? 0 : p2.getPropertyValue();
-
- Color clr = null;
- if (p1 != null && (p2val & 0x10) != 0){
- int rgb = p1.getPropertyValue();
- if (rgb >= 0x8000000) {
- int idx = rgb % 0x8000000;
- if(getSheet() != null) {
- ColorSchemeAtom ca = getSheet().getColorScheme();
- rgb = ca.getColor(idx);
- }
- }
- Color tmp = new Color(rgb, true);
- clr = new Color(tmp.getBlue(), tmp.getGreen(), tmp.getRed());
- }
- return clr;
+ return getFill().getForegroundColor();
}
/**
@@ -215,14 +196,7 @@ public class SimpleShape extends Shape {
* @param color the background color
*/
public void setFillColor(Color color){
- EscherOptRecord opt = (EscherOptRecord)getEscherChild(_escherContainer, EscherOptRecord.RECORD_ID);
- if(color == null) {
- setEscherProperty(opt, EscherProperties.FILL__NOFILLHITTEST, 0x150000);
- } else {
- int rgb = new Color(color.getBlue(), color.getGreen(), color.getRed(), 0).getRGB();
- setEscherProperty(opt, EscherProperties.FILL__FILLCOLOR, rgb);
- setEscherProperty(opt, EscherProperties.FILL__NOFILLHITTEST, 0x150011);
- }
+ getFill().setForegroundColor(color);
}
}
diff --git a/src/scratchpad/src/org/apache/poi/hslf/model/TextBox.java b/src/scratchpad/src/org/apache/poi/hslf/model/TextBox.java
index 1f9a489a7..8a54e079c 100644
--- a/src/scratchpad/src/org/apache/poi/hslf/model/TextBox.java
+++ b/src/scratchpad/src/org/apache/poi/hslf/model/TextBox.java
@@ -22,7 +22,6 @@ import org.apache.poi.ddf.*;
import org.apache.poi.hslf.record.*;
import org.apache.poi.hslf.usermodel.RichTextRun;
import org.apache.poi.hslf.exceptions.HSLFException;
-import org.apache.poi.util.POILogger;
import java.awt.*;
import java.awt.font.FontRenderContext;
@@ -480,7 +479,7 @@ public class TextBox extends SimpleShape {
}
}
if(_txtrun == null) {
- logger.log(POILogger.WARN, "text run not found for OutlineTextRefAtom.TextIndex=" + idx);
+ log.warn("text run not found for OutlineTextRefAtom.TextIndex=" + idx);
}
} else {
int shapeId = _escherContainer.getChildById(EscherSpRecord.RECORD_ID).getShapeId();
diff --git a/src/scratchpad/src/org/apache/poi/hslf/record/Document.java b/src/scratchpad/src/org/apache/poi/hslf/record/Document.java
index f6252840c..c5b217b36 100644
--- a/src/scratchpad/src/org/apache/poi/hslf/record/Document.java
+++ b/src/scratchpad/src/org/apache/poi/hslf/record/Document.java
@@ -19,8 +19,6 @@
package org.apache.poi.hslf.record;
-import org.apache.poi.util.POILogger;
-
import java.io.IOException;
import java.io.OutputStream;
@@ -134,10 +132,10 @@ public class Document extends PositionDependentRecordContainer
// (normally it's 2, or 3 if you have notes)
// Complain if it's not
if(slwtcount == 0) {
- logger.log(POILogger.WARN, "No SlideListWithText's found - there should normally be at least one!");
+ logger.warn("No SlideListWithText's found - there should normally be at least one!");
}
if(slwtcount > 3) {
- logger.log(POILogger.WARN, "Found " + slwtcount + " SlideListWithTexts - normally there should only be three!");
+ logger.warn("Found " + slwtcount + " SlideListWithTexts - normally there should only be three!");
}
// Now grab all the SLWTs
diff --git a/src/scratchpad/src/org/apache/poi/hslf/record/ExEmbed.java b/src/scratchpad/src/org/apache/poi/hslf/record/ExEmbed.java
index a021d6b10..57c79afe1 100644
--- a/src/scratchpad/src/org/apache/poi/hslf/record/ExEmbed.java
+++ b/src/scratchpad/src/org/apache/poi/hslf/record/ExEmbed.java
@@ -21,7 +21,6 @@ import java.io.OutputStream;
import java.io.IOException;
import org.apache.poi.util.LittleEndian;
-import org.apache.poi.util.POILogger;
/**
* This data represents an embedded object in the document.
@@ -94,14 +93,14 @@ public class ExEmbed extends RecordContainer {
if(_children[0] instanceof ExEmbedAtom) {
embedAtom = (ExEmbedAtom)_children[0];
} else {
- logger.log(POILogger.ERROR, "First child record wasn't a ExEmbedAtom, was of type " + _children[0].getRecordType());
+ logger.error("First child record wasn't a ExEmbedAtom, was of type " + _children[0].getRecordType());
}
// Second child should be the ExOleObjAtom
if (_children[1] instanceof ExOleObjAtom) {
oleObjAtom = (ExOleObjAtom)_children[1];
} else {
- logger.log(POILogger.ERROR, "Second child record wasn't a ExOleObjAtom, was of type " + _children[1].getRecordType());
+ logger.error("Second child record wasn't a ExOleObjAtom, was of type " + _children[1].getRecordType());
}
for (int i = 2; i < _children.length; i++) {
@@ -110,15 +109,15 @@ public class ExEmbed extends RecordContainer {
else if (progId == null) progId = (CString)_children[i];
else if (clipboardName == null) clipboardName = (CString)_children[i];
} else {
- logger.log(POILogger.ERROR, "Record after atoms wasn't a CString, was of type " + _children[i].getRecordType());
+ logger.error("Record after atoms wasn't a CString, was of type " + _children[i].getRecordType());
}
}
}
/**
- * Gets the {@code ExEmbedAtom}.
+ * Gets the {@link ExEmbedAtom}.
*
- * @return the {@code ExEmbedAtom}.
+ * @return the {@link ExEmbedAtom}.
*/
public ExEmbedAtom getExEmbedAtom()
{
@@ -126,9 +125,9 @@ public class ExEmbed extends RecordContainer {
}
/**
- * Gets the {@code ExOleObjAtom}.
+ * Gets the {@link ExOleObjAtom}.
*
- * @return the {@code ExOleObjAtom}.
+ * @return the {@link ExOleObjAtom}.
*/
public ExOleObjAtom getExOleObjAtom()
{
diff --git a/src/scratchpad/src/org/apache/poi/hslf/record/ExHyperlink.java b/src/scratchpad/src/org/apache/poi/hslf/record/ExHyperlink.java
index 8ba58cdb6..1832e0901 100644
--- a/src/scratchpad/src/org/apache/poi/hslf/record/ExHyperlink.java
+++ b/src/scratchpad/src/org/apache/poi/hslf/record/ExHyperlink.java
@@ -20,7 +20,6 @@ import java.io.IOException;
import java.io.OutputStream;
import org.apache.poi.util.LittleEndian;
-import org.apache.poi.util.POILogger;
/**
* This class represents the data of a link in the document.
@@ -108,7 +107,7 @@ public class ExHyperlink extends RecordContainer {
if(_children[0] instanceof ExHyperlinkAtom) {
linkAtom = (ExHyperlinkAtom)_children[0];
} else {
- logger.log(POILogger.ERROR, "First child record wasn't a ExHyperlinkAtom, was of type " + _children[0].getRecordType());
+ logger.error("First child record wasn't a ExHyperlinkAtom, was of type " + _children[0].getRecordType());
}
for (int i = 1; i < _children.length; i++) {
@@ -116,7 +115,7 @@ public class ExHyperlink extends RecordContainer {
if ( linkDetailsA == null) linkDetailsA = (CString)_children[i];
else linkDetailsB = (CString)_children[i];
} else {
- logger.log(POILogger.ERROR, "Record after ExHyperlinkAtom wasn't a CString, was of type " + _children[1].getRecordType());
+ logger.error("Record after ExHyperlinkAtom wasn't a CString, was of type " + _children[1].getRecordType());
}
}
diff --git a/src/scratchpad/src/org/apache/poi/hslf/record/FontCollection.java b/src/scratchpad/src/org/apache/poi/hslf/record/FontCollection.java
index e4ee95657..17ab33841 100644
--- a/src/scratchpad/src/org/apache/poi/hslf/record/FontCollection.java
+++ b/src/scratchpad/src/org/apache/poi/hslf/record/FontCollection.java
@@ -18,9 +18,6 @@
package org.apache.poi.hslf.record;
-import org.apache.poi.util.LittleEndian;
-import org.apache.poi.util.POILogger;
-
import java.io.*;
import java.util.*;
@@ -49,7 +46,7 @@ public class FontCollection extends RecordContainer {
FontEntityAtom atom = (FontEntityAtom)_children[i];
fonts.add(atom.getFontName());
} else {
- logger.log(POILogger.WARN, "Warning: FontCollection child wasn't a FontEntityAtom, was " + _children[i]);
+ logger.warn("Warning: FontCollection child wasn't a FontEntityAtom, was " + _children[i]);
}
}
}
diff --git a/src/scratchpad/src/org/apache/poi/hslf/record/PPDrawing.java b/src/scratchpad/src/org/apache/poi/hslf/record/PPDrawing.java
index e42b358b8..b0602bc46 100644
--- a/src/scratchpad/src/org/apache/poi/hslf/record/PPDrawing.java
+++ b/src/scratchpad/src/org/apache/poi/hslf/record/PPDrawing.java
@@ -20,7 +20,6 @@
package org.apache.poi.hslf.record;
import org.apache.poi.util.LittleEndian;
-import org.apache.poi.util.POILogger;
import org.apache.poi.ddf.*;
import org.apache.poi.hslf.model.ShapeTypes;
@@ -132,7 +131,7 @@ public class PPDrawing extends RecordAtom
// Wind on
int size = r.getRecordSize();
if(size < 8) {
- logger.log(POILogger.WARN, "Hit short DDF record at " + startPos + " - " + size);
+ logger.warn("Hit short DDF record at " + startPos + " - " + size);
}
/**
@@ -142,7 +141,7 @@ public class PPDrawing extends RecordAtom
* Sometimes it is not so, see an example in bug #44770. Most likely reason is that one of ddf records calculates wrong size.
*/
if(size != escherBytes){
- logger.log(POILogger.WARN, "Record length=" + escherBytes + " but getRecordSize() returned " + r.getRecordSize() + "; record: " + r.getClass());
+ logger.warn("Record length=" + escherBytes + " but getRecordSize() returned " + r.getRecordSize() + "; record: " + r.getClass());
size = escherBytes;
}
startPos += size;
diff --git a/src/scratchpad/src/org/apache/poi/hslf/record/PersistPtrHolder.java b/src/scratchpad/src/org/apache/poi/hslf/record/PersistPtrHolder.java
index 68b8b7caf..7f9d64680 100644
--- a/src/scratchpad/src/org/apache/poi/hslf/record/PersistPtrHolder.java
+++ b/src/scratchpad/src/org/apache/poi/hslf/record/PersistPtrHolder.java
@@ -20,7 +20,6 @@
package org.apache.poi.hslf.record;
import org.apache.poi.util.LittleEndian;
-import org.apache.poi.util.POILogger;
import java.io.IOException;
import java.io.OutputStream;
@@ -195,8 +194,8 @@ public class PersistPtrHolder extends PositionDependentRecordAtom
Integer newPos = (Integer)oldToNewReferencesLookup.get(oldPos);
if(newPos == null) {
- logger.log(POILogger.WARN, "Couldn't find the new location of the \"slide\" with id " + id + " that used to be at " + oldPos);
- logger.log(POILogger.WARN, "Not updating the position of it, you probably won't be able to find it any more (if you ever could!)");
+ logger.warn("Couldn't find the new location of the \"slide\" with id " + id + " that used to be at " + oldPos);
+ logger.warn("Not updating the position of it, you probably won't be able to find it any more (if you ever could!)");
newPos = oldPos;
}
diff --git a/src/scratchpad/src/org/apache/poi/hslf/record/Record.java b/src/scratchpad/src/org/apache/poi/hslf/record/Record.java
index 1aface94c..44cde7595 100644
--- a/src/scratchpad/src/org/apache/poi/hslf/record/Record.java
+++ b/src/scratchpad/src/org/apache/poi/hslf/record/Record.java
@@ -24,9 +24,9 @@ import java.io.IOException;
import java.io.OutputStream;
import java.util.Vector;
import org.apache.poi.util.LittleEndian;
-import org.apache.poi.util.POILogger;
-import org.apache.poi.util.POILogFactory;
import org.apache.poi.hslf.exceptions.CorruptPowerPointFileException;
+import org.apache.commons.logging.Log;
+import org.apache.commons.logging.LogFactory;
/**
@@ -40,7 +40,7 @@ import org.apache.poi.hslf.exceptions.CorruptPowerPointFileException;
public abstract class Record
{
// For logging
- protected POILogger logger = POILogFactory.getLogger(this.getClass());
+ protected Log logger = LogFactory.getLog(this.getClass());
/**
* Is this record type an Atom record (only has data),
diff --git a/src/scratchpad/src/org/apache/poi/hslf/record/StyleTextPropAtom.java b/src/scratchpad/src/org/apache/poi/hslf/record/StyleTextPropAtom.java
index fdaa9eec2..72e17722c 100644
--- a/src/scratchpad/src/org/apache/poi/hslf/record/StyleTextPropAtom.java
+++ b/src/scratchpad/src/org/apache/poi/hslf/record/StyleTextPropAtom.java
@@ -31,7 +31,6 @@ import org.apache.poi.hslf.model.textproperties.ParagraphFlagsTextProp;
import org.apache.poi.hslf.model.textproperties.TextProp;
import org.apache.poi.hslf.model.textproperties.TextPropCollection;
import org.apache.poi.util.LittleEndian;
-import org.apache.poi.util.POILogger;
/**
* A StyleTextPropAtom (type 4001). Holds basic character properties
@@ -293,7 +292,7 @@ public class StyleTextPropAtom extends RecordAtom
}
if (rawContents.length > 0 && textHandled != (size+1)){
- logger.log(POILogger.WARN, "Problem reading paragraph style runs: textHandled = " + textHandled + ", text.size+1 = " + (size+1));
+ logger.warn("Problem reading paragraph style runs: textHandled = " + textHandled + ", text.size+1 = " + (size+1));
}
// Now do the character stylings
@@ -328,7 +327,7 @@ public class StyleTextPropAtom extends RecordAtom
}
}
if (rawContents.length > 0 && textHandled != (size+1)){
- logger.log(POILogger.WARN, "Problem reading character style runs: textHandled = " + textHandled + ", text.size+1 = " + (size+1));
+ logger.warn("Problem reading character style runs: textHandled = " + textHandled + ", text.size+1 = " + (size+1));
}
// Handle anything left over
diff --git a/src/scratchpad/src/org/apache/poi/hslf/usermodel/SlideShow.java b/src/scratchpad/src/org/apache/poi/hslf/usermodel/SlideShow.java
index 02db3567c..105bca5d4 100644
--- a/src/scratchpad/src/org/apache/poi/hslf/usermodel/SlideShow.java
+++ b/src/scratchpad/src/org/apache/poi/hslf/usermodel/SlideShow.java
@@ -37,8 +37,8 @@ import org.apache.poi.hslf.record.*;
import org.apache.poi.hslf.exceptions.CorruptPowerPointFileException;
import org.apache.poi.hslf.exceptions.HSLFException;
import org.apache.poi.util.ArrayUtil;
-import org.apache.poi.util.POILogFactory;
-import org.apache.poi.util.POILogger;
+import org.apache.commons.logging.Log;
+import org.apache.commons.logging.LogFactory;
/**
* This class is a friendly wrapper on top of the more scary HSLFSlideShow.
@@ -80,7 +80,7 @@ public class SlideShow
private FontCollection _fonts;
// For logging
- private POILogger logger = POILogFactory.getLogger(this.getClass());
+ private static final Log logger = LogFactory.getLog(SlideShow.class);
/* ===============================================================
@@ -275,7 +275,7 @@ public class SlideShow
Record r = _mostRecentCoreRecords[coreRecordId.intValue()];
return r;
} else {
- logger.log(POILogger.ERROR, "We tried to look up a reference to a core record, but there was no core ID for reference ID " + refID);
+ logger.error("We tried to look up a reference to a core record, but there was no core ID for reference ID " + refID);
return null;
}
}
@@ -378,7 +378,7 @@ public class SlideShow
Integer slideId = new Integer(spa.getSlideIdentifier());
slideIdToNotes.put(slideId, new Integer(i));
} else {
- logger.log(POILogger.ERROR, "A Notes SlideAtomSet at " + i + " said its record was at refID " + notesSets[i].getSlidePersistAtom().getRefID() + ", but that was actually a " + r);
+ logger.error("A Notes SlideAtomSet at " + i + " said its record was at refID " + notesSets[i].getSlidePersistAtom().getRefID() + ", but that was actually a " + r);
}
}
notesRecords = new org.apache.poi.hslf.record.Notes[notesRecordsL.size()];
@@ -404,7 +404,7 @@ public class SlideShow
if(r instanceof org.apache.poi.hslf.record.Slide) {
slidesRecords[i] = (org.apache.poi.hslf.record.Slide)r;
} else {
- logger.log(POILogger.ERROR, "A Slide SlideAtomSet at " + i + " said its record was at refID " + slidesSets[i].getSlidePersistAtom().getRefID() + ", but that was actually a " + r);
+ logger.error("A Slide SlideAtomSet at " + i + " said its record was at refID " + slidesSets[i].getSlidePersistAtom().getRefID() + ", but that was actually a " + r);
}
}
}
@@ -429,7 +429,7 @@ public class SlideShow
if (noteId != 0){
Integer notesPos = (Integer)slideIdToNotes.get(new Integer(noteId));
if (notesPos != null) notes = _notes[notesPos.intValue()];
- else logger.log(POILogger.ERROR, "Notes not found for noteId=" + noteId);
+ else logger.error("Notes not found for noteId=" + noteId);
}
// Now, build our slide
@@ -622,7 +622,7 @@ public class SlideShow
System.arraycopy(_slides, 0, s, 0, _slides.length);
s[_slides.length] = slide;
_slides = s;
- logger.log(POILogger.INFO, "Added slide " + _slides.length + " with ref " + sp.getRefID() + " and identifier " + sp.getSlideIdentifier());
+ logger.info("Added slide " + _slides.length + " with ref " + sp.getRefID() + " and identifier " + sp.getSlideIdentifier());
// Add the core records for this new Slide to the record tree
org.apache.poi.hslf.record.Slide slideRecord = slide.getSlideRecord();
@@ -658,7 +658,7 @@ public class SlideShow
// (Also need to tell it where it is)
slideRecord.setLastOnDiskOffset(slideOffset);
ptr.addSlideLookup(sp.getRefID(), slideOffset);
- logger.log(POILogger.INFO, "New slide ended up at " + slideOffset);
+ logger.info("New slide ended up at " + slideOffset);
// Last view is now of the slide
usr.setLastViewType((short)UserEditAtom.LAST_VIEW_SLIDE_VIEW);
diff --git a/src/scratchpad/testcases/org/apache/poi/hslf/model/TestPPGraphics2D.java b/src/scratchpad/testcases/org/apache/poi/hslf/model/TestPPGraphics2D.java
index 12aca6fa3..7efe956e2 100644
--- a/src/scratchpad/testcases/org/apache/poi/hslf/model/TestPPGraphics2D.java
+++ b/src/scratchpad/testcases/org/apache/poi/hslf/model/TestPPGraphics2D.java
@@ -83,7 +83,7 @@ public class TestPPGraphics2D extends TestCase {
group = (ShapeGroup)shape[0];
shape = group.getShapes();
- assertEquals(shape.length, 7);
+ assertEquals(shape.length, 3);
}
}