]> source.dussan.org Git - poi.git/commitdiff
common sl: reworked and unified generics definitions
authorAndreas Beeker <kiwiwings@apache.org>
Mon, 24 Aug 2015 23:15:14 +0000 (23:15 +0000)
committerAndreas Beeker <kiwiwings@apache.org>
Mon, 24 Aug 2015 23:15:14 +0000 (23:15 +0000)
made various methods available through common sl
added createTextBox,AutoShape,... methods to ShapeContainers
hslf tables created by poi, will be identified as such when the file is read again

git-svn-id: https://svn.apache.org/repos/asf/poi/trunk@1697515 13f79535-47bb-0310-9956-ffa450edef68

96 files changed:
src/integrationtest/org/apache/poi/stress/SlideShowHandler.java
src/java/org/apache/poi/ddf/EscherContainerRecord.java
src/java/org/apache/poi/sl/draw/DrawAutoShape.java
src/java/org/apache/poi/sl/draw/DrawBackground.java
src/java/org/apache/poi/sl/draw/DrawConnectorShape.java
src/java/org/apache/poi/sl/draw/DrawFactory.java
src/java/org/apache/poi/sl/draw/DrawFreeformShape.java
src/java/org/apache/poi/sl/draw/DrawGroupShape.java
src/java/org/apache/poi/sl/draw/DrawMasterSheet.java
src/java/org/apache/poi/sl/draw/DrawNothing.java
src/java/org/apache/poi/sl/draw/DrawPaint.java
src/java/org/apache/poi/sl/draw/DrawPictureShape.java
src/java/org/apache/poi/sl/draw/DrawShape.java
src/java/org/apache/poi/sl/draw/DrawSheet.java
src/java/org/apache/poi/sl/draw/DrawSimpleShape.java
src/java/org/apache/poi/sl/draw/DrawSlide.java
src/java/org/apache/poi/sl/draw/DrawTableShape.java
src/java/org/apache/poi/sl/draw/DrawTextBox.java
src/java/org/apache/poi/sl/draw/DrawTextParagraph.java
src/java/org/apache/poi/sl/draw/DrawTextShape.java
src/java/org/apache/poi/sl/usermodel/AutoShape.java
src/java/org/apache/poi/sl/usermodel/Background.java
src/java/org/apache/poi/sl/usermodel/ConnectorShape.java
src/java/org/apache/poi/sl/usermodel/FreeformShape.java
src/java/org/apache/poi/sl/usermodel/GroupShape.java
src/java/org/apache/poi/sl/usermodel/Line.java
src/java/org/apache/poi/sl/usermodel/MasterSheet.java
src/java/org/apache/poi/sl/usermodel/Notes.java
src/java/org/apache/poi/sl/usermodel/PictureShape.java
src/java/org/apache/poi/sl/usermodel/PlaceableShape.java
src/java/org/apache/poi/sl/usermodel/Shape.java
src/java/org/apache/poi/sl/usermodel/ShapeContainer.java
src/java/org/apache/poi/sl/usermodel/Sheet.java
src/java/org/apache/poi/sl/usermodel/SimpleShape.java
src/java/org/apache/poi/sl/usermodel/Slide.java
src/java/org/apache/poi/sl/usermodel/SlideShow.java
src/java/org/apache/poi/sl/usermodel/TableCell.java [new file with mode: 0644]
src/java/org/apache/poi/sl/usermodel/TableShape.java
src/java/org/apache/poi/sl/usermodel/TextBox.java
src/java/org/apache/poi/sl/usermodel/TextParagraph.java
src/java/org/apache/poi/sl/usermodel/TextShape.java
src/ooxml/java/org/apache/poi/xslf/usermodel/XMLSlideShow.java
src/ooxml/java/org/apache/poi/xslf/usermodel/XSLFAutoShape.java
src/ooxml/java/org/apache/poi/xslf/usermodel/XSLFBackground.java
src/ooxml/java/org/apache/poi/xslf/usermodel/XSLFConnectorShape.java
src/ooxml/java/org/apache/poi/xslf/usermodel/XSLFFreeformShape.java
src/ooxml/java/org/apache/poi/xslf/usermodel/XSLFGroupShape.java
src/ooxml/java/org/apache/poi/xslf/usermodel/XSLFNotes.java
src/ooxml/java/org/apache/poi/xslf/usermodel/XSLFNotesMaster.java
src/ooxml/java/org/apache/poi/xslf/usermodel/XSLFPictureShape.java
src/ooxml/java/org/apache/poi/xslf/usermodel/XSLFShape.java
src/ooxml/java/org/apache/poi/xslf/usermodel/XSLFShapeContainer.java
src/ooxml/java/org/apache/poi/xslf/usermodel/XSLFSheet.java
src/ooxml/java/org/apache/poi/xslf/usermodel/XSLFSimpleShape.java
src/ooxml/java/org/apache/poi/xslf/usermodel/XSLFSlide.java
src/ooxml/java/org/apache/poi/xslf/usermodel/XSLFSlideLayout.java
src/ooxml/java/org/apache/poi/xslf/usermodel/XSLFSlideMaster.java
src/ooxml/java/org/apache/poi/xslf/usermodel/XSLFTable.java
src/ooxml/java/org/apache/poi/xslf/usermodel/XSLFTableCell.java
src/ooxml/java/org/apache/poi/xslf/usermodel/XSLFTextBox.java
src/ooxml/java/org/apache/poi/xslf/usermodel/XSLFTextParagraph.java
src/ooxml/java/org/apache/poi/xslf/usermodel/XSLFTextShape.java
src/ooxml/java/org/apache/poi/xslf/util/PPTX2PNG.java
src/ooxml/testcases/org/apache/poi/xslf/usermodel/TestXSLFTextParagraph.java
src/scratchpad/src/org/apache/poi/hslf/model/ActiveXShape.java
src/scratchpad/src/org/apache/poi/hslf/model/MovieShape.java
src/scratchpad/src/org/apache/poi/hslf/model/OLEShape.java
src/scratchpad/src/org/apache/poi/hslf/model/Placeholder.java
src/scratchpad/src/org/apache/poi/hslf/model/Polygon.java
src/scratchpad/src/org/apache/poi/hslf/usermodel/HSLFAutoShape.java
src/scratchpad/src/org/apache/poi/hslf/usermodel/HSLFBackground.java
src/scratchpad/src/org/apache/poi/hslf/usermodel/HSLFConnectorShape.java [new file with mode: 0644]
src/scratchpad/src/org/apache/poi/hslf/usermodel/HSLFFill.java
src/scratchpad/src/org/apache/poi/hslf/usermodel/HSLFFreeformShape.java
src/scratchpad/src/org/apache/poi/hslf/usermodel/HSLFGroupShape.java
src/scratchpad/src/org/apache/poi/hslf/usermodel/HSLFLine.java
src/scratchpad/src/org/apache/poi/hslf/usermodel/HSLFMasterSheet.java
src/scratchpad/src/org/apache/poi/hslf/usermodel/HSLFNotes.java
src/scratchpad/src/org/apache/poi/hslf/usermodel/HSLFPictureShape.java
src/scratchpad/src/org/apache/poi/hslf/usermodel/HSLFShape.java
src/scratchpad/src/org/apache/poi/hslf/usermodel/HSLFShapeContainer.java [new file with mode: 0644]
src/scratchpad/src/org/apache/poi/hslf/usermodel/HSLFShapeFactory.java
src/scratchpad/src/org/apache/poi/hslf/usermodel/HSLFSheet.java
src/scratchpad/src/org/apache/poi/hslf/usermodel/HSLFSimpleShape.java
src/scratchpad/src/org/apache/poi/hslf/usermodel/HSLFSlide.java
src/scratchpad/src/org/apache/poi/hslf/usermodel/HSLFSlideShow.java
src/scratchpad/src/org/apache/poi/hslf/usermodel/HSLFTable.java
src/scratchpad/src/org/apache/poi/hslf/usermodel/HSLFTableCell.java
src/scratchpad/src/org/apache/poi/hslf/usermodel/HSLFTextBox.java
src/scratchpad/src/org/apache/poi/hslf/usermodel/HSLFTextParagraph.java
src/scratchpad/src/org/apache/poi/hslf/usermodel/HSLFTextShape.java
src/scratchpad/testcases/org/apache/poi/hslf/model/TestBackground.java
src/scratchpad/testcases/org/apache/poi/hslf/model/TestShapes.java
src/scratchpad/testcases/org/apache/poi/hslf/model/TestTable.java
src/scratchpad/testcases/org/apache/poi/hslf/usermodel/TestBugs.java
src/scratchpad/testcases/org/apache/poi/hslf/usermodel/TestPicture.java

index a4de13e407315fd7299405adb4a8d632ae23577a..c1c13024184b8450607bf11b569a5d59077c91ec 100644 (file)
@@ -31,7 +31,6 @@ import java.util.Map;
 import org.apache.poi.openxml4j.exceptions.InvalidFormatException;\r
 import org.apache.poi.sl.SlideShowFactory;\r
 import org.apache.poi.sl.draw.Drawable;\r
-import org.apache.poi.sl.usermodel.Notes;\r
 import org.apache.poi.sl.usermodel.Shape;\r
 import org.apache.poi.sl.usermodel.ShapeContainer;\r
 import org.apache.poi.sl.usermodel.Slide;\r
@@ -42,7 +41,7 @@ import org.apache.poi.sl.usermodel.TextShape;
 import org.apache.poi.util.JvmBugs;\r
 \r
 public abstract class SlideShowHandler extends POIFSFileHandler {\r
-    public void handleSlideShow(SlideShow ss) throws IOException {\r
+    public void handleSlideShow(SlideShow<?,?> ss) throws IOException {\r
         renderSlides(ss);\r
 \r
         readContent(ss);\r
@@ -53,7 +52,7 @@ public abstract class SlideShowHandler extends POIFSFileHandler {
         readContent(ss);\r
 \r
         // read in the writen file\r
-        SlideShow read;\r
+        SlideShow<?,?> read;\r
         try {\r
             read = SlideShowFactory.create(new ByteArrayInputStream(out.toByteArray()));\r
         } catch (InvalidFormatException e) {\r
@@ -65,7 +64,7 @@ public abstract class SlideShowHandler extends POIFSFileHandler {
         \r
     }\r
 \r
-    private ByteArrayOutputStream writeToArray(SlideShow ss) throws IOException {\r
+    private ByteArrayOutputStream writeToArray(SlideShow<?,?> ss) throws IOException {\r
         ByteArrayOutputStream stream = new ByteArrayOutputStream();\r
         try {\r
             ss.write(stream);\r
@@ -77,8 +76,8 @@ public abstract class SlideShowHandler extends POIFSFileHandler {
     }\r
 \r
     \r
-    private void readContent(SlideShow ss) {\r
-        for (Slide<?,?,? extends Notes<?,?>> s : ss.getSlides()) {\r
+    private void readContent(SlideShow<?,?> ss) {\r
+        for (Slide<?,?> s : ss.getSlides()) {\r
             s.getTitle();\r
             readText(s);\r
             readText(s.getNotes());\r
@@ -86,12 +85,11 @@ public abstract class SlideShowHandler extends POIFSFileHandler {
         }\r
     }\r
     \r
-    @SuppressWarnings("unchecked")\r
-    private void readText(ShapeContainer<?> sc) {\r
+    private void readText(ShapeContainer<?,?> sc) {\r
         if (sc == null) return;\r
-        for (Shape s : sc) {\r
+        for (Shape<?,?> s : sc) {\r
             if (s instanceof TextShape) {\r
-                for (TextParagraph<? extends TextRun> tp : (TextShape<TextParagraph<? extends TextRun>>)s) {\r
+                for (TextParagraph<?,?,?> tp : (TextShape<?,?>)s) {\r
                     for (TextRun tr : tp) {\r
                         tr.getRawText();\r
                     }\r
@@ -100,10 +98,10 @@ public abstract class SlideShowHandler extends POIFSFileHandler {
         }\r
     }\r
     \r
-    private void renderSlides(SlideShow ss) {\r
+    private void renderSlides(SlideShow<?,?> ss) {\r
         Dimension pgsize = ss.getPageSize();\r
 \r
-        for (Slide<?,?,?> s : ss.getSlides()) {\r
+        for (Slide<?,?> s : ss.getSlides()) {\r
             BufferedImage img = new BufferedImage(pgsize.width, pgsize.height, BufferedImage.TYPE_INT_ARGB);\r
             Graphics2D graphics = img.createGraphics();\r
             fixFonts(graphics);\r
index d6139436aaa857fcfbe144c3062db0a15e6fe5ce..3cb6ddd52faa5b394bf6b771599f382d56706f63 100644 (file)
@@ -221,13 +221,13 @@ public final class EscherContainerRecord extends EscherRecord {
     }
 
     public void addChildBefore(EscherRecord record, int insertBeforeRecordId) {
-        for (int i = 0; i < _childRecords.size(); i++) {
-            EscherRecord rec = _childRecords.get(i);
-            if(rec.getRecordId() == insertBeforeRecordId){
-                _childRecords.add(i++, record);
-                // TODO - keep looping? Do we expect multiple matches?
-            }
+        int idx = 0;
+        for (EscherRecord rec : _childRecords) {
+            if(rec.getRecordId() == (short)insertBeforeRecordId) break;
+            // TODO - keep looping? Do we expect multiple matches?
+            idx++;
         }
+        _childRecords.add(idx, record);
     }
 
     public String toString()
index 6af2b4b9c18d56669483edee04e7c9504f98b8d9..9cda7a32a674735595017b78cad8d161ac1057a3 100644 (file)
@@ -20,8 +20,8 @@ package org.apache.poi.sl.draw;
 import org.apache.poi.sl.usermodel.*;\r
 \r
 \r
-public class DrawAutoShape<T extends AutoShape<? extends TextParagraph<? extends TextRun>>> extends DrawTextShape<T> {\r
-    public DrawAutoShape(T shape) {\r
+public class DrawAutoShape extends DrawTextShape {\r
+    public DrawAutoShape(AutoShape<?,?> shape) {\r
         super(shape);\r
     }\r
 }\r
index 35c844d8d053682810a9136ff6f9cc095df7af08..4072fe4bcd01f11521aa7145b474d1f5120a202b 100644 (file)
 \r
 package org.apache.poi.sl.draw;\r
 \r
-import java.awt.*;\r
+import java.awt.Dimension;\r
+import java.awt.Graphics2D;\r
+import java.awt.Paint;\r
 import java.awt.geom.Rectangle2D;\r
 \r
-import org.apache.poi.sl.usermodel.*;\r
-import org.apache.poi.sl.usermodel.Shape;\r
+import org.apache.poi.sl.usermodel.Background;\r
+import org.apache.poi.sl.usermodel.PlaceableShape;\r
+import org.apache.poi.sl.usermodel.ShapeContainer;\r
 \r
 \r
-public class DrawBackground<T extends Background> extends DrawShape<T> {\r
-    public DrawBackground(T shape) {\r
+public class DrawBackground extends DrawShape {\r
+    public DrawBackground(Background<?,?> shape) {\r
         super(shape);\r
     }\r
 \r
+    @SuppressWarnings("rawtypes")\r
     public void draw(Graphics2D graphics) {\r
         Dimension pg = shape.getSheet().getSlideShow().getPageSize();\r
         final Rectangle2D anchor = new Rectangle2D.Double(0, 0, pg.getWidth(), pg.getHeight());\r
 \r
-        PlaceableShape ps = new PlaceableShape(){\r
-            public ShapeContainer<? extends Shape> getParent() { return null; }\r
+        PlaceableShape<?,?> ps = new PlaceableShape(){\r
+            public ShapeContainer<?,?> getParent() { return null; }\r
             public Rectangle2D getAnchor() { return anchor; }\r
             public void setAnchor(Rectangle2D anchor) {}\r
             public double getRotation() { return 0; }\r
@@ -47,7 +51,7 @@ public class DrawBackground<T extends Background> extends DrawShape<T> {
         \r
         DrawFactory drawFact = DrawFactory.getInstance(graphics);\r
         DrawPaint dp = drawFact.getPaint(ps);\r
-        Paint fill = dp.getPaint(graphics, shape.getFillStyle().getPaint());\r
+        Paint fill = dp.getPaint(graphics, getShape().getFillStyle().getPaint());\r
         Rectangle2D anchor2 = getAnchor(graphics, anchor);\r
         \r
         if(fill != null) {\r
@@ -56,5 +60,7 @@ public class DrawBackground<T extends Background> extends DrawShape<T> {
         }\r
     }\r
     \r
-    \r
+    protected Background<?,?> getShape() {\r
+        return (Background<?,?>)shape;\r
+    }\r
 }\r
index 0fee07cf6dd01284b9358bab42d9a7652e76a867..00bcd1b58e9609ee3b5fd13ed51030d541b9992c 100644 (file)
 \r
 package org.apache.poi.sl.draw;\r
 \r
-import org.apache.poi.sl.usermodel.*;\r
+import org.apache.poi.sl.usermodel.ConnectorShape;\r
 \r
-public class DrawConnectorShape<T extends ConnectorShape> extends DrawSimpleShape<T> {\r
-    public DrawConnectorShape(T shape) {\r
+public class DrawConnectorShape extends DrawSimpleShape {\r
+    public DrawConnectorShape(ConnectorShape<?,?> shape) {\r
         super(shape);\r
     }\r
 }\r
index 8e75514e4d7ca43795c60d1bf9d641cc5f047829..19d3476470e1e60d554b6f591a973d6bb4a7e148 100644 (file)
@@ -28,17 +28,14 @@ import org.apache.poi.sl.usermodel.ConnectorShape;
 import org.apache.poi.sl.usermodel.FreeformShape;\r
 import org.apache.poi.sl.usermodel.GroupShape;\r
 import org.apache.poi.sl.usermodel.MasterSheet;\r
-import org.apache.poi.sl.usermodel.Notes;\r
 import org.apache.poi.sl.usermodel.PictureShape;\r
 import org.apache.poi.sl.usermodel.PlaceableShape;\r
 import org.apache.poi.sl.usermodel.Shape;\r
 import org.apache.poi.sl.usermodel.Sheet;\r
 import org.apache.poi.sl.usermodel.Slide;\r
-import org.apache.poi.sl.usermodel.SlideShow;\r
 import org.apache.poi.sl.usermodel.TableShape;\r
 import org.apache.poi.sl.usermodel.TextBox;\r
 import org.apache.poi.sl.usermodel.TextParagraph;\r
-import org.apache.poi.sl.usermodel.TextRun;\r
 import org.apache.poi.sl.usermodel.TextShape;\r
 \r
 public class DrawFactory {\r
@@ -77,90 +74,89 @@ public class DrawFactory {
         return factory;\r
     }\r
 \r
-    @SuppressWarnings("unchecked")\r
-    public Drawable getDrawable(Shape shape) {\r
+    public Drawable getDrawable(Shape<?,?> shape) {\r
         if (shape instanceof TextBox) {\r
-            return getDrawable((TextBox<? extends TextParagraph<? extends TextRun>>)shape);\r
+            return getDrawable((TextBox<?,?>)shape);\r
         } else if (shape instanceof FreeformShape) {\r
-            return getDrawable((FreeformShape<? extends TextParagraph<? extends TextRun>>)shape);\r
+            return getDrawable((FreeformShape<?,?>)shape);\r
         } else if (shape instanceof TextShape) {\r
-            return getDrawable((TextShape<? extends TextParagraph<? extends TextRun>>)shape);\r
+            return getDrawable((TextShape<?,?>)shape);\r
+        } else if (shape instanceof TableShape) {\r
+            return getDrawable((TableShape<?,?>)shape);\r
         } else if (shape instanceof GroupShape) {\r
-            return getDrawable((GroupShape<? extends Shape>)shape);\r
+            return getDrawable((GroupShape<?,?>)shape);\r
         } else if (shape instanceof PictureShape) {\r
-            return getDrawable((PictureShape)shape);\r
+            return getDrawable((PictureShape<?,?>)shape);\r
         } else if (shape instanceof Background) {\r
-            return getDrawable((Background)shape);\r
+            return getDrawable((Background<?,?>)shape);\r
         } else if (shape instanceof ConnectorShape) {\r
-            return getDrawable((ConnectorShape)shape);\r
-        } else if (shape instanceof TableShape) {\r
-            return getDrawable((TableShape)shape);\r
+            return getDrawable((ConnectorShape<?,?>)shape);\r
         } else if (shape instanceof Slide) {\r
-            return getDrawable((Slide<? extends Shape, ? extends SlideShow, ? extends Notes<?,?>>)shape);\r
+            return getDrawable((Slide<?,?>)shape);\r
         } else if (shape instanceof MasterSheet) {\r
-            return getDrawable((MasterSheet<? extends Shape, ? extends SlideShow>)shape);\r
+            return getDrawable((MasterSheet<?,?>)shape);\r
         } else if (shape instanceof Sheet) {\r
-            return getDrawable((Sheet<? extends Shape, ? extends SlideShow>)shape);\r
+            return getDrawable((Sheet<?,?>)shape);\r
         } else if (shape.getClass().isAnnotationPresent(DrawNotImplemented.class)) {\r
-            return new DrawNothing<Shape>(shape);\r
+            return new DrawNothing(shape);\r
         }\r
         \r
         throw new IllegalArgumentException("Unsupported shape type: "+shape.getClass());\r
     }\r
 \r
-    public <T extends Slide<? extends Shape, ? extends SlideShow, ? extends Notes<?,?>>> DrawSlide<T> getDrawable(T sheet) {\r
-        return new DrawSlide<T>(sheet);\r
+    public DrawSlide getDrawable(Slide<?,?> sheet) {\r
+        return new DrawSlide(sheet);\r
     }\r
 \r
-    public <T extends Sheet<? extends Shape, ? extends SlideShow>> DrawSheet<T> getDrawable(T sheet) {\r
-        return new DrawSheet<T>(sheet);\r
+    public DrawSheet getDrawable(Sheet<?,?> sheet) {\r
+        return new DrawSheet(sheet);\r
     }\r
 \r
-    public <T extends MasterSheet<? extends Shape, ? extends SlideShow>> DrawMasterSheet<T> getDrawable(T sheet) {\r
-        return new DrawMasterSheet<T>(sheet);\r
+    public DrawMasterSheet getDrawable(MasterSheet<?,?> sheet) {\r
+        return new DrawMasterSheet(sheet);\r
     }\r
 \r
-    public <T extends TextBox<? extends TextParagraph<?>>> DrawTextBox<T> getDrawable(T shape) {\r
-        return new DrawTextBox<T>(shape);\r
+    public DrawTextBox getDrawable(TextBox<?,?> shape) {\r
+        return new DrawTextBox(shape);\r
     }\r
 \r
-    public <T extends FreeformShape<? extends TextParagraph<? extends TextRun>>> DrawFreeformShape<T> getDrawable(T shape) {\r
-        return new DrawFreeformShape<T>(shape);\r
+    public DrawFreeformShape getDrawable(FreeformShape<?,?> shape) {\r
+        return new DrawFreeformShape(shape);\r
     }\r
 \r
-    public <T extends ConnectorShape> DrawConnectorShape<T> getDrawable(T shape) {\r
-        return new DrawConnectorShape<T>(shape);\r
+    public DrawConnectorShape getDrawable(ConnectorShape<?,?> shape) {\r
+        return new DrawConnectorShape(shape);\r
     }\r
     \r
-    public <T extends TableShape> DrawTableShape<T> getDrawable(T shape) {\r
-        return new DrawTableShape<T>(shape);\r
+    public DrawTableShape getDrawable(TableShape<?,?> shape) {\r
+        return new DrawTableShape(shape);\r
     }\r
     \r
-    public <T extends TextShape<? extends TextParagraph<? extends TextRun>>> DrawTextShape<T> getDrawable(T shape) {\r
-        return new DrawTextShape<T>(shape);\r
+    public DrawTextShape getDrawable(TextShape<?,?> shape) {\r
+        return new DrawTextShape(shape);\r
     }\r
 \r
-    public <T extends GroupShape<? extends Shape>> DrawGroupShape<T> getDrawable(T shape) {\r
-        return new DrawGroupShape<T>(shape);\r
+    public DrawGroupShape getDrawable(GroupShape<?,?> shape) {\r
+        return new DrawGroupShape(shape);\r
     }\r
     \r
-    public <T extends PictureShape> DrawPictureShape<T> getDrawable(T shape) {\r
-        return new DrawPictureShape<T>(shape);\r
+    public DrawPictureShape getDrawable(PictureShape<?,?> shape) {\r
+        return new DrawPictureShape(shape);\r
     }\r
     \r
-    public <T extends TextRun> DrawTextParagraph<T> getDrawable(TextParagraph<T> paragraph) {\r
-        return new DrawTextParagraph<T>(paragraph);\r
+    public DrawTextParagraph getDrawable(TextParagraph<?,?,?> paragraph) {\r
+        return new DrawTextParagraph(paragraph);\r
     }\r
 \r
-    public <T extends Background> DrawBackground<T> getDrawable(T shape) {\r
-        return new DrawBackground<T>(shape);\r
+    public DrawBackground getDrawable(Background<?,?> shape) {\r
+        return new DrawBackground(shape);\r
     }\r
     \r
     public DrawTextFragment getTextFragment(TextLayout layout, AttributedString str) {\r
         return new DrawTextFragment(layout, str);\r
     }\r
     \r
-    public DrawPaint getPaint(PlaceableShape shape) {\r
+    public DrawPaint getPaint(PlaceableShape<?,?> shape) {\r
         return new DrawPaint(shape);\r
     }\r
 }\r
index 1c3d6c07b45b5c0c0a218d3c19439a9834c659da..ee3bebb1c2c2f2b95d6b492e3030533cbf44354a 100644 (file)
@@ -27,21 +27,24 @@ import org.apache.poi.sl.draw.geom.Path;
 import org.apache.poi.sl.usermodel.FillStyle;\r
 import org.apache.poi.sl.usermodel.FreeformShape;\r
 import org.apache.poi.sl.usermodel.StrokeStyle;\r
-import org.apache.poi.sl.usermodel.TextParagraph;\r
-import org.apache.poi.sl.usermodel.TextRun;\r
 \r
-public class DrawFreeformShape<T extends FreeformShape<? extends TextParagraph<? extends TextRun>>> extends DrawAutoShape<T> {\r
-    public DrawFreeformShape(T shape) {\r
+public class DrawFreeformShape extends DrawAutoShape {\r
+    public DrawFreeformShape(FreeformShape<?,?> shape) {\r
         super(shape);\r
     }\r
     \r
     protected Collection<Outline> computeOutlines(Graphics2D graphics) {\r
         List<Outline> lst = new ArrayList<Outline>();\r
-        java.awt.Shape sh = shape.getPath();\r
-        FillStyle fs = shape.getFillStyle();\r
-        StrokeStyle ss = shape.getStrokeStyle();\r
+        java.awt.Shape sh = getShape().getPath();\r
+        FillStyle fs = getShape().getFillStyle();\r
+        StrokeStyle ss = getShape().getStrokeStyle();\r
         Path path = new Path(fs != null, ss != null);\r
         lst.add(new Outline(sh, path));\r
         return lst;\r
     }\r
+\r
+    @Override\r
+    protected FreeformShape<?,?> getShape() {\r
+        return (FreeformShape<?,?>)shape;\r
+    }\r
 }\r
index 60af5f710e636c6cc4c2a12b545d628e3f9c8878..999e34c546ce56cbd966343e4f0a1f4a3401937e 100644 (file)
@@ -24,18 +24,18 @@ import java.awt.geom.Rectangle2D;
 import org.apache.poi.sl.usermodel.*;\r
 \r
 \r
-public class DrawGroupShape<T extends GroupShape<? extends Shape>> extends DrawShape<T> implements Drawable {\r
+public class DrawGroupShape extends DrawShape {\r
 \r
-    public DrawGroupShape(T shape) {\r
+    public DrawGroupShape(GroupShape<?,?> shape) {\r
         super(shape);\r
     }\r
     \r
     public void draw(Graphics2D graphics) {\r
 \r
         // the coordinate system of this group of shape\r
-        Rectangle2D interior = shape.getInteriorAnchor();\r
+        Rectangle2D interior = getShape().getInteriorAnchor();\r
         // anchor of this group relative to the parent shape\r
-        Rectangle2D exterior = shape.getAnchor();\r
+        Rectangle2D exterior = getShape().getAnchor();\r
 \r
         AffineTransform tx = (AffineTransform)graphics.getRenderingHint(Drawable.GROUP_TRANSFORM);\r
         AffineTransform tx0 = new AffineTransform(tx);\r
@@ -50,7 +50,7 @@ public class DrawGroupShape<T extends GroupShape<? extends Shape>> extends DrawS
         DrawFactory drawFact = DrawFactory.getInstance(graphics);\r
         AffineTransform at2 = graphics.getTransform();\r
         \r
-        for (Shape child : shape) {\r
+        for (Shape<?,?> child : getShape()) {\r
             // remember the initial transform and restore it after we are done with the drawing\r
             AffineTransform at = graphics.getTransform();\r
             graphics.setRenderingHint(Drawable.GSAVE, true);\r
@@ -67,4 +67,9 @@ public class DrawGroupShape<T extends GroupShape<? extends Shape>> extends DrawS
         graphics.setTransform(at2);\r
         graphics.setRenderingHint(Drawable.GROUP_TRANSFORM, tx0);\r
     }\r
+\r
+    @Override\r
+    protected GroupShape<?,?> getShape() {\r
+        return (GroupShape<?,?>)shape;\r
+    }\r
 }\r
index 6b5d0781dfec2cc9a7415ad1b7324b7db07b116e..76ae92de709351142bc9307a0cc8e9fc35e532bc 100644 (file)
@@ -20,9 +20,9 @@ package org.apache.poi.sl.draw;
 import org.apache.poi.sl.usermodel.*;\r
 \r
 \r
-public class DrawMasterSheet<T extends MasterSheet<? extends Shape, ? extends SlideShow>> extends DrawSheet<T> {\r
+public class DrawMasterSheet extends DrawSheet {\r
 \r
-    public DrawMasterSheet(T sheet) {\r
+    public DrawMasterSheet(MasterSheet<?,?> sheet) {\r
         super(sheet);\r
     }\r
 \r
@@ -32,7 +32,8 @@ public class DrawMasterSheet<T extends MasterSheet<? extends Shape, ? extends Sl
      * Subclasses can override it and skip certain shapes from drawings,\r
      * for instance, slide masters and layouts don't display placeholders\r
      */\r
-    protected boolean canDraw(Shape shape){\r
-        return !(shape instanceof SimpleShape) || !((SimpleShape)shape).isPlaceholder();\r
+    @Override\r
+    protected boolean canDraw(Shape<?,?> shape){\r
+        return !(shape instanceof SimpleShape) || !((SimpleShape<?,?>)shape).isPlaceholder();\r
     }\r
 }\r
index eb32888809ef1bfb4c9ca635957ddecfd1329009..d1710b23526af0386cae3797d33d9df5dfe2e9aa 100644 (file)
@@ -22,11 +22,11 @@ import java.awt.Graphics2D;
 import org.apache.poi.sl.usermodel.Shape;\r
 \r
 \r
-public class DrawNothing<T extends Shape> implements Drawable {\r
+public class DrawNothing implements Drawable {\r
 \r
-    protected final T shape;\r
+    protected final Shape<?,?> shape;\r
     \r
-    public DrawNothing(T shape) {\r
+    public DrawNothing(Shape<?,?> shape) {\r
         this.shape = shape;\r
     }\r
     \r
index 4309d4ec5dbdb2ca4713031bfbad2d31a6b59005..7aed90811f71d85846459e654efbda7803c5f2db 100644 (file)
@@ -50,9 +50,9 @@ public class DrawPaint {
     \r
     private final static POILogger LOG = POILogFactory.getLogger(DrawPaint.class);\r
 \r
-    protected PlaceableShape shape;\r
+    protected PlaceableShape<?,?> shape;\r
     \r
-    public DrawPaint(PlaceableShape shape) {\r
+    public DrawPaint(PlaceableShape<?,?> shape) {\r
         this.shape = shape;\r
     }\r
 \r
index 3d00b4ec6bfdf69beb52996004add0d278a0e9ee..43586f111f857636dc2a96749d7cd4bc71cc324b 100644 (file)
@@ -26,22 +26,22 @@ import org.apache.poi.sl.usermodel.PictureData;
 import org.apache.poi.sl.usermodel.PictureShape;\r
 \r
 \r
-public class DrawPictureShape<T extends PictureShape> extends DrawSimpleShape<T> {\r
-    public DrawPictureShape(T shape) {\r
+public class DrawPictureShape extends DrawSimpleShape {\r
+    public DrawPictureShape(PictureShape<?,?> shape) {\r
         super(shape);\r
     }\r
     \r
     @Override\r
     public void drawContent(Graphics2D graphics) {\r
-        PictureData data = shape.getPictureData();\r
+        PictureData data = getShape().getPictureData();\r
         if(data == null) return;\r
 \r
         ImageRenderer renderer = (ImageRenderer)graphics.getRenderingHint(Drawable.IMAGE_RENDERER);\r
         if (renderer == null) renderer = new ImageRenderer();\r
         \r
-        Rectangle2D anchor = getAnchor(graphics, shape);\r
+        Rectangle2D anchor = getAnchor(graphics, getShape());\r
 \r
-        Insets insets = shape.getClipping();\r
+        Insets insets = getShape().getClipping();\r
 \r
         try {\r
             renderer.loadImage(data.getData(), data.getContentType());\r
@@ -51,4 +51,9 @@ public class DrawPictureShape<T extends PictureShape> extends DrawSimpleShape<T>
             throw new RuntimeException(e);\r
         }\r
     }    \r
+\r
+    @Override\r
+    protected PictureShape<?,?> getShape() {\r
+        return (PictureShape<?,?>)shape;\r
+    }\r
 }\r
index 13ef4292a3b7cf0bca1d3da153d92e0385c6589a..deca5d7a325939ef0c562d596db481f9b075cad5 100644 (file)
@@ -25,14 +25,14 @@ import org.apache.poi.sl.usermodel.PlaceableShape;
 import org.apache.poi.sl.usermodel.Shape;\r
 \r
 \r
-public class DrawShape<T extends Shape> implements Drawable {\r
+public class DrawShape implements Drawable {\r
 \r
-    protected final T shape;\r
-    \r
-    public DrawShape(T shape) {\r
+    protected final Shape<?,?> shape;\r
+\r
+    public DrawShape(Shape<?,?> shape) {\r
         this.shape = shape;\r
     }\r
-    \r
+\r
     /**\r
      * Apply 2-D transforms before drawing this shape. This includes rotation and flipping.\r
      *\r
@@ -40,8 +40,8 @@ public class DrawShape<T extends Shape> implements Drawable {
      */\r
     public void applyTransform(Graphics2D graphics) {\r
         if (!(shape instanceof PlaceableShape)) return;\r
-        \r
-        PlaceableShape ps = (PlaceableShape)shape;\r
+\r
+        PlaceableShape<?,?> ps = (PlaceableShape<?,?>)shape;\r
         AffineTransform tx = (AffineTransform)graphics.getRenderingHint(Drawable.GROUP_TRANSFORM);\r
         if (tx == null) tx = new AffineTransform();\r
         final Rectangle2D anchor = tx.createTransformedShape(ps.getAnchor()).getBounds2D();\r
@@ -59,12 +59,12 @@ public class DrawShape<T extends Shape> implements Drawable {
 \r
             int quadrant = (((int)rotation+45)/90)%4;\r
             double scaleX = 1.0, scaleY = 1.0;\r
-            \r
+\r
             // scale to bounding box (bug #53176)\r
             if (quadrant == 1 || quadrant == 3) {\r
-                // In quadrant 1 and 3, which is basically a shape in a more or less portrait orientation \r
-                // (45-135 degrees and 225-315 degrees), we need to first rotate the shape by a multiple \r
-                // of 90 degrees and then resize the bounding box to its original bbox. After that we can \r
+                // In quadrant 1 and 3, which is basically a shape in a more or less portrait orientation\r
+                // (45-135 degrees and 225-315 degrees), we need to first rotate the shape by a multiple\r
+                // of 90 degrees and then resize the bounding box to its original bbox. After that we can\r
                 // rotate the shape to the exact rotation amount.\r
                 // It's strange that you'll need to rotate the shape back and forth again, but you can\r
                 // think of it, as if you paint the shape on a canvas. First you rotate the canvas, which might\r
@@ -82,19 +82,19 @@ public class DrawShape<T extends Shape> implements Drawable {
                     txs.translate(-centerX, -centerY);\r
                     txs.concatenate(tx);\r
                 }\r
-                \r
+\r
                 txs.translate(centerX, centerY);\r
                 txs.rotate(Math.PI/2.);\r
                 txs.translate(-centerX, -centerY);\r
-                \r
+\r
                 Rectangle2D anchor2 = txs.createTransformedShape(ps.getAnchor()).getBounds2D();\r
-                \r
+\r
                 scaleX = anchor.getWidth() == 0. ? 1.0 : anchor.getWidth() / anchor2.getWidth();\r
                 scaleY = anchor.getHeight() == 0. ? 1.0 : anchor.getHeight() / anchor2.getHeight();\r
             } else {\r
                 quadrant = 0;\r
             }\r
-            \r
+\r
             // transformation is applied reversed ...\r
             graphics.translate(centerX, centerY);\r
             graphics.rotate(Math.toRadians(rotation-quadrant*90.));\r
@@ -122,13 +122,13 @@ public class DrawShape<T extends Shape> implements Drawable {
     public void draw(Graphics2D graphics) {\r
     }\r
 \r
-    public void drawContent(Graphics2D context) {\r
+    public void drawContent(Graphics2D graphics) {\r
     }\r
 \r
-    public static Rectangle2D getAnchor(Graphics2D graphics, PlaceableShape shape) {\r
+    public static Rectangle2D getAnchor(Graphics2D graphics, PlaceableShape<?,?> shape) {\r
         return getAnchor(graphics, shape.getAnchor());\r
     }\r
-    \r
+\r
     public static Rectangle2D getAnchor(Graphics2D graphics, Rectangle2D anchor) {\r
         if(graphics == null)  {\r
             return anchor;\r
@@ -139,5 +139,9 @@ public class DrawShape<T extends Shape> implements Drawable {
             anchor = tx.createTransformedShape(anchor).getBounds2D();\r
         }\r
         return anchor;\r
-    }    \r
+    }\r
+    \r
+    protected Shape<?,?> getShape() {\r
+        return shape;\r
+    }\r
 }\r
index e4c7e185e8a4e09818338841a79ddcccc3254700..dbe82ea6c8b321851830fbf2d5d0223b3e8c3592 100644 (file)
@@ -26,11 +26,11 @@ import java.awt.geom.AffineTransform;
 import org.apache.poi.sl.usermodel.*;\r
 \r
 \r
-public class DrawSheet<T extends Sheet<? extends Shape, ? extends SlideShow>> implements Drawable {\r
+public class DrawSheet implements Drawable {\r
 \r
-    protected final T sheet;\r
+    protected final Sheet<?,?> sheet;\r
     \r
-    public DrawSheet(T sheet) {\r
+    public DrawSheet(Sheet<?,?> sheet) {\r
         this.sheet = sheet;\r
     }\r
     \r
@@ -41,7 +41,7 @@ public class DrawSheet<T extends Sheet<? extends Shape, ? extends SlideShow>> im
         graphics.fillRect(0, 0, (int)dim.getWidth(), (int)dim.getHeight());\r
         \r
         DrawFactory drawFact = DrawFactory.getInstance(graphics);\r
-        MasterSheet<? extends Shape, ? extends SlideShow> master = sheet.getMasterSheet();\r
+        MasterSheet<?,?> master = sheet.getMasterSheet();\r
         \r
         if(sheet.getFollowMasterGraphics() && master != null) {\r
             Drawable drawer = drawFact.getDrawable(master);\r
@@ -50,7 +50,7 @@ public class DrawSheet<T extends Sheet<? extends Shape, ? extends SlideShow>> im
         \r
         graphics.setRenderingHint(Drawable.GROUP_TRANSFORM, new AffineTransform());\r
 \r
-        for (Shape shape : sheet.getShapes()) {\r
+        for (Shape<?,?> shape : sheet.getShapes()) {\r
             if(!canDraw(shape)) continue;\r
             \r
             // remember the initial transform and restore it after we are done with drawing\r
@@ -85,7 +85,7 @@ public class DrawSheet<T extends Sheet<? extends Shape, ? extends SlideShow>> im
      * Subclasses can override it and skip certain shapes from drawings,\r
      * for instance, slide masters and layouts don't display placeholders\r
      */\r
-    protected boolean canDraw(Shape shape){\r
+    protected boolean canDraw(Shape<?,?> shape){\r
         return true;\r
     }\r
 }\r
index 8ffc57e606f98b181420a5c93b2a50a3cf678d26..37cd6d8b8839875d430ce1e8dec20968ea077a34 100644 (file)
 \r
 package org.apache.poi.sl.draw;\r
 \r
-import java.awt.*;\r
-import java.awt.geom.*;\r
-import java.io.*;\r
+import java.awt.BasicStroke;\r
+import java.awt.Color;\r
+import java.awt.Graphics2D;\r
+import java.awt.Paint;\r
+import java.awt.geom.AffineTransform;\r
+import java.awt.geom.Ellipse2D;\r
+import java.awt.geom.GeneralPath;\r
+import java.awt.geom.Rectangle2D;\r
+import java.io.InputStream;\r
+import java.io.InputStreamReader;\r
+import java.io.Reader;\r
 import java.nio.charset.Charset;\r
-import java.util.*;\r
+import java.util.ArrayList;\r
+import java.util.Collection;\r
+import java.util.HashMap;\r
 import java.util.List;\r
+import java.util.Map;\r
 \r
-import javax.xml.bind.*;\r
-import javax.xml.stream.*;\r
+import javax.xml.bind.JAXBContext;\r
+import javax.xml.bind.JAXBElement;\r
+import javax.xml.bind.Unmarshaller;\r
 import javax.xml.stream.EventFilter;\r
+import javax.xml.stream.XMLEventReader;\r
+import javax.xml.stream.XMLInputFactory;\r
 import javax.xml.stream.events.StartElement;\r
 import javax.xml.stream.events.XMLEvent;\r
 \r
 import org.apache.poi.sl.draw.binding.CTCustomGeometry2D;\r
-import org.apache.poi.sl.draw.geom.*;\r
-import org.apache.poi.sl.usermodel.*;\r
+import org.apache.poi.sl.draw.geom.Context;\r
+import org.apache.poi.sl.draw.geom.CustomGeometry;\r
+import org.apache.poi.sl.draw.geom.Outline;\r
+import org.apache.poi.sl.draw.geom.Path;\r
+import org.apache.poi.sl.usermodel.LineDecoration;\r
 import org.apache.poi.sl.usermodel.LineDecoration.DecorationSize;\r
 import org.apache.poi.sl.usermodel.PaintStyle.SolidPaint;\r
-import org.apache.poi.sl.usermodel.StrokeStyle.*;\r
+import org.apache.poi.sl.usermodel.Shadow;\r
+import org.apache.poi.sl.usermodel.SimpleShape;\r
+import org.apache.poi.sl.usermodel.StrokeStyle;\r
+import org.apache.poi.sl.usermodel.StrokeStyle.LineCap;\r
+import org.apache.poi.sl.usermodel.StrokeStyle.LineDash;\r
 import org.apache.poi.util.Units;\r
 \r
 \r
-public class DrawSimpleShape<T extends SimpleShape> extends DrawShape<T> {\r
+public class DrawSimpleShape extends DrawShape {\r
 \r
-    public DrawSimpleShape(T shape) {\r
+    public DrawSimpleShape(SimpleShape<?,?> shape) {\r
         super(shape);\r
     }\r
 \r
     @Override\r
     public void draw(Graphics2D graphics) {\r
-        DrawPaint drawPaint = DrawFactory.getInstance(graphics).getPaint(shape);\r
-        Paint fill = drawPaint.getPaint(graphics, shape.getFillStyle().getPaint());\r
-        Paint line = drawPaint.getPaint(graphics, shape.getStrokeStyle().getPaint());\r
+        DrawPaint drawPaint = DrawFactory.getInstance(graphics).getPaint(getShape());\r
+        Paint fill = drawPaint.getPaint(graphics, getShape().getFillStyle().getPaint());\r
+        Paint line = drawPaint.getPaint(graphics, getShape().getStrokeStyle().getPaint());\r
         BasicStroke stroke = getStroke(); // the stroke applies both to the shadow and the shape\r
         graphics.setStroke(stroke);\r
 \r
@@ -94,7 +115,7 @@ public class DrawSimpleShape<T extends SimpleShape> extends DrawShape<T> {
         graphics.setPaint(line);\r
         \r
         List<Outline> lst = new ArrayList<Outline>();\r
-        LineDecoration deco = shape.getLineDecoration();\r
+        LineDecoration deco = getShape().getLineDecoration();\r
         Outline head = getHeadDecoration(graphics, deco, stroke);\r
         if (head != null) lst.add(head);\r
         Outline tail = getTailDecoration(graphics, deco, stroke);\r
@@ -117,7 +138,7 @@ public class DrawSimpleShape<T extends SimpleShape> extends DrawShape<T> {
     \r
         double lineWidth = Math.max(2.5, stroke.getLineWidth());\r
     \r
-        Rectangle2D anchor = getAnchor(graphics, shape);\r
+        Rectangle2D anchor = getAnchor(graphics, getShape());\r
         double x2 = anchor.getX() + anchor.getWidth(),\r
                y2 = anchor.getY() + anchor.getHeight();\r
     \r
@@ -175,7 +196,7 @@ public class DrawSimpleShape<T extends SimpleShape> extends DrawShape<T> {
     \r
         double lineWidth = Math.max(2.5, stroke.getLineWidth());\r
     \r
-        Rectangle2D anchor = getAnchor(graphics, shape);\r
+        Rectangle2D anchor = getAnchor(graphics, getShape());\r
         double x1 = anchor.getX(),\r
                 y1 = anchor.getY();\r
     \r
@@ -228,7 +249,7 @@ public class DrawSimpleShape<T extends SimpleShape> extends DrawShape<T> {
     }\r
     \r
     public BasicStroke getStroke() {\r
-        StrokeStyle strokeStyle = shape.getStrokeStyle();\r
+        StrokeStyle strokeStyle = getShape().getStrokeStyle();\r
         \r
         float lineWidth = (float) strokeStyle.getLineWidth();\r
         if (lineWidth == 0.0f) lineWidth = 0.25f; // Both PowerPoint and OOo draw zero-length lines as 0.25pt\r
@@ -275,14 +296,14 @@ public class DrawSimpleShape<T extends SimpleShape> extends DrawShape<T> {
           , Paint fill\r
           , Paint line\r
     ) {\r
-          Shadow shadow = shape.getShadow();\r
+          Shadow shadow = getShape().getShadow();\r
           if (shadow == null || (fill == null && line == null)) return;\r
 \r
           SolidPaint shadowPaint = shadow.getFillStyle();\r
           Color shadowColor = DrawPaint.applyColorTransform(shadowPaint.getSolidColor());\r
           \r
-          double shapeRotation = shape.getRotation();\r
-          if(shape.getFlipVertical()) {\r
+          double shapeRotation = getShape().getRotation();\r
+          if(getShape().getFlipVertical()) {\r
               shapeRotation += 180;\r
           }\r
           double angle = shadow.getAngle() - shapeRotation;\r
@@ -366,12 +387,12 @@ public class DrawSimpleShape<T extends SimpleShape> extends DrawShape<T> {
     protected Collection<Outline> computeOutlines(Graphics2D graphics) {\r
 \r
         List<Outline> lst = new ArrayList<Outline>();\r
-        CustomGeometry geom = shape.getGeometry();\r
+        CustomGeometry geom = getShape().getGeometry();\r
         if(geom == null) {\r
             return lst;\r
         }\r
 \r
-        Rectangle2D anchor = getAnchor(graphics, shape);\r
+        Rectangle2D anchor = getAnchor(graphics, getShape());\r
         for (Path p : geom) {\r
 \r
             double w = p.getW() == -1 ? anchor.getWidth() * Units.EMU_PER_POINT : p.getW();\r
@@ -381,7 +402,7 @@ public class DrawSimpleShape<T extends SimpleShape> extends DrawShape<T> {
             // so we build the path starting from (0,0).\r
             final Rectangle2D pathAnchor = new Rectangle2D.Double(0,0,w,h);\r
 \r
-            Context ctx = new Context(geom, pathAnchor, shape);\r
+            Context ctx = new Context(geom, pathAnchor, getShape());\r
 \r
             java.awt.Shape gp = p.getPath(ctx);\r
 \r
@@ -411,4 +432,8 @@ public class DrawSimpleShape<T extends SimpleShape> extends DrawShape<T> {
         return lst;\r
     }\r
 \r
+    @Override\r
+    protected SimpleShape<?,?> getShape() {\r
+        return (SimpleShape<?,?>)shape;\r
+    }\r
 }\r
index cfa316738e93230667f7d45c1190ab0a66ae9082..ae4baa27fbf062c144b05b12c4a6b80f3fd99426 100644 (file)
@@ -22,14 +22,14 @@ import java.awt.Graphics2D;
 import org.apache.poi.sl.usermodel.*;\r
 \r
 \r
-public class DrawSlide<T extends Slide<? extends Shape, ? extends SlideShow, ? extends Notes<?,?>>> extends DrawSheet<T> {\r
+public class DrawSlide extends DrawSheet {\r
 \r
-    public DrawSlide(T slide) {\r
+    public DrawSlide(Slide<?,?> slide) {\r
         super(slide);\r
     }\r
     \r
     public void draw(Graphics2D graphics) {\r
-        Background bg = sheet.getBackground();\r
+        Background<?,?> bg = sheet.getBackground();\r
         if(bg != null) {\r
             DrawFactory drawFact = DrawFactory.getInstance(graphics);\r
             Drawable db = drawFact.getDrawable(bg);\r
index ceb6450d0b6430caaf994befc82c0f6dc46c6720..b252ddfda934c03db7f5c10eae39b4b38f086df2 100644 (file)
 \r
 package org.apache.poi.sl.draw;\r
 \r
-import org.apache.poi.sl.usermodel.*;\r
+import java.awt.Graphics2D;\r
 \r
-public class DrawTableShape<T extends TableShape> extends DrawShape<T> {\r
+import org.apache.poi.sl.usermodel.GroupShape;\r
+import org.apache.poi.sl.usermodel.TableShape;\r
+\r
+public class DrawTableShape extends DrawShape {\r
     // to be implemented ...\r
-    public DrawTableShape(T shape) {\r
+    public DrawTableShape(TableShape<?,?> shape) {\r
         super(shape);\r
     }\r
+    \r
+    protected Drawable getDrawable(Graphics2D graphics) {\r
+        if (shape instanceof GroupShape) {\r
+            DrawFactory df = DrawFactory.getInstance(graphics);\r
+            return df.getDrawable((GroupShape<?,?>)shape);\r
+        }\r
+        return null;\r
+    }\r
+\r
+    public void applyTransform(Graphics2D graphics) {\r
+        Drawable d = getDrawable(graphics);\r
+        if (d != null) {\r
+            d.applyTransform(graphics);\r
+        }\r
+    }\r
+\r
+    public void draw(Graphics2D graphics) {\r
+        Drawable d = getDrawable(graphics);\r
+        if (d != null) {\r
+            d.draw(graphics);\r
+        }\r
+    }\r
+\r
+    public void drawContent(Graphics2D graphics) {\r
+        Drawable d = getDrawable(graphics);\r
+        if (d != null) {\r
+            d.drawContent(graphics);\r
+        }\r
+    }\r
+\r
+    \r
 }\r
index 89d69223ff10537acdd274aa85966c9d63f9f78a..d44d10807e3f35e5717cf5b2909afcfa1a35a9cc 100644 (file)
@@ -19,8 +19,8 @@ package org.apache.poi.sl.draw;
 \r
 import org.apache.poi.sl.usermodel.*;\r
 \r
-public class DrawTextBox<T extends TextBox<? extends TextParagraph<? extends TextRun>>> extends DrawAutoShape<T> {\r
-    public DrawTextBox(T shape) {\r
+public class DrawTextBox extends DrawAutoShape {\r
+    public DrawTextBox(TextBox<?,?> shape) {\r
         super(shape);\r
     }\r
 }\r
index 1bdd1e829f67393a3f81fe4feb7c88723d710fa9..8cfa481626926f92af29f5b6da75bd5e5e8a8e11 100644 (file)
@@ -35,7 +35,6 @@ import org.apache.poi.sl.usermodel.AutoNumberingScheme;
 import org.apache.poi.sl.usermodel.Insets2D;\r
 import org.apache.poi.sl.usermodel.PaintStyle;\r
 import org.apache.poi.sl.usermodel.PlaceableShape;\r
-import org.apache.poi.sl.usermodel.Shape;\r
 import org.apache.poi.sl.usermodel.ShapeContainer;\r
 import org.apache.poi.sl.usermodel.TextParagraph;\r
 import org.apache.poi.sl.usermodel.TextParagraph.BulletStyle;\r
@@ -45,8 +44,8 @@ import org.apache.poi.sl.usermodel.TextRun.TextCap;
 import org.apache.poi.sl.usermodel.TextShape;\r
 import org.apache.poi.util.Units;\r
 \r
-public class DrawTextParagraph<T extends TextRun> implements Drawable {\r
-    protected TextParagraph<T> paragraph;\r
+public class DrawTextParagraph implements Drawable {\r
+    protected TextParagraph<?,?,?> paragraph;\r
     double x, y;\r
     protected List<DrawTextFragment> lines = new ArrayList<DrawTextFragment>();\r
     protected String rawText;\r
@@ -58,7 +57,7 @@ public class DrawTextParagraph<T extends TextRun> implements Drawable {
      */\r
     protected double maxLineHeight;\r
 \r
-    public DrawTextParagraph(TextParagraph<T> paragraph) {\r
+    public DrawTextParagraph(TextParagraph<?,?,?> paragraph) {\r
         this.paragraph = paragraph;\r
     }\r
 \r
@@ -266,7 +265,7 @@ public class DrawTextParagraph<T extends TextRun> implements Drawable {
         if (buFont == null) buFont = paragraph.getDefaultFontFamily();\r
         assert(buFont != null);\r
 \r
-        PlaceableShape ps = getParagraphShape();\r
+        PlaceableShape<?,?> ps = getParagraphShape();\r
         PaintStyle fgPaintStyle = bulletStyle.getBulletFontColor();\r
         Paint fgPaint;\r
         if (fgPaintStyle == null) {\r
@@ -377,7 +376,7 @@ public class DrawTextParagraph<T extends TextRun> implements Drawable {
         }\r
 \r
         double width;\r
-        TextShape<? extends TextParagraph<T>> ts = paragraph.getParentShape();\r
+        TextShape<?,?> ts = paragraph.getParentShape();\r
         if (!ts.getWordWrap()) {\r
             // if wordWrap == false then we return the advance to the right border of the sheet\r
             width = ts.getSheet().getSlideShow().getPageSize().getWidth() - anchor.getX();\r
@@ -413,9 +412,10 @@ public class DrawTextParagraph<T extends TextRun> implements Drawable {
     /**\r
      * Helper method for paint style relative to bounds, e.g. gradient paint\r
      */\r
-    private PlaceableShape getParagraphShape() {\r
-        PlaceableShape ps = new PlaceableShape(){\r
-            public ShapeContainer<? extends Shape> getParent() { return null; }\r
+    @SuppressWarnings("rawtypes")\r
+    private PlaceableShape<?,?> getParagraphShape() {\r
+        PlaceableShape<?,?> ps = new PlaceableShape(){\r
+            public ShapeContainer<?,?> getParent() { return null; }\r
             public Rectangle2D getAnchor() { return paragraph.getParentShape().getAnchor(); }\r
             public void setAnchor(Rectangle2D anchor) {}\r
             public double getRotation() { return 0; }\r
@@ -432,7 +432,7 @@ public class DrawTextParagraph<T extends TextRun> implements Drawable {
         List<AttributedStringData> attList = new ArrayList<AttributedStringData>();\r
         if (text == null) text = new StringBuilder();\r
 \r
-        PlaceableShape ps = getParagraphShape();\r
+        PlaceableShape<?,?> ps = getParagraphShape();\r
         \r
         DrawFontManager fontHandler = (DrawFontManager)graphics.getRenderingHint(Drawable.FONT_HANDLER);\r
 \r
index 36896ba688e8711f3da0dbb7595e9f8b0abe4457..b1ec2d94360671db637eaefcba6255e95ae8d5a3 100644 (file)
@@ -27,9 +27,9 @@ import org.apache.poi.sl.usermodel.*;
 import org.apache.poi.sl.usermodel.TextParagraph.BulletStyle;\r
 import org.apache.poi.util.JvmBugs;\r
 \r
-public class DrawTextShape<T extends TextShape<? extends TextParagraph<? extends TextRun>>> extends DrawSimpleShape<T> {\r
+public class DrawTextShape extends DrawSimpleShape {\r
 \r
-    public DrawTextShape(T shape) {\r
+    public DrawTextShape(TextShape<?,?> shape) {\r
         super(shape);\r
     }\r
 \r
@@ -37,8 +37,8 @@ public class DrawTextShape<T extends TextShape<? extends TextParagraph<? extends
     public void drawContent(Graphics2D graphics) {\r
         fixFonts(graphics);\r
         \r
-        Rectangle2D anchor = DrawShape.getAnchor(graphics, shape);\r
-        Insets2D insets = shape.getInsets();\r
+        Rectangle2D anchor = DrawShape.getAnchor(graphics, getShape());\r
+        Insets2D insets = getShape().getInsets();\r
         double x = anchor.getX() + insets.left;\r
         double y = anchor.getY();\r
 \r
@@ -50,7 +50,7 @@ public class DrawTextShape<T extends TextShape<? extends TextParagraph<? extends
         // (see DrawShape#applyTransform ), but we need to restore it to avoid painting "upside down".\r
         // See Bugzilla 54210.\r
 \r
-        if(shape.getFlipVertical()){\r
+        if(getShape().getFlipVertical()){\r
             graphics.translate(anchor.getX(), anchor.getY() + anchor.getHeight());\r
             graphics.scale(1, -1);\r
             graphics.translate(-anchor.getX(), -anchor.getY());\r
@@ -65,7 +65,7 @@ public class DrawTextShape<T extends TextShape<? extends TextParagraph<? extends
 \r
         // Horizontal flipping applies only to shape outline and not to the text in the shape.\r
         // Applying flip second time restores the original not-flipped transform\r
-        if(shape.getFlipHorizontal()){\r
+        if(getShape().getFlipHorizontal()){\r
             graphics.translate(anchor.getX() + anchor.getWidth(), anchor.getY());\r
             graphics.scale(-1, 1);\r
             graphics.translate(-anchor.getX() , -anchor.getY());\r
@@ -73,9 +73,9 @@ public class DrawTextShape<T extends TextShape<? extends TextParagraph<? extends
 \r
 \r
         // first dry-run to calculate the total height of the text\r
-        double textHeight = shape.getTextHeight();\r
+        double textHeight = getShape().getTextHeight();\r
 \r
-        switch (shape.getVerticalAlignment()){\r
+        switch (getShape().getVerticalAlignment()){\r
             case TOP:\r
                 y += insets.top;\r
                 break;\r
@@ -104,12 +104,12 @@ public class DrawTextShape<T extends TextShape<? extends TextParagraph<? extends
         DrawFactory fact = DrawFactory.getInstance(graphics);\r
 \r
         double y0 = y;\r
-        Iterator<? extends TextParagraph<? extends TextRun>> paragraphs = shape.iterator();\r
+        Iterator<? extends TextParagraph<?,?,? extends TextRun>> paragraphs = getShape().iterator();\r
         \r
         boolean isFirstLine = true;\r
         for (int autoNbrIdx=0; paragraphs.hasNext(); autoNbrIdx++){\r
-            TextParagraph<? extends TextRun> p = paragraphs.next();\r
-            DrawTextParagraph<? extends TextRun> dp = fact.getDrawable(p);\r
+            TextParagraph<?,?,? extends TextRun> p = paragraphs.next();\r
+            DrawTextParagraph dp = fact.getDrawable(p);\r
             BulletStyle bs = p.getBulletStyle();\r
             if (bs == null || bs.getAutoNumberingScheme() == null) {\r
                 autoNbrIdx = -1;\r
@@ -180,4 +180,9 @@ public class DrawTextShape<T extends TextShape<? extends TextParagraph<? extends
         if (!fontMap.containsKey("Calibri")) fontMap.put("Calibri", "Lucida Sans");\r
         if (!fontMap.containsKey("Cambria")) fontMap.put("Cambria", "Lucida Bright");\r
     }\r
+\r
+    @Override\r
+    protected TextShape<?,?> getShape() {\r
+        return (TextShape<?,?>)shape;\r
+    }\r
 }\r
index 1bf073dfbb70df97c695f1db0da7bfeb9fb530ef..bea0502135169fd129d00fdbec74556f3145236e 100644 (file)
@@ -17,5 +17,8 @@
 
 package org.apache.poi.sl.usermodel;
 
-public interface AutoShape<T extends TextParagraph<? extends TextRun>> extends TextShape<T> {
+public interface AutoShape<
+    S extends Shape<S,P>,
+    P extends TextParagraph<S,P,? extends TextRun>
+> extends TextShape<S,P> {
 }
index 8d868b86006555ef256b053cea3a9a063a922322..879879a209d47bca826317581f657d9ce8d7afd0 100644 (file)
@@ -17,6 +17,9 @@
 
 package org.apache.poi.sl.usermodel;
 
-public interface Background extends Shape {
+public interface Background<
+    S extends Shape<S,P>,
+    P extends TextParagraph<S,P,? extends TextRun>
+> extends Shape<S,P> {
     FillStyle getFillStyle();
 }
index 7e2bbf065cbf91beff8dd52a2457f0a69e394c5f..8d356b655a7875b438f052b54a71901adbe0aa44 100644 (file)
@@ -17,6 +17,9 @@
 \r
 package org.apache.poi.sl.usermodel;\r
 \r
-public interface ConnectorShape extends SimpleShape {\r
+public interface ConnectorShape<\r
+    S extends Shape<S,P>,\r
+    P extends TextParagraph<S,P,? extends TextRun>\r
+> extends SimpleShape<S,P> {\r
 \r
 }\r
index ec288854a284a262c7d1ecc0a440abef3c3dc86c..19b5d313fc3ed575a9f03074f16f9148c2799a7a 100644 (file)
@@ -19,7 +19,10 @@ package org.apache.poi.sl.usermodel;
 \r
 import java.awt.geom.GeneralPath;\r
 \r
-public interface FreeformShape<T extends TextParagraph<? extends TextRun>> extends AutoShape<T> {\r
+public interface FreeformShape<\r
+    S extends Shape<S,P>,\r
+    P extends TextParagraph<S,P,? extends TextRun>\r
+> extends AutoShape<S,P> {\r
     /**\r
      * Gets the shape path.\r
      * <p>\r
index 8133ac048e4ac288676027e6aeeb5c5798b0e476..31f5be53450e38583635231b3d7073ef31bad1d4 100644 (file)
@@ -19,7 +19,10 @@ package org.apache.poi.sl.usermodel;
 
 import java.awt.geom.Rectangle2D;
 
-public interface GroupShape<T extends Shape> extends Shape, ShapeContainer<T>, PlaceableShape {
+public interface GroupShape<
+    S extends Shape<S,P>,
+    P extends TextParagraph<S,P,? extends TextRun>
+> extends Shape<S,P>, ShapeContainer<S,P>, PlaceableShape<S,P> {
 
     /**
      * Gets the coordinate space of this group.  All children are constrained
index aa42eeab63b4fcab8d6768ecb6e4853a18cce0c4..d2c2134e5284fa17a84d975267ae6b5fa64174ea 100644 (file)
@@ -25,6 +25,9 @@ import org.apache.poi.util.Internal;
  */
 
 @Internal
-public interface Line<T extends TextParagraph<? extends TextRun>> extends AutoShape<T> {
+public interface Line<
+    S extends Shape<S,P>,
+    P extends TextParagraph<S,P,? extends TextRun>
+> extends AutoShape<S,P> {
 
 }
index 727217d3fac04fdc8784e60769e105944f1d389d..ac23bc3bbaa71fe5fe3afc84df26eb67bf96e5f7 100644 (file)
@@ -17,6 +17,9 @@
 
 package org.apache.poi.sl.usermodel;
 
-public interface MasterSheet<T extends Shape, SS extends SlideShow> extends Sheet<T,SS> {
+public interface MasterSheet<
+    S extends Shape<S,P>,
+    P extends TextParagraph<S,P,? extends TextRun>
+> extends Sheet<S,P> {
 
 }
index 3e4b92472190dc95f282d3dcce1551982867356c..377ad24c4003f64e6396c13ca0cffc9c7e34cf3b 100644 (file)
@@ -19,6 +19,9 @@ package org.apache.poi.sl.usermodel;
 
 import java.util.List;
 
-public interface Notes<T extends Shape, SS extends SlideShow> extends Sheet<T,SS> {
-       List<? extends List<? extends TextParagraph<? extends TextRun>>> getTextParagraphs();
+public interface Notes<
+    S extends Shape<S,P>,
+    P extends TextParagraph<S,P,? extends TextRun>
+> extends Sheet<S,P> {
+       List<? extends List<P>> getTextParagraphs();
 }
index a2c0824e0ccf9b561f80ee235419c8920746e8f5..c7fb629410e84ae61da75832d8e3df39221e0656 100644 (file)
@@ -19,7 +19,10 @@ package org.apache.poi.sl.usermodel;
 
 import java.awt.Insets;
 
-public interface PictureShape extends SimpleShape {
+public interface PictureShape<
+    S extends Shape<S,P>,
+    P extends TextParagraph<S,P,? extends TextRun>
+> extends SimpleShape<S,P> {
     /**
      * Returns the picture data for this picture.
      *
index f81a344b178d4e25f497b4d781dce2fb855a606b..f434b3cc6df329cb998d9bf217dbde23fcbfa85b 100644 (file)
@@ -19,8 +19,11 @@ package org.apache.poi.sl.usermodel;
 \r
 import java.awt.geom.Rectangle2D;\r
 \r
-public interface PlaceableShape {\r
-    ShapeContainer<? extends Shape> getParent();\r
+public interface PlaceableShape<\r
+    S extends Shape<S,P>,\r
+    P extends TextParagraph<S,P,? extends TextRun>\r
+> {\r
+    ShapeContainer<S,P> getParent();\r
     \r
     /**\r
      * @return the position of this shape within the drawing canvas.\r
index 4de645d41f41ae8c66f2a507a49d1dbd1ef0902f..164c406438095c6935beb23434fd5a068d2719ed 100644 (file)
 package org.apache.poi.sl.usermodel;
 
 
-public interface Shape {
-       ShapeContainer<? extends Shape> getParent();
+public interface Shape<
+    S extends Shape<S,P>,
+    P extends TextParagraph<S,P,? extends TextRun>
+> {
+       ShapeContainer<S,P> getParent();
        
     /**
     *
     * @return the sheet this shape belongs to
     */
-   Sheet<? extends Shape, ? extends SlideShow> getSheet();
+   Sheet<S,P> getSheet();
 }
index 0172fa7701590f9494dd2ade8e03b7a0f8f05901..b5c296098636f91e07a01f9c763c963c43d5711e 100644 (file)
@@ -20,7 +20,10 @@ package org.apache.poi.sl.usermodel;
 import java.util.List;
 
 
-public interface ShapeContainer<T extends Shape> extends Iterable<T> {
+public interface ShapeContainer<
+    S extends Shape<S,P>,
+    P extends TextParagraph<S,P,? extends TextRun>
+> extends Iterable<S> {
     /**
      * Returns an list containing all of the elements in this container in proper
      * sequence (from first to last element).
@@ -28,9 +31,9 @@ public interface ShapeContainer<T extends Shape> extends Iterable<T> {
      * @return an list containing all of the elements in this container in proper
      *         sequence
      */
-       List<T> getShapes();
+       List<S> getShapes();
 
-       void addShape(T shape);
+       void addShape(S shape);
 
     /**
      * Removes the specified shape from this sheet, if it is present
@@ -42,5 +45,43 @@ public interface ShapeContainer<T extends Shape> extends Iterable<T> {
      * @throws IllegalArgumentException if the type of the specified shape
      *         is incompatible with this sheet (optional)
      */
-       boolean removeShape(T shape);
+       boolean removeShape(S shape);
+
+    /**
+     * create a new shape with a predefined geometry and add it to this shape container
+     */
+    AutoShape<S,P> createAutoShape();
+
+    /**
+     * create a new shape with a custom geometry
+     */
+    FreeformShape<S,P> createFreeform();
+
+    /**
+     * create a text box
+     */
+       TextBox<S,P> createTextBox();
+       
+    /**
+     * create a connector
+     */
+       ConnectorShape<S,P> createConnector();
+       
+    /**
+     * create a group of shapes belonging to this container
+     */
+       GroupShape<S,P> createGroup();
+       
+    /**
+     * create a picture belonging to this container
+     */
+       PictureShape<S,P> createPicture(PictureData pictureData);
+       
+    /**
+     * Create a new Table of the given number of rows and columns
+     *
+     * @param numrows the number of rows
+     * @param numcols the number of columns
+     */
+       TableShape<S,P> createTable(int numRows, int numCols);
 }
index f94b7727a780a3aae23c8f3b5c1476a3a1f29c92..923dac3781299e10da7ea47416397c8ec964aad5 100644 (file)
@@ -23,8 +23,11 @@ import java.awt.Graphics2D;
 /**
  * Common parent of Slides, Notes and Masters
  */
-public interface Sheet<T extends Shape, SS extends SlideShow> extends ShapeContainer<T> {
-       SS getSlideShow();
+public interface Sheet<
+    S extends Shape<S,P>,
+    P extends TextParagraph<S,P,? extends TextRun>
+> extends ShapeContainer<S,P> {
+       SlideShow<S,P> getSlideShow();
 
     /**
      * @return whether shapes on the master sheet should be shown. By default master graphics is turned off.
@@ -33,9 +36,9 @@ public interface Sheet<T extends Shape, SS extends SlideShow> extends ShapeConta
      */
        boolean getFollowMasterGraphics();
        
-       MasterSheet<T,SS> getMasterSheet();
+       MasterSheet<S,P> getMasterSheet();
 
-       Background getBackground();
+       Background<S,P> getBackground();
        
        /**
         * Convenience method to draw a sheet to a graphics context
index e4e8efe3a13bd869ccbb8d1fe6614b65c4f08c19..92612cf956874882b84f73eeb4cffb3d51a7e39d 100644 (file)
@@ -21,7 +21,10 @@ import org.apache.poi.sl.draw.geom.CustomGeometry;
 import org.apache.poi.sl.draw.geom.IAdjustableShape;
 
 
-public interface SimpleShape extends Shape, IAdjustableShape, PlaceableShape {
+public interface SimpleShape<
+    S extends Shape<S,P>,
+    P extends TextParagraph<S,P,? extends TextRun>
+> extends Shape<S,P>, IAdjustableShape, PlaceableShape<S,P> {
     FillStyle getFillStyle();
     LineDecoration getLineDecoration();
     StrokeStyle getStrokeStyle();
index b992a5e3c6b7f1199e81bb49f015ae3630cae4cb..237e0229bbed194c5a9af2621453179c9b01caed 100644 (file)
 
 package org.apache.poi.sl.usermodel;
 
-public interface Slide<T extends Shape, SS extends SlideShow, N extends Notes<T,SS>> extends Sheet<T, SS> {
-    N getNotes();
-    void setNotes(N notes);
+public interface Slide<
+    S extends Shape<S,P>,
+    P extends TextParagraph<S,P,? extends TextRun>
+> extends Sheet<S,P> {
+    Notes<S,P> getNotes();
+    void setNotes(Notes<S,P> notes);
 
     boolean getFollowMasterBackground();
     void setFollowMasterBackground(boolean follow);
index ac2a7a7d90f7feaf36ef5861bea5c83f26a5c711..2b04327e466635dff4c86b5704ab2d0cf17c1152 100644 (file)
@@ -24,18 +24,21 @@ import java.util.List;
 
 import org.apache.poi.sl.usermodel.PictureData.PictureType;
 
-public interface SlideShow {
-       Slide<? extends Shape, ? extends SlideShow, ? extends Notes<?,?>> createSlide() throws IOException;
+public interface SlideShow<
+    S extends Shape<S,P>,
+    P extends TextParagraph<S,P,? extends TextRun>
+> {
+       Slide<S,P> createSlide() throws IOException;
 
-       List<? extends Slide<? extends Shape, ? extends SlideShow, ? extends Notes<?,?>>> getSlides();
+       List<? extends Slide<S,P>> getSlides();
 
-    MasterSheet<? extends Shape, ? extends SlideShow> createMasterSheet() throws IOException;
+    MasterSheet<S,P> createMasterSheet() throws IOException;
 
        /**
      * Returns all slide masters.
      * This doesn't include notes master and other arbitrary masters.
      */
-       List<? extends MasterSheet<? extends Shape, ? extends SlideShow>> getSlideMasters();
+       List<? extends MasterSheet<S,P>> getSlideMasters();
 
        Resources getResources();
 
diff --git a/src/java/org/apache/poi/sl/usermodel/TableCell.java b/src/java/org/apache/poi/sl/usermodel/TableCell.java
new file mode 100644 (file)
index 0000000..30cb2da
--- /dev/null
@@ -0,0 +1,25 @@
+/* ====================================================================\r
+   Licensed to the Apache Software Foundation (ASF) under one or more\r
+   contributor license agreements.  See the NOTICE file distributed with\r
+   this work for additional information regarding copyright ownership.\r
+   The ASF licenses this file to You under the Apache License, Version 2.0\r
+   (the "License"); you may not use this file except in compliance with\r
+   the License.  You may obtain a copy of the License at\r
+\r
+       http://www.apache.org/licenses/LICENSE-2.0\r
+\r
+   Unless required by applicable law or agreed to in writing, software\r
+   distributed under the License is distributed on an "AS IS" BASIS,\r
+   WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\r
+   See the License for the specific language governing permissions and\r
+   limitations under the License.\r
+==================================================================== */\r
+\r
+package org.apache.poi.sl.usermodel;\r
+\r
+public interface TableCell<\r
+    S extends Shape<S,P>,\r
+    P extends TextParagraph<S,P,? extends TextRun>\r
+> extends TextShape<S,P> {\r
+\r
+}\r
index 4fda40f2dffd3d59e1c693c3c452fa8fca8d399b..2ac2881d6d3eeb28b674cfce633b5667caa57003 100644 (file)
@@ -17,6 +17,9 @@
 \r
 package org.apache.poi.sl.usermodel;\r
 \r
-public interface TableShape extends Shape, PlaceableShape {\r
+public interface TableShape<\r
+    S extends Shape<S,P>,\r
+    P extends TextParagraph<S,P,? extends TextRun>\r
+> extends Shape<S,P>, PlaceableShape<S,P> {\r
     // to be defined ...\r
 }\r
index 3fa3bbe20d3ab3a3467f0d1a43c6c312af049396..94fd4de40df0783cd5cdd369eef56ad2e67d3918 100644 (file)
@@ -17,5 +17,8 @@
 
 package org.apache.poi.sl.usermodel;
 
-public interface TextBox<T extends TextParagraph<? extends TextRun>> extends AutoShape<T> {
+public interface TextBox<
+    S extends Shape<S,P>,
+    P extends TextParagraph<S,P,? extends TextRun>
+> extends AutoShape<S,P> {
 }
index 97296bb0bc54039d0a246e7807be321a61b5331a..00a016058d1565082f3cea3f79a83f7d8d91821b 100644 (file)
@@ -21,7 +21,11 @@ import java.awt.Color;
 \r
 \r
 \r
-public interface TextParagraph<T extends TextRun> extends Iterable<T> {\r
+public interface TextParagraph<\r
+    S extends Shape<S,P>,\r
+    P extends TextParagraph<S,P,T>,\r
+    T extends TextRun\r
+> extends Iterable<T> {\r
 \r
     /**\r
      * Specifies a list of text alignment types\r
@@ -334,5 +338,5 @@ public interface TextParagraph<T extends TextRun> extends Iterable<T> {
     Double getDefaultTabSize();\r
 \r
     \r
-    TextShape<? extends TextParagraph<T>> getParentShape();\r
+    TextShape<S,P> getParentShape();\r
 }\r
index 927fdf1f9de31bb714625682bb1dc67ac4781cbe..5f55a1dc40395ca65eb9b58aae76ffd272e58881 100644 (file)
 \r
 package org.apache.poi.sl.usermodel;\r
 \r
-import org.apache.poi.ss.usermodel.HorizontalAlignment;\r
+import java.util.List;\r
 \r
-\r
-\r
-public interface TextShape<T extends TextParagraph<? extends TextRun>> extends SimpleShape, Iterable<T>  {\r
+public interface TextShape<\r
+    S extends Shape<S,P>,\r
+    P extends TextParagraph<S,P,? extends TextRun>\r
+> extends SimpleShape<S,P>, Iterable<P>  {\r
     /**\r
      * Vertical Text Types\r
      */\r
@@ -87,40 +88,45 @@ public interface TextShape<T extends TextParagraph<? extends TextRun>> extends S
          * </p>\r
          */\r
         SHAPE\r
-    }    \r
+    }\r
     \r
+    /**\r
+     * @return the TextParagraphs for this text box\r
+     */\r
+    List<? extends TextParagraph<S,P,? extends TextRun>> getTextParagraphs();\r
+\r
     /**\r
      * @return text shape margin\r
      */\r
     Insets2D getInsets();\r
-    \r
+\r
     /**\r
      * Compute the cumulative height occupied by the text\r
      */\r
     double getTextHeight();\r
-    \r
+\r
     /**\r
      * Returns the type of vertical alignment for the text.\r
      *\r
      * @return the type of vertical alignment\r
      */\r
     VerticalAlignment getVerticalAlignment();\r
-    \r
+\r
     /**\r
      * Returns if the text is centered.\r
      * If true and if the individual paragraph settings allow it,\r
      * the whole text block will be displayed centered, i.e. its left and right\r
      * margin will be maximized while still keeping the alignment of the paragraphs\r
      *\r
-     * @return true, if the text anchor is horizontal centered \r
+     * @return true, if the text anchor is horizontal centered\r
      */\r
     boolean isHorizontalCentered();\r
-    \r
+\r
     /**\r
      * @return whether to wrap words within the bounding rectangle\r
      */\r
     boolean getWordWrap();\r
-    \r
+\r
     /**\r
      * @return vertical orientation of the text\r
      */\r
index 2bbec18ab9088eab5896077ce499b235a07400f3..2cf4bda982b9122c0b05cbe341f9a027e0b9ddf6 100644 (file)
@@ -68,7 +68,8 @@ import org.openxmlformats.schemas.presentationml.x2006.main.PresentationDocument
  *  top level object for creating new slides/etc.
  */
 @Beta
-public class XMLSlideShow extends POIXMLDocument implements SlideShow {
+public class XMLSlideShow extends POIXMLDocument
+implements SlideShow<XSLFShape,XSLFTextParagraph> {
     private static POILogger _logger = POILogFactory.getLogger(XMLSlideShow.class);
 
     private CTPresentation _presentation;
@@ -512,7 +513,8 @@ public class XMLSlideShow extends POIXMLDocument implements SlideShow {
         return null;
     }
 
-    public MasterSheet<XSLFShape, XMLSlideShow> createMasterSheet() throws IOException {
+    @Override
+    public MasterSheet<XSLFShape,XSLFTextParagraph> createMasterSheet() throws IOException {
         // TODO: implement!
         throw new UnsupportedOperationException();
     }
index a87d91bd5890a208e84c30cc7354d6b205a4e950..b9e40044887163583763f117e3df5cac18bc0bfc 100644 (file)
@@ -36,7 +36,8 @@ import org.openxmlformats.schemas.presentationml.x2006.main.CTShapeNonVisual;
  * @author Yegor Kozlov\r
  */\r
 @Beta\r
-public class XSLFAutoShape extends XSLFTextShape implements AutoShape<XSLFTextParagraph> {\r
+public class XSLFAutoShape extends XSLFTextShape\r
+    implements AutoShape<XSLFShape,XSLFTextParagraph> {\r
 \r
     /*package*/ XSLFAutoShape(CTShape shape, XSLFSheet sheet) {\r
         super(shape, sheet);\r
index e40494da2d6157f5a52b2f2096323c943d043cb3..6dbdf2d4f123fbc8085c2ba7806eecd722c16a30 100644 (file)
@@ -35,7 +35,8 @@ import org.openxmlformats.schemas.presentationml.x2006.main.CTBackground;
  *\r
  * @author Yegor Kozlov\r
  */\r
-public class XSLFBackground extends XSLFSimpleShape implements Background {\r
+public class XSLFBackground extends XSLFSimpleShape\r
+    implements Background<XSLFShape,XSLFTextParagraph> {\r
 \r
     /* package */XSLFBackground(CTBackground shape, XSLFSheet sheet) {\r
         super(shape, sheet);\r
index e5362c4d23d6461461d066aa4ead33db1588985e..ef8a2adf0f6a0c6c7514eef4a319ae18b281aacd 100644 (file)
@@ -34,7 +34,8 @@ import org.openxmlformats.schemas.presentationml.x2006.main.CTConnectorNonVisual
  * @author Yegor Kozlov\r
  */\r
 @Beta\r
-public class XSLFConnectorShape extends XSLFSimpleShape implements ConnectorShape {\r
+public class XSLFConnectorShape extends XSLFSimpleShape\r
+    implements ConnectorShape<XSLFShape,XSLFTextParagraph> {\r
 \r
     /*package*/ XSLFConnectorShape(CTConnector shape, XSLFSheet sheet) {\r
         super(shape, sheet);\r
index 8acc12b442bb3b0732dc2471b130c941945e4f0b..1f23523938144c7cd8be0a1eedecb87e547876ef 100644 (file)
@@ -49,7 +49,8 @@ import org.openxmlformats.schemas.presentationml.x2006.main.CTShapeNonVisual;
  * @author Yegor Kozlov\r
  */\r
 @Beta\r
-public class XSLFFreeformShape extends XSLFAutoShape implements FreeformShape<XSLFTextParagraph> {\r
+public class XSLFFreeformShape extends XSLFAutoShape\r
+    implements FreeformShape<XSLFShape,XSLFTextParagraph> {\r
 \r
     /*package*/ XSLFFreeformShape(CTShape shape, XSLFSheet sheet) {\r
         super(shape, sheet);\r
index 9115f0edd25b5003a92c1325d31d00c200836374..6199501178139d45bb81d51d68c3e78a744a02b6 100644 (file)
@@ -28,6 +28,7 @@ import org.apache.poi.openxml4j.opc.PackagePart;
 import org.apache.poi.openxml4j.opc.PackageRelationship;\r
 import org.apache.poi.openxml4j.opc.TargetMode;\r
 import org.apache.poi.sl.usermodel.GroupShape;\r
+import org.apache.poi.sl.usermodel.PictureData;\r
 import org.apache.poi.util.Beta;\r
 import org.apache.poi.util.POILogFactory;\r
 import org.apache.poi.util.POILogger;\r
@@ -49,7 +50,8 @@ import org.openxmlformats.schemas.presentationml.x2006.main.CTShape;
  * @author Yegor Kozlov\r
  */\r
 @Beta\r
-public class XSLFGroupShape extends XSLFShape implements XSLFShapeContainer, GroupShape<XSLFShape> {\r
+public class XSLFGroupShape extends XSLFShape\r
+implements XSLFShapeContainer, GroupShape<XSLFShape,XSLFTextParagraph> {\r
     private static POILogger _logger = POILogFactory.getLogger(XSLFGroupShape.class);\r
     \r
     private final List<XSLFShape> _shapes;\r
@@ -237,8 +239,12 @@ public class XSLFGroupShape extends XSLFShape implements XSLFShapeContainer, Gro
         return sh;\r
     }\r
 \r
-    public XSLFPictureShape createPicture(XSLFPictureData pictureData){\r
-        PackagePart pic = pictureData.getPackagePart();\r
+    public XSLFPictureShape createPicture(PictureData pictureData){\r
+        if (!(pictureData instanceof XSLFPictureData)) {\r
+            throw new IllegalArgumentException("pictureData needs to be of type XSLFPictureData");\r
+        }\r
+        XSLFPictureData xPictureData = (XSLFPictureData)pictureData;\r
+        PackagePart pic = xPictureData.getPackagePart();\r
 \r
         PackageRelationship rel = getSheet().getPackagePart().addRelationship(\r
                 pic.getPartName(), TargetMode.INTERNAL, XSLFRelation.IMAGES.getRelation());\r
@@ -257,6 +263,24 @@ public class XSLFGroupShape extends XSLFShape implements XSLFShapeContainer, Gro
         return sh;\r
     }\r
     \r
+    @Override\r
+    public XSLFTable createTable(int numRows, int numCols){\r
+        if (numRows < 1 || numCols < 1) {\r
+            throw new IllegalArgumentException("numRows and numCols must be greater than 0");\r
+        }\r
+        XSLFTable sh = getDrawing().createTable();\r
+        _shapes.add(sh);\r
+        sh.setParent(this);\r
+        for (int r=0; r<numRows; r++) {\r
+            XSLFTableRow row = sh.addRow();\r
+            for (int c=0; c<numCols; c++) {\r
+                row.addCell();\r
+            }\r
+        }\r
+        return sh;\r
+    }\r
+\r
+    \r
     @Override\r
     public void setFlipHorizontal(boolean flip){\r
         getSafeXfrm().setFlipH(flip);\r
index 6fb98c07db39158c72504aac87d17ebf581494f2..0acb411fc2bfa202cc1ea328aa199f855c20ca7c 100644 (file)
@@ -31,7 +31,8 @@ import org.openxmlformats.schemas.presentationml.x2006.main.CTNotesSlide;
 import org.openxmlformats.schemas.presentationml.x2006.main.NotesDocument;
 
 @Beta
-public final class XSLFNotes extends XSLFSheet implements Notes<XSLFShape,XMLSlideShow> {
+public final class XSLFNotes extends XSLFSheet
+implements Notes<XSLFShape,XSLFTextParagraph> {
    private CTNotesSlide _notes;
 
     /**
@@ -83,6 +84,7 @@ public final class XSLFNotes extends XSLFSheet implements Notes<XSLFShape,XMLSli
        return getMasterSheet().getTheme();
     }
 
+    @Override
     public XSLFNotesMaster getMasterSheet() {
         for (POIXMLDocumentPart p : getRelations()) {
            if (p instanceof XSLFNotesMaster){
index aeea5cc521d85ce71e0e02803bedf1f1f7fae069..5da683ce56bc3b0455ffb2ab773e4549224b1734 100644 (file)
@@ -47,7 +47,8 @@ import org.openxmlformats.schemas.presentationml.x2006.main.NotesMasterDocument;
  * @author Yegor Kozlov
 */
 @Beta
- public class XSLFNotesMaster extends XSLFSheet implements MasterSheet<XSLFShape,XMLSlideShow> {
+ public class XSLFNotesMaster extends XSLFSheet
+     implements MasterSheet<XSLFShape,XSLFTextParagraph> {
         private CTNotesMaster _slide;
      private XSLFTheme _theme;
 
@@ -94,7 +95,7 @@ import org.openxmlformats.schemas.presentationml.x2006.main.NotesMasterDocument;
     }
 
     @Override
-    public MasterSheet<XSLFShape,XMLSlideShow> getMasterSheet() {
+    public MasterSheet<XSLFShape,XSLFTextParagraph> getMasterSheet() {
         return null;
     }
     
index 73ec45b9a8ab3008604692d1909a09130c3abe8b..0dc14844ea67e7efdef3d6f42c456f7f49d86f97 100644 (file)
@@ -51,7 +51,8 @@ import org.openxmlformats.schemas.presentationml.x2006.main.CTPictureNonVisual;
  * Represents a picture shape\r
  */\r
 @Beta\r
-public class XSLFPictureShape extends XSLFSimpleShape implements PictureShape {\r
+public class XSLFPictureShape extends XSLFSimpleShape\r
+    implements PictureShape<XSLFShape,XSLFTextParagraph> {\r
     private XSLFPictureData _data;\r
 \r
     /*package*/ XSLFPictureShape(CTPicture shape, XSLFSheet sheet) {\r
index d0c5123825bc8074b6b595e3633cb8ebc51eda31..37dbc33a227c57bda31e78bec62c900f01b4210f 100644 (file)
@@ -65,7 +65,7 @@ import org.openxmlformats.schemas.presentationml.x2006.main.STPlaceholderType;
  * @author Yegor Kozlov\r
  */\r
 @Beta\r
-public abstract class XSLFShape implements Shape {\r
+public abstract class XSLFShape implements Shape<XSLFShape,XSLFTextParagraph> {\r
     private final XmlObject _shape;\r
     private final XSLFSheet _sheet;\r
     private XSLFShapeContainer _parent;\r
@@ -130,8 +130,8 @@ public abstract class XSLFShape implements Shape {
         }\r
 \r
         if (this instanceof PlaceableShape) {\r
-            PlaceableShape ps = (PlaceableShape)this;\r
-            ps.setAnchor(((PlaceableShape)sh).getAnchor());\r
+            PlaceableShape<?,?> ps = (PlaceableShape<?,?>)this;\r
+            ps.setAnchor(((PlaceableShape<?,?>)sh).getAnchor());\r
         }\r
         \r
         \r
index f7078029b61be1f8d9c5194cc36bcf378aa3bc21..ddf832d3d9530ec968547ad88838fc4ab347344c 100644 (file)
 
 package org.apache.poi.xslf.usermodel;
 
+import org.apache.poi.sl.usermodel.PictureData;
 import org.apache.poi.sl.usermodel.ShapeContainer;
 
 /**
  * Common interface for shape containers, e.g. sheets or groups of shapes
  */
-public interface XSLFShapeContainer extends ShapeContainer<XSLFShape> {
+public interface XSLFShapeContainer
+    extends ShapeContainer<XSLFShape,XSLFTextParagraph> {
 
-    /**
-     * create a new shape with a predefined geometry and add it to this shape container
-     */
+    @Override
     XSLFAutoShape createAutoShape();
 
-    /**
-     * create a new shape with a custom geometry
-     */
+    @Override
     XSLFFreeformShape createFreeform();
 
-    /**
-     * create a text box
-     */
+    @Override
     XSLFTextBox createTextBox();
 
-    /**
-     *
-     * create a connector
-     */
+    @Override
     XSLFConnectorShape createConnector();
 
-    /**
-     * create a group of shapes belonging to this container
-     */
+    @Override
     XSLFGroupShape createGroup();
 
-    /**
-     * create a picture belonging to this container
-     */
-    XSLFPictureShape createPicture(XSLFPictureData pictureData);
+    @Override
+    XSLFPictureShape createPicture(PictureData pictureData);
 
     /**
      * Removes all of the elements from this container (optional operation).
index 62ef3b7ec7d3c1ed891f5e46cef80d7a5cd755f4..627f97310b95be86f123acc685300d53be5fd3a8 100644 (file)
@@ -37,6 +37,7 @@ import org.apache.poi.openxml4j.opc.PackageRelationship;
 import org.apache.poi.openxml4j.opc.TargetMode;
 import org.apache.poi.sl.draw.DrawFactory;
 import org.apache.poi.sl.draw.Drawable;
+import org.apache.poi.sl.usermodel.PictureData;
 import org.apache.poi.sl.usermodel.Sheet;
 import org.apache.poi.util.Beta;
 import org.apache.poi.util.IOUtils;
@@ -53,7 +54,8 @@ import org.openxmlformats.schemas.presentationml.x2006.main.CTPlaceholder;
 import org.openxmlformats.schemas.presentationml.x2006.main.CTShape;
 
 @Beta
-public abstract class XSLFSheet extends POIXMLDocumentPart implements XSLFShapeContainer, Sheet<XSLFShape, XMLSlideShow> {
+public abstract class XSLFSheet extends POIXMLDocumentPart
+implements XSLFShapeContainer, Sheet<XSLFShape,XSLFTextParagraph> {
     private XSLFCommonSlideData _commonSlideData;
     private XSLFDrawing _drawing;
     private List<XSLFShape> _shapes;
@@ -72,9 +74,9 @@ public abstract class XSLFSheet extends POIXMLDocumentPart implements XSLFShapeC
     }
 
     /**
-     *
      * @return the XMLSlideShow this sheet belongs to
      */
+    @Override
     public XMLSlideShow getSlideShow() {
         POIXMLDocumentPart p = getParent();
         while(p != null) {
@@ -158,6 +160,7 @@ public abstract class XSLFSheet extends POIXMLDocumentPart implements XSLFShapeC
 
     // shape factory methods
 
+    @Override
     public XSLFAutoShape createAutoShape(){
         XSLFAutoShape sh = getDrawing().createAutoShape();
         getShapes().add(sh);
@@ -165,6 +168,7 @@ public abstract class XSLFSheet extends POIXMLDocumentPart implements XSLFShapeC
         return sh;
     }
 
+    @Override
     public XSLFFreeformShape createFreeform(){
         XSLFFreeformShape sh = getDrawing().createFreeform();
         getShapes().add(sh);
@@ -172,6 +176,7 @@ public abstract class XSLFSheet extends POIXMLDocumentPart implements XSLFShapeC
         return sh;
     }
 
+    @Override
     public XSLFTextBox createTextBox(){
         XSLFTextBox sh = getDrawing().createTextBox();
         getShapes().add(sh);
@@ -179,6 +184,7 @@ public abstract class XSLFSheet extends POIXMLDocumentPart implements XSLFShapeC
         return sh;
     }
 
+    @Override
     public XSLFConnectorShape createConnector(){
         XSLFConnectorShape sh = getDrawing().createConnector();
         getShapes().add(sh);
@@ -186,6 +192,7 @@ public abstract class XSLFSheet extends POIXMLDocumentPart implements XSLFShapeC
         return sh;
     }
 
+    @Override
     public XSLFGroupShape createGroup(){
         XSLFGroupShape sh = getDrawing().createGroup();
         getShapes().add(sh);
@@ -193,8 +200,13 @@ public abstract class XSLFSheet extends POIXMLDocumentPart implements XSLFShapeC
         return sh;
     }
 
-    public XSLFPictureShape createPicture(XSLFPictureData pictureData){
-        PackagePart pic = pictureData.getPackagePart();
+    @Override
+    public XSLFPictureShape createPicture(PictureData pictureData){
+        if (!(pictureData instanceof XSLFPictureData)) {
+            throw new IllegalArgumentException("pictureData needs to be of type XSLFPictureData");
+        }
+        XSLFPictureData xPictureData = (XSLFPictureData)pictureData;
+        PackagePart pic = xPictureData.getPackagePart();
 
         PackageRelationship rel = getPackagePart().addRelationship(
                 pic.getPartName(), TargetMode.INTERNAL, XSLFRelation.IMAGES.getRelation());
@@ -214,6 +226,24 @@ public abstract class XSLFSheet extends POIXMLDocumentPart implements XSLFShapeC
         return sh;
     }
 
+    @Override
+    public XSLFTable createTable(int numRows, int numCols){
+        if (numRows < 1 || numCols < 1) {
+            throw new IllegalArgumentException("numRows and numCols must be greater than 0");
+        }
+        XSLFTable sh = getDrawing().createTable();
+        getShapes().add(sh);
+        sh.setParent(this);
+        for (int r=0; r<numRows; r++) {
+            XSLFTableRow row = sh.addRow();
+            for (int c=0; c<numCols; c++) {
+                row.addCell();
+            }
+        }
+        return sh;
+    }
+
+    
     /**
      * Returns an iterator over the shapes in this sheet
      *
@@ -481,9 +511,9 @@ public abstract class XSLFSheet extends POIXMLDocumentPart implements XSLFShapeC
     }
 
     /**
-     *
      * @return  background for this sheet
      */
+    @Override
     public XSLFBackground getBackground() {
         return null;
     }
index 3b08748762894d41dd3ee0756e834380902a7881..4ada16bf847e41de940c30709ffa9ea78515f26b 100644 (file)
@@ -54,7 +54,8 @@ import org.openxmlformats.schemas.presentationml.x2006.main.CTPlaceholder;
  * @author Yegor Kozlov\r
  */\r
 @Beta\r
-public abstract class XSLFSimpleShape extends XSLFShape implements SimpleShape {\r
+public abstract class XSLFSimpleShape extends XSLFShape\r
+    implements SimpleShape<XSLFShape,XSLFTextParagraph> {\r
     private static CTOuterShadowEffect NO_SHADOW = CTOuterShadowEffect.Factory.newInstance();\r
 \r
     /* package */XSLFSimpleShape(XmlObject shape, XSLFSheet sheet) {\r
index 83453573cd00445069baff0833285553afb37300..cb66f697f05cd324d17f6489ecb6df67adb4d18e 100644 (file)
@@ -24,6 +24,7 @@ import org.apache.poi.openxml4j.opc.PackagePart;
 import org.apache.poi.openxml4j.opc.PackageRelationship;
 import org.apache.poi.sl.draw.DrawFactory;
 import org.apache.poi.sl.draw.Drawable;
+import org.apache.poi.sl.usermodel.Notes;
 import org.apache.poi.sl.usermodel.Slide;
 import org.apache.poi.util.Beta;
 import org.apache.xmlbeans.XmlException;
@@ -41,7 +42,8 @@ import org.openxmlformats.schemas.presentationml.x2006.main.CTSlide;
 import org.openxmlformats.schemas.presentationml.x2006.main.SldDocument;
 
 @Beta
-public final class XSLFSlide extends XSLFSheet implements Slide<XSLFShape, XMLSlideShow, XSLFNotes> {
+public final class XSLFSlide extends XSLFSheet
+implements Slide<XSLFShape,XSLFTextParagraph> {
    private final CTSlide _slide;
    private XSLFSlideLayout _layout;
    private XSLFComments _comments;
@@ -254,11 +256,12 @@ public final class XSLFSlide extends XSLFSheet implements Slide<XSLFShape, XMLSl
         throw new UnsupportedOperationException();
     }
 
-    public void setNotes(XSLFNotes notes) {
+    @Override
+    public void setNotes(Notes<XSLFShape,XSLFTextParagraph> notes) {
+        assert(notes instanceof XSLFNotes);
         // TODO Auto-generated method stub
-        
     }
-
+    
     @Override
     public int getSlideNumber() {
         int idx = getSlideShow().getSlides().indexOf(this);
index b408d529ec2ac9aa58be0e5355f7590041c5e9ab..48c5b20358d419abdd1d9c9f101da0b25fbb6bad 100644 (file)
@@ -31,7 +31,8 @@ import org.openxmlformats.schemas.presentationml.x2006.main.CTSlideLayout;
 import org.openxmlformats.schemas.presentationml.x2006.main.SldLayoutDocument;
 
 @Beta
-public class XSLFSlideLayout extends XSLFSheet implements MasterSheet<XSLFShape, XMLSlideShow> {
+public class XSLFSlideLayout extends XSLFSheet
+implements MasterSheet<XSLFShape,XSLFTextParagraph> {
     private CTSlideLayout _layout;
     private XSLFSlideMaster _master;
 
index c1ed1bf0d9f4b39dc5440601dd677e234a9a9e54..776cbf6772e6e8c36b8ccf99b61b746b2c634273 100644 (file)
@@ -54,7 +54,8 @@ import org.openxmlformats.schemas.presentationml.x2006.main.SldMasterDocument;
  * @author Yegor Kozlov
 */
 @Beta
- public class XSLFSlideMaster extends XSLFSheet implements MasterSheet<XSLFShape, XMLSlideShow> {
+ public class XSLFSlideMaster extends XSLFSheet
+ implements MasterSheet<XSLFShape,XSLFTextParagraph> {
        private CTSlideMaster _slide;
     private Map<String, XSLFSlideLayout> _layouts;
     private XSLFTheme _theme;
@@ -83,7 +84,7 @@ import org.openxmlformats.schemas.presentationml.x2006.main.SldMasterDocument;
     }
 
     @Override
-    public MasterSheet<XSLFShape, XMLSlideShow> getMasterSheet() {
+    public XSLFSlideMaster getMasterSheet() {
         return null;
     }
 
index 9f2bb490327f1258209cf78762a378ee4580f0a4..3f156316676d282f6b6952eb7c35bda1bbc6abd1 100644 (file)
@@ -46,7 +46,8 @@ import org.openxmlformats.schemas.presentationml.x2006.main.CTGraphicalObjectFra
  *\r
  * @author Yegor Kozlov\r
  */\r
-public class XSLFTable extends XSLFGraphicFrame implements Iterable<XSLFTableRow>, TableShape {\r
+public class XSLFTable extends XSLFGraphicFrame implements Iterable<XSLFTableRow>,\r
+    TableShape<XSLFShape,XSLFTextParagraph> {\r
     static String TABLE_URI = "http://schemas.openxmlformats.org/drawingml/2006/table";\r
 \r
     private CTTable _table;\r
index 93811527873e20c547f53f94d48559474800f647..29f373929e3360e508986961c43794cc47945915 100644 (file)
@@ -21,14 +21,29 @@ package org.apache.poi.xslf.usermodel;
 \r
 import java.awt.Color;\r
 \r
+import org.apache.poi.sl.usermodel.TableCell;\r
 import org.apache.poi.sl.usermodel.VerticalAlignment;\r
 import org.apache.poi.util.Units;\r
-import org.openxmlformats.schemas.drawingml.x2006.main.*;\r
+import org.openxmlformats.schemas.drawingml.x2006.main.CTLineEndProperties;\r
+import org.openxmlformats.schemas.drawingml.x2006.main.CTLineProperties;\r
+import org.openxmlformats.schemas.drawingml.x2006.main.CTSRgbColor;\r
+import org.openxmlformats.schemas.drawingml.x2006.main.CTSolidColorFillProperties;\r
+import org.openxmlformats.schemas.drawingml.x2006.main.CTTableCell;\r
+import org.openxmlformats.schemas.drawingml.x2006.main.CTTableCellProperties;\r
+import org.openxmlformats.schemas.drawingml.x2006.main.CTTextBody;\r
+import org.openxmlformats.schemas.drawingml.x2006.main.STCompoundLine;\r
+import org.openxmlformats.schemas.drawingml.x2006.main.STLineCap;\r
+import org.openxmlformats.schemas.drawingml.x2006.main.STLineEndLength;\r
+import org.openxmlformats.schemas.drawingml.x2006.main.STLineEndType;\r
+import org.openxmlformats.schemas.drawingml.x2006.main.STLineEndWidth;\r
+import org.openxmlformats.schemas.drawingml.x2006.main.STPenAlignment;\r
+import org.openxmlformats.schemas.drawingml.x2006.main.STPresetLineDashVal;\r
+import org.openxmlformats.schemas.drawingml.x2006.main.STTextAnchoringType;\r
 \r
 /**\r
  * Represents a cell of a table in a .pptx presentation\r
  */\r
-public class XSLFTableCell extends XSLFTextShape {\r
+public class XSLFTableCell extends XSLFTextShape implements TableCell<XSLFShape,XSLFTextParagraph> {\r
     static double defaultBorderWidth = 1.0;\r
     private CTTableCellProperties _tcPr = null;\r
 \r
index e27bedbb53dbee5d181ba5dbe9d9938edc66824a..65635c4d3c97accc8168187ee5a8b65229448fca 100644 (file)
@@ -19,6 +19,7 @@
 \r
 package org.apache.poi.xslf.usermodel;\r
 \r
+import org.apache.poi.sl.usermodel.TextBox;\r
 import org.apache.poi.util.Beta;\r
 import org.openxmlformats.schemas.drawingml.x2006.main.*;\r
 import org.openxmlformats.schemas.presentationml.x2006.main.CTShape;\r
@@ -29,7 +30,8 @@ import org.openxmlformats.schemas.presentationml.x2006.main.CTShapeNonVisual;
  * @author Yegor Kozlov\r
  */\r
 @Beta\r
-public class XSLFTextBox extends XSLFAutoShape {\r
+public class XSLFTextBox extends XSLFAutoShape\r
+    implements TextBox<XSLFShape,XSLFTextParagraph> {\r
 \r
     /*package*/ XSLFTextBox(CTShape shape, XSLFSheet sheet){\r
         super(shape, sheet);\r
index 6cffd94701193adaa1437a0dc418d4fd6a47bf12..68d7438d4e3f5e38d784a2481e5f2ca677306701 100644 (file)
@@ -44,7 +44,7 @@ import org.openxmlformats.schemas.presentationml.x2006.main.STPlaceholderType;
  * @since POI-3.8\r
  */\r
 @Beta\r
-public class XSLFTextParagraph implements TextParagraph<XSLFTextRun> {\r
+public class XSLFTextParagraph implements TextParagraph<XSLFShape,XSLFTextParagraph,XSLFTextRun> {\r
     private final CTTextParagraph _p;\r
     private final List<XSLFTextRun> _runs;\r
     private final XSLFTextShape _shape;\r
index ae5470c796172812d50cff242414828d9c7e6c41..034b50cddb287b972f5458647341b6291ff2f9db 100644 (file)
@@ -48,7 +48,8 @@ import org.openxmlformats.schemas.presentationml.x2006.main.CTPlaceholder;
  * Represents a shape that can hold text.
  */
 @Beta
-public abstract class XSLFTextShape extends XSLFSimpleShape implements TextShape<XSLFTextParagraph> {
+public abstract class XSLFTextShape extends XSLFSimpleShape
+    implements TextShape<XSLFShape,XSLFTextParagraph> {
     private final List<XSLFTextParagraph> _paragraphs;
 
     @SuppressWarnings("deprecation")
@@ -96,10 +97,7 @@ public abstract class XSLFTextShape extends XSLFSimpleShape implements TextShape
         addNewTextParagraph().addNewTextRun().setText(text);
     }
 
-    /**
-     *
-     * @return text paragraphs in this shape
-     */
+    @Override
     public List<XSLFTextParagraph> getTextParagraphs() {
         return _paragraphs;
     }
@@ -459,7 +457,7 @@ public abstract class XSLFTextShape extends XSLFSimpleShape implements TextShape
     @Override
     public double getTextHeight(){
         DrawFactory drawFact = DrawFactory.getInstance(null);
-        DrawTextShape<XSLFTextShape> dts = drawFact.getDrawable(this);
+        DrawTextShape dts = drawFact.getDrawable(this);
         return dts.getTextHeight();
     }
 
index 43fefedf54cd25862784508dcd30a354bd13b07b..cc59f04fd93df65c4bf4d05e9112905be69d87f4 100644 (file)
@@ -116,8 +116,8 @@ public class PPTX2PNG {
         if (!quite) {\r
             System.out.println("Processing " + file);\r
         }\r
-        SlideShow ss = SlideShowFactory.create(file, null, true);\r
-        List<? extends Slide<?,?,?>> slides = ss.getSlides();\r
+        SlideShow<?,?> ss = SlideShowFactory.create(file, null, true);\r
+        List<? extends Slide<?,?>> slides = ss.getSlides();\r
 \r
         \r
         if (slidenum < -1 || slidenum == 0 || slidenum > slides.size()) {\r
@@ -130,7 +130,7 @@ public class PPTX2PNG {
         int height = (int) (pgsize.height * scale);\r
 \r
         int slideNo=1;\r
-        for(Slide<?,?,?> slide : slides) {\r
+        for(Slide<?,?> slide : slides) {\r
             if (slidenum == -1 || slideNo == slidenum) {\r
                 String title = slide.getTitle();\r
                 if (!quite) {\r
index 1ad525011c2266b8a3a2e454fbee0ac152bec914..a2ddfadbbcab97e0a4437c20f79225c6e2782de4 100644 (file)
@@ -44,7 +44,7 @@ import org.junit.Test;
 public class TestXSLFTextParagraph {\r
     // private static POILogger _logger = POILogFactory.getLogger(XSLFTextParagraph.class);\r
 \r
-    static class DrawTextParagraphProxy extends DrawTextParagraph<XSLFTextRun> {\r
+    static class DrawTextParagraphProxy extends DrawTextParagraph {\r
         DrawTextParagraphProxy(XSLFTextParagraph p) {\r
             super(p);\r
         }\r
index 25bb1aa13154e4cf3687d648ba7f729145724cb2..5bcf98ab850d8a80ac5b4231ea9fe99f7748dbfd 100644 (file)
@@ -20,10 +20,10 @@ package org.apache.poi.hslf.model;
 import java.io.ByteArrayOutputStream;
 import java.util.Iterator;
 
+import org.apache.poi.ddf.AbstractEscherOptRecord;
 import org.apache.poi.ddf.EscherClientDataRecord;
 import org.apache.poi.ddf.EscherComplexProperty;
 import org.apache.poi.ddf.EscherContainerRecord;
-import org.apache.poi.ddf.EscherOptRecord;
 import org.apache.poi.ddf.EscherProperties;
 import org.apache.poi.ddf.EscherRecord;
 import org.apache.poi.ddf.EscherSpRecord;
@@ -34,7 +34,11 @@ import org.apache.poi.hslf.record.ExObjList;
 import org.apache.poi.hslf.record.OEShapeAtom;
 import org.apache.poi.hslf.record.Record;
 import org.apache.poi.hslf.record.RecordTypes;
-import org.apache.poi.hslf.usermodel.*;
+import org.apache.poi.hslf.usermodel.HSLFPictureData;
+import org.apache.poi.hslf.usermodel.HSLFPictureShape;
+import org.apache.poi.hslf.usermodel.HSLFShape;
+import org.apache.poi.hslf.usermodel.HSLFSheet;
+import org.apache.poi.hslf.usermodel.HSLFTextParagraph;
 import org.apache.poi.sl.usermodel.ShapeContainer;
 import org.apache.poi.sl.usermodel.ShapeType;
 import org.apache.poi.util.LittleEndian;
@@ -66,7 +70,7 @@ public final class ActiveXShape extends HSLFPictureShape {
       *        this picture in the <code>Slide</code>
       * @param parent the parent shape of this picture
       */
-     protected ActiveXShape(EscherContainerRecord escherRecord, ShapeContainer<HSLFShape> parent){
+     protected ActiveXShape(EscherContainerRecord escherRecord, ShapeContainer<HSLFShape,HSLFTextParagraph> parent){
         super(escherRecord, parent);
     }
 
@@ -172,7 +176,7 @@ public final class ActiveXShape extends HSLFPictureShape {
         String name = ctrl.getProgId() + "-" + getControlIndex() + '\u0000';
         byte[] data = StringUtil.getToUnicodeLE(name);
         EscherComplexProperty prop = new EscherComplexProperty(EscherProperties.GROUPSHAPE__SHAPENAME, false, data);
-        EscherOptRecord opt = getEscherOptRecord();
+        AbstractEscherOptRecord opt = getEscherOptRecord();
         opt.addEscherProperty(prop);
     }
 }
index 0e35a0e2984aa5990af92157ac4a6effe25ad3c7..d4da2a3101ef57e4343e18eb6fd6f9ad4672239b 100644 (file)
@@ -55,7 +55,7 @@ public final class MovieShape extends HSLFPictureShape {
      * @param pictureData the picture data
      * @param parent the parent shape
      */
-    public MovieShape(int movieIdx, HSLFPictureData pictureData, ShapeContainer<HSLFShape> parent) {
+    public MovieShape(int movieIdx, HSLFPictureData pictureData, ShapeContainer<HSLFShape,HSLFTextParagraph> parent) {
         super(pictureData, parent);
         setMovieIndex(movieIdx);
     }
@@ -67,7 +67,7 @@ public final class MovieShape extends HSLFPictureShape {
       *        this picture in the <code>Slide</code>
       * @param parent the parent shape of this picture
       */
-    public MovieShape(EscherContainerRecord escherRecord, ShapeContainer<HSLFShape> parent){
+    public MovieShape(EscherContainerRecord escherRecord, ShapeContainer<HSLFShape,HSLFTextParagraph> parent){
         super(escherRecord, parent);
     }
 
index 6f8792df26eb27edd50a08ee95b5ef5f5150676f..c61c5ce5ac4e7ab8f104cd290f2d9a8799457cd3 100644 (file)
@@ -51,7 +51,7 @@ public final class OLEShape extends HSLFPictureShape {
      * @param data the picture data
      * @param parent the parent shape
      */
-    public OLEShape(HSLFPictureData data, ShapeContainer<HSLFShape> parent) {
+    public OLEShape(HSLFPictureData data, ShapeContainer<HSLFShape,HSLFTextParagraph> parent) {
         super(data, parent);
     }
 
@@ -62,7 +62,7 @@ public final class OLEShape extends HSLFPictureShape {
       *        this picture in the <code>Slide</code>
       * @param parent the parent shape of this picture
       */
-    public OLEShape(EscherContainerRecord escherRecord, ShapeContainer<HSLFShape> parent){
+    public OLEShape(EscherContainerRecord escherRecord, ShapeContainer<HSLFShape,HSLFTextParagraph> parent){
         super(escherRecord, parent);
     }
 
index 78e7a47350d5f8678e26a4fc145dbfb19bf963ab..1e632b8dcc9bdbb30653abdc0dabf27ad670e975 100644 (file)
@@ -21,6 +21,7 @@ import org.apache.poi.ddf.*;
 import org.apache.poi.hslf.record.OEPlaceholderAtom;
 import org.apache.poi.hslf.usermodel.HSLFShape;
 import org.apache.poi.hslf.usermodel.HSLFTextBox;
+import org.apache.poi.hslf.usermodel.HSLFTextParagraph;
 import org.apache.poi.hslf.exceptions.HSLFException;
 import org.apache.poi.sl.usermodel.ShapeContainer;
 
@@ -33,11 +34,11 @@ import java.io.ByteArrayOutputStream;
  */
 public final class Placeholder extends HSLFTextBox {
 
-    protected Placeholder(EscherContainerRecord escherRecord, ShapeContainer<HSLFShape> parent){
+    protected Placeholder(EscherContainerRecord escherRecord, ShapeContainer<HSLFShape,HSLFTextParagraph> parent){
         super(escherRecord, parent);
     }
 
-    public Placeholder(ShapeContainer<HSLFShape> parent){
+    public Placeholder(ShapeContainer<HSLFShape,HSLFTextParagraph> parent){
         super(parent);
     }
 
@@ -59,7 +60,7 @@ public final class Placeholder extends HSLFTextBox {
         EscherClientDataRecord cldata = new EscherClientDataRecord();
         cldata.setOptions((short)15);
 
-        EscherOptRecord opt = getEscherOptRecord();
+        AbstractEscherOptRecord opt = getEscherOptRecord();
 
         //Placeholders can't be grouped
         setEscherProperty(opt, EscherProperties.PROTECTION__LOCKAGAINSTGROUPING, 262144);
index 2a26973463015936a5b4be32028a36723d33216f..9c2cb24ed8db8ee24033a55382a52d86562673de 100644 (file)
@@ -38,7 +38,7 @@ public final class Polygon extends HSLFAutoShape {
      * @param escherRecord       <code>EscherSpContainer</code> container which holds information about this shape
      * @param parent    the parent of the shape
      */
-   protected Polygon(EscherContainerRecord escherRecord, ShapeContainer<HSLFShape> parent){
+   protected Polygon(EscherContainerRecord escherRecord, ShapeContainer<HSLFShape,HSLFTextParagraph> parent){
         super(escherRecord, parent);
 
     }
@@ -49,7 +49,7 @@ public final class Polygon extends HSLFAutoShape {
      * @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 Polygon(ShapeContainer<HSLFShape> parent){
+    public Polygon(ShapeContainer<HSLFShape,HSLFTextParagraph> parent){
         super((EscherContainerRecord)null, parent);
         _escherContainer = createSpContainer(ShapeType.NOT_PRIMITIVE, parent instanceof HSLFGroupShape);
     }
@@ -75,7 +75,7 @@ public final class Polygon extends HSLFAutoShape {
         float left   = findSmallest(xPoints);
         float top    = findSmallest(yPoints);
 
-        EscherOptRecord opt = getEscherOptRecord();
+        AbstractEscherOptRecord opt = getEscherOptRecord();
         opt.addEscherProperty(new EscherSimpleProperty(EscherProperties.GEOMETRY__RIGHT, Units.pointsToMaster(right - left)));
         opt.addEscherProperty(new EscherSimpleProperty(EscherProperties.GEOMETRY__BOTTOM, Units.pointsToMaster(bottom - top)));
 
index ceb655250c1052d37699c92ba91b0c1cb01a85ff..21c07010ca86bb326a344c3b3c7fd40277b2f4fe 100644 (file)
@@ -31,13 +31,13 @@ import org.apache.poi.ss.usermodel.ShapeTypes;
  *
  *  @author Yegor Kozlov
  */
-public class HSLFAutoShape extends HSLFTextShape implements AutoShape<HSLFTextParagraph> {
+public class HSLFAutoShape extends HSLFTextShape implements AutoShape<HSLFShape,HSLFTextParagraph> {
 
-    protected HSLFAutoShape(EscherContainerRecord escherRecord, ShapeContainer<HSLFShape> parent){
+    protected HSLFAutoShape(EscherContainerRecord escherRecord, ShapeContainer<HSLFShape,HSLFTextParagraph> parent){
         super(escherRecord, parent);
     }
 
-    public HSLFAutoShape(ShapeType type, ShapeContainer<HSLFShape> parent){
+    public HSLFAutoShape(ShapeType type, ShapeContainer<HSLFShape,HSLFTextParagraph> parent){
         super(null, parent);
         _escherContainer = createSpContainer(type, parent instanceof HSLFGroupShape);
     }
index 4b9846fd698a50f2e8e0b28cf08eeff84336b08a..8f477f95626150757ae9dca003a2b7ee3e0bdb3a 100644 (file)
@@ -26,9 +26,9 @@ import org.apache.poi.sl.usermodel.ShapeContainer;
  *
  * @author Yegor Kozlov
  */
-public final class HSLFBackground extends HSLFShape implements Background {
+public final class HSLFBackground extends HSLFShape implements Background<HSLFShape,HSLFTextParagraph> {
 
-    protected HSLFBackground(EscherContainerRecord escherRecord, ShapeContainer<HSLFShape> parent) {
+    protected HSLFBackground(EscherContainerRecord escherRecord, ShapeContainer<HSLFShape,HSLFTextParagraph> parent) {
         super(escherRecord, parent);
     }
 
diff --git a/src/scratchpad/src/org/apache/poi/hslf/usermodel/HSLFConnectorShape.java b/src/scratchpad/src/org/apache/poi/hslf/usermodel/HSLFConnectorShape.java
new file mode 100644 (file)
index 0000000..3c26c5a
--- /dev/null
@@ -0,0 +1,65 @@
+/*\r
+ *  ====================================================================\r
+ *    Licensed to the Apache Software Foundation (ASF) under one or more\r
+ *    contributor license agreements.  See the NOTICE file distributed with\r
+ *    this work for additional information regarding copyright ownership.\r
+ *    The ASF licenses this file to You under the Apache License, Version 2.0\r
+ *    (the "License"); you may not use this file except in compliance with\r
+ *    the License.  You may obtain a copy of the License at\r
+ *\r
+ *        http://www.apache.org/licenses/LICENSE-2.0\r
+ *\r
+ *    Unless required by applicable law or agreed to in writing, software\r
+ *    distributed under the License is distributed on an "AS IS" BASIS,\r
+ *    WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\r
+ *    See the License for the specific language governing permissions and\r
+ *    limitations under the License.\r
+ * ====================================================================\r
+ */\r
+\r
+package org.apache.poi.hslf.usermodel;\r
+\r
+import org.apache.poi.ddf.EscherContainerRecord;\r
+import org.apache.poi.sl.usermodel.ConnectorShape;\r
+import org.apache.poi.sl.usermodel.ShapeContainer;\r
+import org.apache.poi.util.Beta;\r
+\r
+/**\r
+ * Specifies a connection shape.\r
+ * \r
+ * This is currently only a dummy implementation.\r
+ */\r
+@Beta\r
+public class HSLFConnectorShape extends HSLFSimpleShape\r
+implements ConnectorShape<HSLFShape,HSLFTextParagraph> {\r
+\r
+    /**\r
+     * Create a ConnectorShape object and initialize it from the supplied Record container.\r
+     *\r
+     * @param escherRecord       <code>EscherSpContainer</code> container which holds information about this shape\r
+     * @param parent    the parent of the shape\r
+     */\r
+   protected HSLFConnectorShape(EscherContainerRecord escherRecord, ShapeContainer<HSLFShape,HSLFTextParagraph> parent){\r
+        super(escherRecord, parent);\r
+\r
+    }\r
+\r
+    /**\r
+     * Create a new ConnectorShape. This constructor is used when a new shape is created.\r
+     *\r
+     * @param parent    the parent of this Shape. For example, if this text box is a cell\r
+     * in a table then the parent is Table.\r
+     */\r
+    public HSLFConnectorShape(ShapeContainer<HSLFShape,HSLFTextParagraph> parent){\r
+        super(null, parent);\r
+        _escherContainer = createSpContainer(parent instanceof HSLFGroupShape);\r
+    }\r
+\r
+    /**\r
+     * Create a new ConnectorShape. This constructor is used when a new shape is created.\r
+     *\r
+     */\r
+    public HSLFConnectorShape(){\r
+        this(null);\r
+    }\r
+}\r
index e0b056714705ad3f9f2f772cc8f7fd1b3203adf1..7940892e7dc893e307e2fb682834590cba3ea792 100644 (file)
@@ -22,9 +22,9 @@ import java.io.ByteArrayInputStream;
 import java.io.InputStream;
 import java.util.List;
 
+import org.apache.poi.ddf.AbstractEscherOptRecord;
 import org.apache.poi.ddf.EscherBSERecord;
 import org.apache.poi.ddf.EscherContainerRecord;
-import org.apache.poi.ddf.EscherOptRecord;
 import org.apache.poi.ddf.EscherProperties;
 import org.apache.poi.ddf.EscherRecord;
 import org.apache.poi.ddf.EscherSimpleProperty;
@@ -155,7 +155,7 @@ public final class HSLFFill {
      * @return type of fill
      */
     public int getFillType(){
-        EscherOptRecord opt = shape.getEscherOptRecord();
+        AbstractEscherOptRecord opt = shape.getEscherOptRecord();
         EscherSimpleProperty prop = HSLFShape.getEscherProperty(opt, EscherProperties.FILL__FILLTYPE);
         return prop == null ? FILL_SOLID : prop.getPropertyValue();
     }
@@ -163,7 +163,7 @@ public final class HSLFFill {
     /**
      */
     protected void afterInsert(HSLFSheet sh){
-        EscherOptRecord opt = shape.getEscherOptRecord();
+        AbstractEscherOptRecord opt = shape.getEscherOptRecord();
         EscherSimpleProperty p = HSLFShape.getEscherProperty(opt, EscherProperties.FILL__PATTERNTEXTURE);
         if(p != null) {
             int idx = p.getPropertyValue();
@@ -197,7 +197,7 @@ public final class HSLFFill {
      * @param type type of the fill
      */
     public void setFillType(int type){
-        EscherOptRecord opt = shape.getEscherOptRecord();
+        AbstractEscherOptRecord opt = shape.getEscherOptRecord();
         HSLFShape.setEscherProperty(opt, EscherProperties.FILL__FILLTYPE, type);
     }
 
@@ -205,7 +205,7 @@ public final class HSLFFill {
      * Foreground color
      */
     public Color getForegroundColor(){
-        EscherOptRecord opt = shape.getEscherOptRecord();
+        AbstractEscherOptRecord opt = shape.getEscherOptRecord();
         EscherSimpleProperty p = HSLFShape.getEscherProperty(opt, EscherProperties.FILL__NOFILLHITTEST);
 
         if(p != null && (p.getPropertyValue() & 0x10) == 0) return null;
@@ -218,7 +218,7 @@ public final class HSLFFill {
      * Foreground color
      */
     public void setForegroundColor(Color color){
-        EscherOptRecord opt = shape.getEscherOptRecord();
+        AbstractEscherOptRecord opt = shape.getEscherOptRecord();
         if (color == null) {
             HSLFShape.setEscherProperty(opt, EscherProperties.FILL__NOFILLHITTEST, 0x150000);
         }
@@ -233,7 +233,7 @@ public final class HSLFFill {
      * Background color
      */
     public Color getBackgroundColor(){
-        EscherOptRecord opt = shape.getEscherOptRecord();
+        AbstractEscherOptRecord opt = shape.getEscherOptRecord();
         EscherSimpleProperty p = HSLFShape.getEscherProperty(opt, EscherProperties.FILL__NOFILLHITTEST);
 
         if(p != null && (p.getPropertyValue() & 0x10) == 0) return null;
@@ -245,7 +245,7 @@ public final class HSLFFill {
      * Background color
      */
     public void setBackgroundColor(Color color){
-        EscherOptRecord opt = shape.getEscherOptRecord();
+        AbstractEscherOptRecord opt = shape.getEscherOptRecord();
         if (color == null) {
             HSLFShape.setEscherProperty(opt, EscherProperties.FILL__FILLBACKCOLOR, -1);
         }
@@ -259,7 +259,7 @@ public final class HSLFFill {
      * <code>PictureData</code> object used in a texture, pattern of picture fill.
      */
     public HSLFPictureData getPictureData(){
-        EscherOptRecord opt = shape.getEscherOptRecord();
+        AbstractEscherOptRecord opt = shape.getEscherOptRecord();
         EscherSimpleProperty p = HSLFShape.getEscherProperty(opt, EscherProperties.FILL__PATTERNTEXTURE);
         if (p == null) return null;
 
@@ -292,7 +292,7 @@ public final class HSLFFill {
      * @param data the picture data added to this ppt by {@link HSLFSlideShow#addPicture(byte[], org.apache.poi.sl.usermodel.PictureData.PictureType)} method.
      */
     public void setPictureData(HSLFPictureData data){
-        EscherOptRecord opt = shape.getEscherOptRecord();
+        AbstractEscherOptRecord opt = shape.getEscherOptRecord();
         HSLFShape.setEscherProperty(opt, (short)(EscherProperties.FILL__PATTERNTEXTURE + 0x4000), (data == null ? 0 : data.getIndex()));
         if(data != null && shape.getSheet() != null) {
             EscherBSERecord bse = getEscherBSERecord(data.getIndex());
index 7a2cd9bdf85aff3bfeadf38fd0ffb4b1607a0deb..e576cceef45181dc390654c809f83b4c27abdbb6 100644 (file)
@@ -26,9 +26,9 @@ import java.util.ArrayList;
 import java.util.Arrays;
 import java.util.List;
 
+import org.apache.poi.ddf.AbstractEscherOptRecord;
 import org.apache.poi.ddf.EscherArrayProperty;
 import org.apache.poi.ddf.EscherContainerRecord;
-import org.apache.poi.ddf.EscherOptRecord;
 import org.apache.poi.ddf.EscherProperties;
 import org.apache.poi.ddf.EscherSimpleProperty;
 import org.apache.poi.sl.usermodel.FreeformShape;
@@ -47,7 +47,7 @@ import org.apache.poi.util.Units;
  * </p>
  * @author Yegor Kozlov
  */
-public final class HSLFFreeformShape extends HSLFAutoShape implements FreeformShape<HSLFTextParagraph> {
+public final class HSLFFreeformShape extends HSLFAutoShape implements FreeformShape<HSLFShape,HSLFTextParagraph> {
 
     public static final byte[] SEGMENTINFO_MOVETO   = new byte[]{0x00, 0x40};
     public static final byte[] SEGMENTINFO_LINETO   = new byte[]{0x00, (byte)0xAC};
@@ -64,7 +64,7 @@ public final class HSLFFreeformShape extends HSLFAutoShape implements FreeformSh
      * @param escherRecord       <code>EscherSpContainer</code> container which holds information about this shape
      * @param parent    the parent of the shape
      */
-   protected HSLFFreeformShape(EscherContainerRecord escherRecord, ShapeContainer<HSLFShape> parent){
+   protected HSLFFreeformShape(EscherContainerRecord escherRecord, ShapeContainer<HSLFShape,HSLFTextParagraph> parent){
         super(escherRecord, parent);
 
     }
@@ -75,7 +75,7 @@ public final class HSLFFreeformShape extends HSLFAutoShape implements FreeformSh
      * @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 HSLFFreeformShape(ShapeContainer<HSLFShape> parent){
+    public HSLFFreeformShape(ShapeContainer<HSLFShape,HSLFTextParagraph> parent){
         super((EscherContainerRecord)null, parent);
         _escherContainer = createSpContainer(ShapeType.NOT_PRIMITIVE, parent instanceof HSLFGroupShape);
     }
@@ -140,7 +140,7 @@ public final class HSLFFreeformShape extends HSLFAutoShape implements FreeformSh
         if(!isClosed) segInfo.add(SEGMENTINFO_LINETO);
         segInfo.add(new byte[]{0x00, (byte)0x80});
 
-        EscherOptRecord opt = getEscherOptRecord();
+        AbstractEscherOptRecord opt = getEscherOptRecord();
         opt.addEscherProperty(new EscherSimpleProperty(EscherProperties.GEOMETRY__SHAPEPATH, 0x4));
 
         EscherArrayProperty verticesProp = new EscherArrayProperty((short)(EscherProperties.GEOMETRY__VERTICES + 0x4000), false, null);
@@ -178,7 +178,7 @@ public final class HSLFFreeformShape extends HSLFAutoShape implements FreeformSh
 
     @Override
     public GeneralPath getPath(){
-        EscherOptRecord opt = getEscherOptRecord();
+        AbstractEscherOptRecord opt = getEscherOptRecord();
         opt.addEscherProperty(new EscherSimpleProperty(EscherProperties.GEOMETRY__SHAPEPATH, 0x4));
 
         EscherArrayProperty verticesProp = getEscherProperty(opt, (short)(EscherProperties.GEOMETRY__VERTICES + 0x4000));
index 41c08fdaa3a2954a3c3b17e696e9b39696e144f0..0ba1d379be4da9910107ee816c242af3b2535012 100644 (file)
 
 package org.apache.poi.hslf.usermodel;
 
+import java.awt.Rectangle;
 import java.awt.geom.Rectangle2D;
-import java.util.*;
-
-import org.apache.poi.ddf.*;
-import org.apache.poi.sl.usermodel.*;
+import java.util.ArrayList;
+import java.util.Iterator;
+import java.util.List;
+
+import org.apache.poi.ddf.EscherChildAnchorRecord;
+import org.apache.poi.ddf.EscherClientAnchorRecord;
+import org.apache.poi.ddf.EscherContainerRecord;
+import org.apache.poi.ddf.EscherRecord;
+import org.apache.poi.ddf.EscherSpRecord;
+import org.apache.poi.ddf.EscherSpgrRecord;
+import org.apache.poi.sl.usermodel.GroupShape;
+import org.apache.poi.sl.usermodel.PictureData;
+import org.apache.poi.sl.usermodel.ShapeContainer;
+import org.apache.poi.sl.usermodel.ShapeType;
 import org.apache.poi.util.LittleEndian;
 import org.apache.poi.util.POILogger;
 import org.apache.poi.util.Units;
@@ -31,7 +42,8 @@ import org.apache.poi.util.Units;
  *
  * @author Yegor Kozlov
  */
-public class HSLFGroupShape extends HSLFShape implements GroupShape<HSLFShape> {
+public class HSLFGroupShape extends HSLFShape
+implements HSLFShapeContainer, GroupShape<HSLFShape,HSLFTextParagraph> {
 
     /**
       * Create a new ShapeGroup. This constructor is used when a new shape is created.
@@ -43,12 +55,22 @@ public class HSLFGroupShape extends HSLFShape implements GroupShape<HSLFShape> {
     }
 
     /**
-      * Create a ShapeGroup object and initilize it from the supplied Record container.
+      * Create a new ShapeGroup. This constructor is used when a new shape is created.
+      *
+      * @param parent    the parent of the shape
+      */
+    public HSLFGroupShape(ShapeContainer<HSLFShape,HSLFTextParagraph> parent){
+        this(null, parent);
+        _escherContainer = createSpContainer(parent instanceof HSLFGroupShape);
+    }
+
+    /**
+      * Create a ShapeGroup object and initialize it from the supplied Record container.
       *
       * @param escherRecord       <code>EscherSpContainer</code> container which holds information about this shape
       * @param parent    the parent of the shape
       */
-    protected HSLFGroupShape(EscherContainerRecord escherRecord, ShapeContainer<HSLFShape> parent){
+    protected HSLFGroupShape(EscherContainerRecord escherRecord, ShapeContainer<HSLFShape,HSLFTextParagraph> parent){
         super(escherRecord, parent);
     }
 
@@ -273,4 +295,68 @@ public class HSLFGroupShape extends HSLFShape implements GroupShape<HSLFShape> {
         return shapeList;
     }
 
+    @Override
+    public HSLFTextBox createTextBox() {
+        HSLFTextBox s = new HSLFTextBox(this);
+        s.setHorizontalCentered(true);
+        s.setAnchor(new Rectangle(0, 0, 100, 100));
+        addShape(s);
+        return s;
+    }
+
+    @Override
+    public HSLFAutoShape createAutoShape() {
+        HSLFAutoShape s = new HSLFAutoShape(ShapeType.RECT, this);
+        s.setHorizontalCentered(true);
+        s.setAnchor(new Rectangle(0, 0, 100, 100));
+        addShape(s);
+        return s;
+    }
+
+    @Override
+    public HSLFFreeformShape createFreeform() {
+        HSLFFreeformShape s = new HSLFFreeformShape(this);
+        s.setHorizontalCentered(true);
+        s.setAnchor(new Rectangle(0, 0, 100, 100));
+        addShape(s);
+        return s;
+    }
+
+    @Override
+    public HSLFConnectorShape createConnector() {
+        HSLFConnectorShape s = new HSLFConnectorShape(this);
+        s.setAnchor(new Rectangle(0, 0, 100, 100));
+        addShape(s);
+        return s;
+    }
+
+    @Override
+    public HSLFGroupShape createGroup() {
+        HSLFGroupShape s = new HSLFGroupShape(this);
+        s.setAnchor(new Rectangle(0, 0, 100, 100));
+        addShape(s);
+        return s;
+    }
+
+    @Override
+    public HSLFPictureShape createPicture(PictureData pictureData) {
+        if (!(pictureData instanceof HSLFPictureData)) {
+            throw new IllegalArgumentException("pictureData needs to be of type HSLFPictureData");
+        }
+        HSLFPictureShape s = new HSLFPictureShape((HSLFPictureData)pictureData, this);
+        s.setAnchor(new Rectangle(0, 0, 100, 100));
+        addShape(s);
+        return s;
+    }
+
+    @Override
+    public HSLFTable createTable(int numRows, int numCols) {
+        if (numRows < 1 || numCols < 1) {
+            throw new IllegalArgumentException("numRows and numCols must be greater than 0");
+        }
+        HSLFTable s = new HSLFTable(numRows,numCols,this);
+        s.setAnchor(new Rectangle(0, 0, 100, 100));
+        addShape(s);
+        return s;
+    }
 }
index 10b2bd099eeea0f6de23454af5664565003be302..21706db40db41203ae5ca047275330bef2b74691 100644 (file)
@@ -17,8 +17,8 @@
 
 package org.apache.poi.hslf.usermodel;
 
+import org.apache.poi.ddf.AbstractEscherOptRecord;
 import org.apache.poi.ddf.EscherContainerRecord;
-import org.apache.poi.ddf.EscherOptRecord;
 import org.apache.poi.ddf.EscherProperties;
 import org.apache.poi.ddf.EscherSpRecord;
 import org.apache.poi.sl.usermodel.Line;
@@ -30,12 +30,12 @@ import org.apache.poi.sl.usermodel.ShapeType;
  *
  *  @author Yegor Kozlov
  */
-public final class HSLFLine extends HSLFTextShape implements Line<HSLFTextParagraph> {
-    public HSLFLine(EscherContainerRecord escherRecord, ShapeContainer<HSLFShape> parent){
+public final class HSLFLine extends HSLFTextShape implements Line<HSLFShape,HSLFTextParagraph> {
+    public HSLFLine(EscherContainerRecord escherRecord, ShapeContainer<HSLFShape,HSLFTextParagraph> parent){
         super(escherRecord, parent);
     }
 
-    public HSLFLine(ShapeContainer<HSLFShape> parent){
+    public HSLFLine(ShapeContainer<HSLFShape,HSLFTextParagraph> parent){
         super(null, parent);
         _escherContainer = createSpContainer(parent instanceof HSLFGroupShape);
     }
@@ -54,7 +54,7 @@ public final class HSLFLine extends HSLFTextShape implements Line<HSLFTextParagr
         spRecord.setOptions(type);
 
         //set default properties for a line
-        EscherOptRecord opt = getEscherOptRecord();
+        AbstractEscherOptRecord opt = getEscherOptRecord();
 
         //default line properties
         setEscherProperty(opt, EscherProperties.GEOMETRY__SHAPEPATH, 4);
index 974a858616ac89fc6f78a70d582845dd2de573df..d73374620d1c5f58533fa204c58a2902dca98759 100644 (file)
@@ -28,7 +28,7 @@ import org.apache.poi.sl.usermodel.MasterSheet;
  *
  * @author Yegor Kozlov
  */
-public abstract class HSLFMasterSheet extends HSLFSheet implements MasterSheet<HSLFShape,HSLFSlideShow> {
+public abstract class HSLFMasterSheet extends HSLFSheet implements MasterSheet<HSLFShape,HSLFTextParagraph> {
     public HSLFMasterSheet(SheetContainer container, int sheetNo){
         super(container, sheetNo);
     }
index 34cb8cf2c3b854ec2815481bc801790ab9fd06e1..50125ea48e898a997612e7c78cab27bd967ddb9b 100644 (file)
@@ -32,7 +32,7 @@ import org.apache.poi.util.POILogger;
  * @author Nick Burch
  */
 
-public final class HSLFNotes extends HSLFSheet implements Notes<HSLFShape, HSLFSlideShow> {
+public final class HSLFNotes extends HSLFSheet implements Notes<HSLFShape,HSLFTextParagraph> {
     protected static final POILogger logger = POILogFactory.getLogger(HSLFNotes.class);
     
     private List<List<HSLFTextParagraph>> _paragraphs = new ArrayList<List<HSLFTextParagraph>>();
index 10e9555c8c6b1978211b26090909dda7f1ebfe69..639545c87ba9daefc8309117a9e11036460ba0b8 100644 (file)
@@ -26,10 +26,10 @@ import java.util.List;
 
 import javax.imageio.ImageIO;
 
+import org.apache.poi.ddf.AbstractEscherOptRecord;
 import org.apache.poi.ddf.EscherBSERecord;
 import org.apache.poi.ddf.EscherComplexProperty;
 import org.apache.poi.ddf.EscherContainerRecord;
-import org.apache.poi.ddf.EscherOptRecord;
 import org.apache.poi.ddf.EscherProperties;
 import org.apache.poi.ddf.EscherRecord;
 import org.apache.poi.ddf.EscherSimpleProperty;
@@ -49,7 +49,7 @@ import org.apache.poi.util.Units;
  *
  * @author Yegor Kozlov
  */
-public class HSLFPictureShape extends HSLFSimpleShape implements PictureShape {
+public class HSLFPictureShape extends HSLFSimpleShape implements PictureShape<HSLFShape,HSLFTextParagraph> {
 
     /**
      * Create a new <code>Picture</code>
@@ -66,7 +66,7 @@ public class HSLFPictureShape extends HSLFSimpleShape implements PictureShape {
      * @param data the picture data
      * @param parent the parent shape
      */
-    public HSLFPictureShape(HSLFPictureData data, ShapeContainer<HSLFShape> parent) {
+    public HSLFPictureShape(HSLFPictureData data, ShapeContainer<HSLFShape,HSLFTextParagraph> parent) {
         super(null, parent);
         _escherContainer = createSpContainer(data.getIndex(), parent instanceof HSLFGroupShape);
     }
@@ -78,7 +78,7 @@ public class HSLFPictureShape extends HSLFSimpleShape implements PictureShape {
       *        this picture in the <code>Slide</code>
       * @param parent the parent shape of this picture
       */
-     protected HSLFPictureShape(EscherContainerRecord escherRecord, ShapeContainer<HSLFShape> parent){
+     protected HSLFPictureShape(EscherContainerRecord escherRecord, ShapeContainer<HSLFShape,HSLFTextParagraph> parent){
         super(escherRecord, parent);
     }
 
@@ -90,7 +90,7 @@ public class HSLFPictureShape extends HSLFSimpleShape implements PictureShape {
      * @return the index to this picture (1 based).
      */
     public int getPictureIndex(){
-        EscherOptRecord opt = getEscherOptRecord();
+        AbstractEscherOptRecord opt = getEscherOptRecord();
         EscherSimpleProperty prop = getEscherProperty(opt, EscherProperties.BLIP__BLIPTODISPLAY);
         return prop == null ? 0 : prop.getPropertyValue();
     }
@@ -109,7 +109,7 @@ public class HSLFPictureShape extends HSLFSimpleShape implements PictureShape {
         spRecord.setOptions((short)((ShapeType.FRAME.nativeId << 4) | 0x2));
 
         //set default properties for a picture
-        EscherOptRecord opt = getEscherOptRecord();
+        AbstractEscherOptRecord opt = getEscherOptRecord();
         setEscherProperty(opt, EscherProperties.PROTECTION__LOCKAGAINSTGROUPING, 0x800080);
 
         //another weird feature of powerpoint: for picture id we must add 0x4000.
@@ -189,7 +189,7 @@ public class HSLFPictureShape extends HSLFSimpleShape implements PictureShape {
      * @return name of this picture
      */
     public String getPictureName(){
-        EscherOptRecord opt = getEscherOptRecord();
+        AbstractEscherOptRecord opt = getEscherOptRecord();
         EscherComplexProperty prop = getEscherProperty(opt, EscherProperties.BLIP__BLIPFILENAME);
         if (prop == null) return null;
         String name = StringUtil.getFromUnicodeLE(prop.getComplexData());
@@ -202,7 +202,7 @@ public class HSLFPictureShape extends HSLFSimpleShape implements PictureShape {
      * @param name of this picture
      */
     public void setPictureName(String name){
-        EscherOptRecord opt = getEscherOptRecord();
+        AbstractEscherOptRecord opt = getEscherOptRecord();
         byte[] data = StringUtil.getToUnicodeLE(name + '\u0000');
         EscherComplexProperty prop = new EscherComplexProperty(EscherProperties.BLIP__BLIPFILENAME, false, data);
         opt.addEscherProperty(prop);
@@ -228,7 +228,7 @@ public class HSLFPictureShape extends HSLFSimpleShape implements PictureShape {
     public Insets getClipping() {
         // The anchor specified by the escher properties is the displayed size,
         // i.e. the size of the already clipped image
-        EscherOptRecord opt = getEscherOptRecord();
+        AbstractEscherOptRecord opt = getEscherOptRecord();
         
         double top    = getFractProp(opt, EscherProperties.BLIP__CROPFROMTOP);
         double bottom = getFractProp(opt, EscherProperties.BLIP__CROPFROMBOTTOM);
@@ -244,7 +244,7 @@ public class HSLFPictureShape extends HSLFSimpleShape implements PictureShape {
     /**
      * @return the fractional property or 0 if not defined
      */
-    private static double getFractProp(EscherOptRecord opt, short propertyId) {
+    private static double getFractProp(AbstractEscherOptRecord opt, short propertyId) {
         EscherSimpleProperty prop = getEscherProperty(opt, propertyId);
         if (prop == null) return 0;
         int fixedPoint = prop.getPropertyValue();
index 635402319c1a8edbe6d13896201a22ab81daf47f..2af2678b20815ce1324b302aa4235ae0959d1900 100644 (file)
@@ -44,7 +44,7 @@ import org.apache.poi.util.*;
   *
   * @author Yegor Kozlov
  */
-public abstract class HSLFShape implements Shape {
+public abstract class HSLFShape implements Shape<HSLFShape,HSLFTextParagraph> {
 
     // For logging
     protected POILogger logger = POILogFactory.getLogger(this.getClass());
@@ -59,7 +59,7 @@ public abstract class HSLFShape implements Shape {
      * Parent of this shape.
      * <code>null</code> for the topmost shapes.
      */
-    protected ShapeContainer<HSLFShape> _parent;
+    protected ShapeContainer<HSLFShape,HSLFTextParagraph> _parent;
 
     /**
      * The <code>Sheet</code> this shape belongs to
@@ -77,7 +77,7 @@ public abstract class HSLFShape implements Shape {
      * @param escherRecord       <code>EscherSpContainer</code> container which holds information about this shape
      * @param parent             the parent of this Shape
      */
-      protected HSLFShape(EscherContainerRecord escherRecord, ShapeContainer<HSLFShape> parent){
+      protected HSLFShape(EscherContainerRecord escherRecord, ShapeContainer<HSLFShape,HSLFTextParagraph> parent){
         _escherContainer = escherRecord;
         _parent = parent;
      }
@@ -90,7 +90,7 @@ public abstract class HSLFShape implements Shape {
     /**
      *  @return the parent of this shape
      */
-    public ShapeContainer<HSLFShape> getParent(){
+    public ShapeContainer<HSLFShape,HSLFTextParagraph> getParent(){
         return _parent;
     }
 
@@ -229,7 +229,7 @@ public abstract class HSLFShape implements Shape {
      *
      * @return escher property or <code>null</code> if not found.
      */
-     public static <T extends EscherProperty> T getEscherProperty(EscherOptRecord opt, int propId){
+     public static <T extends EscherProperty> T getEscherProperty(AbstractEscherOptRecord opt, int propId){
          if (opt == null) return null;
          return opt.lookup(propId);
      }
@@ -241,7 +241,7 @@ public abstract class HSLFShape implements Shape {
      * @param propId    The id of the property. One of the constants defined in EscherOptRecord.
      * @param value     value of the property. If value = -1 then the property is removed.
      */
-     public static void setEscherProperty(EscherOptRecord opt, short propId, int value){
+     public static void setEscherProperty(AbstractEscherOptRecord opt, short propId, int value){
         java.util.List<EscherProperty> props = opt.getEscherProperties();
         for ( Iterator<EscherProperty> iterator = props.iterator(); iterator.hasNext(); ) {
             if (iterator.next().getPropertyNumber() == propId){
@@ -262,7 +262,7 @@ public abstract class HSLFShape implements Shape {
      * @param value     value of the property. If value = -1 then the property is removed.
      */
     public void setEscherProperty(short propId, int value){
-        EscherOptRecord opt = getEscherOptRecord();
+        AbstractEscherOptRecord opt = getEscherOptRecord();
         setEscherProperty(opt, propId, value);
     }
 
@@ -272,7 +272,7 @@ public abstract class HSLFShape implements Shape {
      * @param propId    The id of the property. One of the constants defined in EscherOptRecord.
      */
    public int getEscherProperty(short propId){
-        EscherOptRecord opt = getEscherOptRecord();
+       AbstractEscherOptRecord opt = getEscherOptRecord();
         EscherSimpleProperty prop = getEscherProperty(opt, propId);
         return prop == null ? 0 : prop.getPropertyValue();
     }
@@ -283,7 +283,7 @@ public abstract class HSLFShape implements Shape {
      * @param propId    The id of the property. One of the constants defined in EscherOptRecord.
      */
    public int getEscherProperty(short propId, int defaultValue){
-        EscherOptRecord opt = getEscherOptRecord();
+       AbstractEscherOptRecord opt = getEscherOptRecord();
         EscherSimpleProperty prop = getEscherProperty(opt, propId);
         return prop == null ? defaultValue : prop.getPropertyValue();
     }
@@ -327,7 +327,7 @@ public abstract class HSLFShape implements Shape {
     }
 
     Color getColor(short colorProperty, short opacityProperty, int defaultColor){
-        EscherOptRecord opt = getEscherOptRecord();
+        AbstractEscherOptRecord opt = getEscherOptRecord();
         EscherSimpleProperty p = getEscherProperty(opt, colorProperty);
         if(p == null && defaultColor == -1) return null;
 
@@ -367,7 +367,7 @@ public abstract class HSLFShape implements Shape {
     }
 
     double getAlpha(short opacityProperty) {
-        EscherOptRecord opt = getEscherOptRecord();
+        AbstractEscherOptRecord opt = getEscherOptRecord();
         EscherSimpleProperty op = getEscherProperty(opt, opacityProperty);
         int defaultOpacity = 0x00010000;
         int opacity = (op == null) ? defaultOpacity : op.getPropertyValue();
@@ -444,8 +444,8 @@ public abstract class HSLFShape implements Shape {
         logger.log(POILogger.INFO, "Rendering " + getShapeName());
     }
 
-    public EscherOptRecord getEscherOptRecord() {
-        EscherOptRecord opt = getEscherChild(EscherOptRecord.RECORD_ID);
+    public AbstractEscherOptRecord getEscherOptRecord() {
+        AbstractEscherOptRecord opt = getEscherChild(EscherOptRecord.RECORD_ID);
         if (opt == null) {
             opt = getEscherChild(RecordTypes.EscherUserDefined);
         }
diff --git a/src/scratchpad/src/org/apache/poi/hslf/usermodel/HSLFShapeContainer.java b/src/scratchpad/src/org/apache/poi/hslf/usermodel/HSLFShapeContainer.java
new file mode 100644 (file)
index 0000000..c09e2d6
--- /dev/null
@@ -0,0 +1,49 @@
+/*\r
+ *  ====================================================================\r
+ *    Licensed to the Apache Software Foundation (ASF) under one or more\r
+ *    contributor license agreements.  See the NOTICE file distributed with\r
+ *    this work for additional information regarding copyright ownership.\r
+ *    The ASF licenses this file to You under the Apache License, Version 2.0\r
+ *    (the "License"); you may not use this file except in compliance with\r
+ *    the License.  You may obtain a copy of the License at\r
+ *\r
+ *        http://www.apache.org/licenses/LICENSE-2.0\r
+ *\r
+ *    Unless required by applicable law or agreed to in writing, software\r
+ *    distributed under the License is distributed on an "AS IS" BASIS,\r
+ *    WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\r
+ *    See the License for the specific language governing permissions and\r
+ *    limitations under the License.\r
+ * ====================================================================\r
+ */\r
+\r
+package org.apache.poi.hslf.usermodel;\r
+\r
+import org.apache.poi.sl.usermodel.PictureData;\r
+import org.apache.poi.sl.usermodel.ShapeContainer;\r
+\r
+/**\r
+ * Common interface for shape containers, e.g. sheets or groups of shapes\r
+ */\r
+public interface HSLFShapeContainer extends ShapeContainer<HSLFShape,HSLFTextParagraph> {\r
+\r
+    @Override\r
+    HSLFAutoShape createAutoShape();\r
+\r
+    @Override\r
+    HSLFFreeformShape createFreeform();\r
+\r
+    @Override\r
+    HSLFTextBox createTextBox();\r
+\r
+    @Override\r
+    HSLFConnectorShape createConnector();\r
+\r
+    @Override\r
+    HSLFGroupShape createGroup();\r
+\r
+    @Override\r
+    HSLFPictureShape createPicture(PictureData pictureData);\r
+\r
+\r
+}\r
index 08db124d4c1e800408605228eabf0da1f5ad9590..f2aac4da252274b9ae3472744f1a812128d89429 100644 (file)
@@ -40,38 +40,39 @@ public final class HSLFShapeFactory {
     /**
      * Create a new shape from the data provided.
      */
-    public static HSLFShape createShape(EscherContainerRecord spContainer, ShapeContainer<HSLFShape> parent){
+    public static HSLFShape createShape(EscherContainerRecord spContainer, ShapeContainer<HSLFShape,HSLFTextParagraph> parent){
         if (spContainer.getRecordId() == EscherContainerRecord.SPGR_CONTAINER){
             return createShapeGroup(spContainer, parent);
         }
         return createSimpleShape(spContainer, parent);
     }
 
-    public static HSLFGroupShape createShapeGroup(EscherContainerRecord spContainer, ShapeContainer<HSLFShape> parent){
-        HSLFGroupShape group = null;
-        EscherRecord opt = HSLFShape.getEscherChild((EscherContainerRecord)spContainer.getChild(0), (short)0xF122);
-        if(opt != null){
-            try {
-                EscherPropertyFactory f = new EscherPropertyFactory();
-                List<EscherProperty> props = f.createProperties( opt.serialize(), 8, opt.getInstance() );
-                EscherSimpleProperty p = (EscherSimpleProperty)props.get(0);
-                if(p.getPropertyNumber() == 0x39F && p.getPropertyValue() == 1){
-                    group = new HSLFTable(spContainer, parent);
-                } else {
-                    group = new HSLFGroupShape(spContainer, parent);
+    public static HSLFGroupShape createShapeGroup(EscherContainerRecord spContainer, ShapeContainer<HSLFShape,HSLFTextParagraph> parent){
+        boolean isTable = false;
+        EscherContainerRecord ecr = (EscherContainerRecord)spContainer.getChild(0);
+        EscherRecord opt = HSLFShape.getEscherChild(ecr, (short)RecordTypes.EscherUserDefined);
+
+        if (opt != null) {
+            EscherPropertyFactory f = new EscherPropertyFactory();
+            List<EscherProperty> props = f.createProperties( opt.serialize(), 8, opt.getInstance() );
+            for (EscherProperty ep : props) {
+                if (ep.getPropertyNumber() == 0x39F
+                    && ep instanceof EscherSimpleProperty
+                    && ((EscherSimpleProperty)ep).getPropertyValue() == 1) {
+                    isTable = true;
+                    break;
                 }
-            } catch (Exception e){
-                logger.log(POILogger.WARN, e.getMessage());
-                group = new HSLFGroupShape(spContainer, parent);
             }
-        }  else {
-            group = new HSLFGroupShape(spContainer, parent);
         }
-
+        
+        HSLFGroupShape group = (isTable)
+            ? new HSLFTable(spContainer, parent)
+            : new HSLFGroupShape(spContainer, parent);
+        
         return group;
      }
 
-    public static HSLFShape createSimpleShape(EscherContainerRecord spContainer, ShapeContainer<HSLFShape> parent){
+    public static HSLFShape createSimpleShape(EscherContainerRecord spContainer, ShapeContainer<HSLFShape,HSLFTextParagraph> parent){
         HSLFShape shape = null;
         EscherSpRecord spRecord = spContainer.getChildById(EscherSpRecord.RECORD_ID);
 
@@ -106,7 +107,7 @@ public final class HSLFShapeFactory {
                 shape = new HSLFLine(spContainer, parent);
                 break;
             case NOT_PRIMITIVE: {
-                EscherOptRecord opt = HSLFShape.getEscherChild(spContainer, EscherOptRecord.RECORD_ID);
+                AbstractEscherOptRecord opt = HSLFShape.getEscherChild(spContainer, EscherOptRecord.RECORD_ID);
                 EscherProperty prop = HSLFShape.getEscherProperty(opt, EscherProperties.GEOMETRY__VERTICES);
                 if(prop != null)
                     shape = new HSLFFreeformShape(spContainer, parent);
index d0c594fd819cceb585b8da635d012c107966ab91..419ded3a150b3f06bc17b679bd8473fc8ce95df4 100644 (file)
 package org.apache.poi.hslf.usermodel;
 
 import java.awt.Graphics2D;
-import java.util.*;
-
-import org.apache.poi.ddf.*;
-import org.apache.poi.hslf.record.*;
+import java.awt.Rectangle;
+import java.util.ArrayList;
+import java.util.Iterator;
+import java.util.List;
+
+import org.apache.poi.ddf.EscherContainerRecord;
+import org.apache.poi.ddf.EscherDgRecord;
+import org.apache.poi.ddf.EscherDggRecord;
+import org.apache.poi.ddf.EscherRecord;
+import org.apache.poi.hslf.record.CString;
+import org.apache.poi.hslf.record.ColorSchemeAtom;
+import org.apache.poi.hslf.record.OEPlaceholderAtom;
+import org.apache.poi.hslf.record.PPDrawing;
+import org.apache.poi.hslf.record.RecordContainer;
+import org.apache.poi.hslf.record.RecordTypes;
+import org.apache.poi.hslf.record.RoundTripHFPlaceholder12;
+import org.apache.poi.hslf.record.SheetContainer;
 import org.apache.poi.sl.draw.DrawFactory;
 import org.apache.poi.sl.draw.Drawable;
+import org.apache.poi.sl.usermodel.PictureData;
+import org.apache.poi.sl.usermodel.ShapeType;
 import org.apache.poi.sl.usermodel.Sheet;
-import org.apache.poi.util.POILogFactory;
-import org.apache.poi.util.POILogger;
 
 /**
  * This class defines the common format of "Sheets" in a powerpoint
@@ -36,9 +49,7 @@ import org.apache.poi.util.POILogger;
  * @author Yegor Kozlov
  */
 
-public abstract class HSLFSheet implements Sheet<HSLFShape,HSLFSlideShow> {
-       private static POILogger logger = POILogFactory.getLogger(HSLFSheet.class);
-
+public abstract class HSLFSheet implements HSLFShapeContainer, Sheet<HSLFShape,HSLFTextParagraph> {
     /**
      * The <code>SlideShow</code> we belong to
      */
@@ -387,4 +398,68 @@ public abstract class HSLFSheet implements Sheet<HSLFShape,HSLFSlideShow> {
     }
 
 
+    @Override
+    public HSLFTextBox createTextBox() {
+        HSLFTextBox s = new HSLFTextBox();
+        s.setHorizontalCentered(true);
+        s.setAnchor(new Rectangle(0, 0, 100, 100));
+        addShape(s);
+        return s;
+    }
+
+    @Override
+    public HSLFAutoShape createAutoShape() {
+        HSLFAutoShape s = new HSLFAutoShape(ShapeType.RECT);
+        s.setHorizontalCentered(true);
+        s.setAnchor(new Rectangle(0, 0, 100, 100));
+        addShape(s);
+        return s;
+    }
+
+    @Override
+    public HSLFFreeformShape createFreeform() {
+        HSLFFreeformShape s = new HSLFFreeformShape();
+        s.setHorizontalCentered(true);
+        s.setAnchor(new Rectangle(0, 0, 100, 100));
+        addShape(s);
+        return s;
+    }
+
+    @Override
+    public HSLFConnectorShape createConnector() {
+        HSLFConnectorShape s = new HSLFConnectorShape();
+        s.setAnchor(new Rectangle(0, 0, 100, 100));
+        addShape(s);
+        return s;
+    }
+
+    @Override
+    public HSLFGroupShape createGroup() {
+        HSLFGroupShape s = new HSLFGroupShape();
+        s.setAnchor(new Rectangle(0, 0, 100, 100));
+        addShape(s);
+        return s;
+    }
+
+    @Override
+    public HSLFPictureShape createPicture(PictureData pictureData) {
+        if (!(pictureData instanceof HSLFPictureData)) {
+            throw new IllegalArgumentException("pictureData needs to be of type HSLFPictureData");
+        }
+        HSLFPictureShape s = new HSLFPictureShape((HSLFPictureData)pictureData);
+        s.setAnchor(new Rectangle(0, 0, 100, 100));
+        addShape(s);
+        return s;
+    }
+
+    @Override
+    public HSLFTable createTable(int numRows, int numCols) {
+        if (numRows < 1 || numCols < 1) {
+            throw new IllegalArgumentException("numRows and numCols must be greater than 0");
+        }
+        HSLFTable s = new HSLFTable(numRows,numCols);
+        s.setAnchor(new Rectangle(0, 0, 100, 100));
+        addShape(s);
+        return s;
+    }
 }
index c6feb514e1398587990411ecbd496a1d64ef9261..aeb36beb56316c0e4b00a2ec871e956a1e72d911 100644 (file)
@@ -39,7 +39,7 @@ import org.apache.poi.util.Units;
  *
  *  @author Yegor Kozlov
  */
-public abstract class HSLFSimpleShape extends HSLFShape implements SimpleShape {
+public abstract class HSLFSimpleShape extends HSLFShape implements SimpleShape<HSLFShape,HSLFTextParagraph> {
 
     public final static double DEFAULT_LINE_WIDTH = 0.75;
 
@@ -55,7 +55,7 @@ public abstract class HSLFSimpleShape extends HSLFShape implements SimpleShape {
      * @param escherRecord    <code>EscherSpContainer</code> container which holds information about this shape
      * @param parent    the parent of the shape
      */
-    protected HSLFSimpleShape(EscherContainerRecord escherRecord, ShapeContainer<HSLFShape> parent){
+    protected HSLFSimpleShape(EscherContainerRecord escherRecord, ShapeContainer<HSLFShape,HSLFTextParagraph> parent){
         super(escherRecord, parent);
     }
 
@@ -76,7 +76,7 @@ public abstract class HSLFSimpleShape extends HSLFShape implements SimpleShape {
         sp.setFlags(flags);
         _escherContainer.addChildRecord(sp);
 
-        EscherOptRecord opt = new EscherOptRecord();
+        AbstractEscherOptRecord opt = new EscherOptRecord();
         opt.setRecordId(EscherOptRecord.RECORD_ID);
         _escherContainer.addChildRecord(opt);
 
@@ -102,7 +102,7 @@ public abstract class HSLFSimpleShape extends HSLFShape implements SimpleShape {
      *  Returns width of the line in in points
      */
     public double getLineWidth(){
-        EscherOptRecord opt = getEscherOptRecord();
+        AbstractEscherOptRecord opt = getEscherOptRecord();
         EscherSimpleProperty prop = getEscherProperty(opt, EscherProperties.LINESTYLE__LINEWIDTH);
         double width = (prop == null) ? DEFAULT_LINE_WIDTH : Units.toPoints(prop.getPropertyValue());
         return width;
@@ -113,7 +113,7 @@ public abstract class HSLFSimpleShape extends HSLFShape implements SimpleShape {
      *  @param width  the width of line in in points
      */
     public void setLineWidth(double width){
-        EscherOptRecord opt = getEscherOptRecord();
+        AbstractEscherOptRecord opt = getEscherOptRecord();
         setEscherProperty(opt, EscherProperties.LINESTYLE__LINEWIDTH, Units.toEMU(width));
     }
 
@@ -123,7 +123,7 @@ public abstract class HSLFSimpleShape extends HSLFShape implements SimpleShape {
      * @param color new color of the line
      */
     public void setLineColor(Color color){
-        EscherOptRecord opt = getEscherOptRecord();
+        AbstractEscherOptRecord opt = getEscherOptRecord();
         if (color == null) {
             setEscherProperty(opt, EscherProperties.LINESTYLE__NOLINEDRAWDASH, 0x80000);
         } else {
@@ -137,7 +137,7 @@ public abstract class HSLFSimpleShape extends HSLFShape implements SimpleShape {
      * @return color of the line. If color is not set returns <code>java.awt.Color.black</code>
      */
     public Color getLineColor(){
-        EscherOptRecord opt = getEscherOptRecord();
+        AbstractEscherOptRecord opt = getEscherOptRecord();
 
         EscherSimpleProperty p = getEscherProperty(opt, EscherProperties.LINESTYLE__NOLINEDRAWDASH);
         if(p != null && (p.getPropertyValue() & 0x8) == 0) return null;
@@ -152,7 +152,7 @@ public abstract class HSLFSimpleShape extends HSLFShape implements SimpleShape {
      * @return dashing of the line.
      */
     public LineDash getLineDashing(){
-        EscherOptRecord opt = getEscherOptRecord();
+        AbstractEscherOptRecord opt = getEscherOptRecord();
         EscherSimpleProperty prop = getEscherProperty(opt, EscherProperties.LINESTYLE__LINEDASHING);
         return (prop == null) ? LineDash.SOLID : LineDash.fromNativeId(prop.getPropertyValue());
     }
@@ -163,7 +163,7 @@ public abstract class HSLFSimpleShape extends HSLFShape implements SimpleShape {
      * @param pen new style of the line.
      */
     public void setLineDashing(LineDash pen){
-        EscherOptRecord opt = getEscherOptRecord();
+        AbstractEscherOptRecord opt = getEscherOptRecord();
         setEscherProperty(opt, EscherProperties.LINESTYLE__LINEDASHING, pen == LineDash.SOLID ? -1 : pen.nativeId);
     }
 
@@ -173,7 +173,7 @@ public abstract class HSLFSimpleShape extends HSLFShape implements SimpleShape {
      * @return the compound style of the line.
      */
     public LineCompound getLineCompound() {
-        EscherOptRecord opt = getEscherOptRecord();
+        AbstractEscherOptRecord opt = getEscherOptRecord();
         EscherSimpleProperty prop = getEscherProperty(opt, EscherProperties.LINESTYLE__LINESTYLE);
         return (prop == null) ? LineCompound.SINGLE : LineCompound.fromNativeId(prop.getPropertyValue());
     }
@@ -184,7 +184,7 @@ public abstract class HSLFSimpleShape extends HSLFShape implements SimpleShape {
      * @param style new compound style of the line.
      */
     public void setLineCompound(LineCompound style){
-        EscherOptRecord opt = getEscherOptRecord();
+        AbstractEscherOptRecord opt = getEscherOptRecord();
         setEscherProperty(opt, EscherProperties.LINESTYLE__LINESTYLE, style == LineCompound.SINGLE ? -1 : style.nativeId);
     }
 
@@ -389,7 +389,7 @@ public abstract class HSLFSimpleShape extends HSLFShape implements SimpleShape {
 
 
     public double getShadowAngle() {
-        EscherOptRecord opt = getEscherOptRecord();
+        AbstractEscherOptRecord opt = getEscherOptRecord();
         EscherSimpleProperty prop = getEscherProperty(opt, EscherProperties.SHADOWSTYLE__OFFSETX);
         int offX = (prop == null) ? 0 : prop.getPropertyValue();
         prop = getEscherProperty(opt, EscherProperties.SHADOWSTYLE__OFFSETY);
@@ -398,7 +398,7 @@ public abstract class HSLFSimpleShape extends HSLFShape implements SimpleShape {
     }
     
     public double getShadowDistance() {
-        EscherOptRecord opt = getEscherOptRecord();
+        AbstractEscherOptRecord opt = getEscherOptRecord();
         EscherSimpleProperty prop = getEscherProperty(opt, EscherProperties.SHADOWSTYLE__OFFSETX);
         int offX = (prop == null) ? 0 : prop.getPropertyValue();
         prop = getEscherProperty(opt, EscherProperties.SHADOWSTYLE__OFFSETY);
@@ -415,12 +415,12 @@ public abstract class HSLFSimpleShape extends HSLFShape implements SimpleShape {
     }    
     
     public Shadow getShadow() {
-        EscherOptRecord opt = getEscherOptRecord();
+        AbstractEscherOptRecord opt = getEscherOptRecord();
         EscherProperty shadowType = opt.lookup(EscherProperties.SHADOWSTYLE__TYPE);
         if (shadowType == null) return null;
         
         return new Shadow(){
-            public SimpleShape getShadowParent() {
+            public SimpleShape<HSLFShape,HSLFTextParagraph> getShadowParent() {
                 return HSLFSimpleShape.this;
             }
 
index bbffdc5e1b177244bbdbbf57ad7eedafcff64090..fad85f46a186ed55534585a4aca227358f720412 100644 (file)
@@ -21,12 +21,28 @@ import java.awt.Graphics2D;
 import java.util.ArrayList;
 import java.util.List;
 
-import org.apache.poi.ddf.*;
-import org.apache.poi.hslf.model.*;
-import org.apache.poi.hslf.record.*;
+import org.apache.poi.ddf.EscherContainerRecord;
+import org.apache.poi.ddf.EscherDgRecord;
+import org.apache.poi.ddf.EscherDggRecord;
+import org.apache.poi.ddf.EscherSpRecord;
+import org.apache.poi.hslf.model.Comment;
+import org.apache.poi.hslf.model.HeadersFooters;
+import org.apache.poi.hslf.model.Placeholder;
+import org.apache.poi.hslf.record.ColorSchemeAtom;
+import org.apache.poi.hslf.record.Comment2000;
+import org.apache.poi.hslf.record.EscherTextboxWrapper;
+import org.apache.poi.hslf.record.HeadersFootersContainer;
+import org.apache.poi.hslf.record.Record;
+import org.apache.poi.hslf.record.RecordContainer;
+import org.apache.poi.hslf.record.RecordTypes;
+import org.apache.poi.hslf.record.SSSlideInfoAtom;
+import org.apache.poi.hslf.record.SlideAtom;
 import org.apache.poi.hslf.record.SlideListWithText.SlideAtomsSet;
+import org.apache.poi.hslf.record.StyleTextProp9Atom;
+import org.apache.poi.hslf.record.TextHeaderAtom;
 import org.apache.poi.sl.draw.DrawFactory;
 import org.apache.poi.sl.draw.Drawable;
+import org.apache.poi.sl.usermodel.Notes;
 import org.apache.poi.sl.usermodel.ShapeType;
 import org.apache.poi.sl.usermodel.Slide;
 
@@ -39,7 +55,7 @@ import org.apache.poi.sl.usermodel.Slide;
  * @author Yegor Kozlov
  */
 
-public final class HSLFSlide extends HSLFSheet implements Slide<HSLFShape,HSLFSlideShow,HSLFNotes> {
+public final class HSLFSlide extends HSLFSheet implements Slide<HSLFShape,HSLFTextParagraph> {
        private int _slideNo;
        private SlideAtomsSet _atomSet;
        private final List<List<HSLFTextParagraph>> _paragraphs = new ArrayList<List<HSLFTextParagraph>>();
@@ -110,8 +126,11 @@ public final class HSLFSlide extends HSLFSheet implements Slide<HSLFShape,HSLFSl
         *  references in the records to point to the new ID
         */
        @Override
-       public void setNotes(HSLFNotes notes) {
-               _notes = notes;
+       public void setNotes(Notes<HSLFShape,HSLFTextParagraph> notes) {
+        if (notes != null && !(notes instanceof HSLFNotes)) {
+            throw new IllegalArgumentException("notes needs to be of type HSLFNotes");
+        }
+               _notes = (HSLFNotes)notes;
 
                // Update the Slide Atom's ID of where to point to
                SlideAtom sa = getSlideRecord().getSlideAtom();
index 4af64ecb4cf99955f3987ba804e5bda6c4b7eecf..fd31be4365eab3ca4ede80a0f75fc72de32dbd7f 100644 (file)
@@ -48,7 +48,6 @@ import org.apache.poi.poifs.filesystem.POIFSFileSystem;
 import org.apache.poi.sl.usermodel.MasterSheet;
 import org.apache.poi.sl.usermodel.PictureData.PictureType;
 import org.apache.poi.sl.usermodel.Resources;
-import org.apache.poi.sl.usermodel.Shape;
 import org.apache.poi.sl.usermodel.SlideShow;
 import org.apache.poi.util.POILogFactory;
 import org.apache.poi.util.POILogger;
@@ -63,7 +62,7 @@ import org.apache.poi.util.Units;
  * @author Nick Burch
  * @author Yegor kozlov
  */
-public final class HSLFSlideShow implements SlideShow {
+public final class HSLFSlideShow implements SlideShow<HSLFShape,HSLFTextParagraph> {
        // What we're based on
        private HSLFSlideShowImpl _hslfSlideShow;
 
@@ -671,6 +670,7 @@ public final class HSLFSlideShow implements SlideShow {
         *
         * @return the created <code>Slide</code>
         */
+       @Override
        public HSLFSlide createSlide() {
                SlideListWithText slist = null;
 
@@ -1131,8 +1131,7 @@ public final class HSLFSlideShow implements SlideShow {
                return psrId;
     }
 
-    public MasterSheet<? extends Shape, ? extends SlideShow> createMasterSheet()
-            throws IOException {
+    public MasterSheet<HSLFShape,HSLFTextParagraph> createMasterSheet() throws IOException {
         // TODO Auto-generated method stub
         return null;
     }
index 9e7ff158e72b1d37fefea884300b7a3bcd5ca055..2f785c433bfb8a87edc149c06076b35b434e77b0 100644 (file)
@@ -24,6 +24,7 @@ import java.util.Comparator;
 import java.util.Iterator;
 import java.util.List;
 
+import org.apache.poi.ddf.AbstractEscherOptRecord;
 import org.apache.poi.ddf.EscherArrayProperty;
 import org.apache.poi.ddf.EscherContainerRecord;
 import org.apache.poi.ddf.EscherOptRecord;
@@ -31,6 +32,7 @@ import org.apache.poi.ddf.EscherProperties;
 import org.apache.poi.ddf.EscherRecord;
 import org.apache.poi.ddf.EscherSimpleProperty;
 import org.apache.poi.ddf.EscherTextboxRecord;
+import org.apache.poi.hslf.record.RecordTypes;
 import org.apache.poi.sl.usermodel.ShapeContainer;
 import org.apache.poi.sl.usermodel.TableShape;
 import org.apache.poi.util.LittleEndian;
@@ -41,7 +43,8 @@ import org.apache.poi.util.Units;
  *
  * @author Yegor Kozlov
  */
-public final class HSLFTable extends HSLFGroupShape implements TableShape {
+public final class HSLFTable extends HSLFGroupShape
+implements HSLFShapeContainer, TableShape<HSLFShape,HSLFTextParagraph> {
 
     protected static final int BORDER_TOP = 1;
     protected static final int BORDER_RIGHT = 2;
@@ -59,17 +62,28 @@ public final class HSLFTable extends HSLFGroupShape implements TableShape {
     /**
      * Create a new Table of the given number of rows and columns
      *
-     * @param numrows the number of rows
-     * @param numcols the number of columns
+     * @param numRows the number of rows
+     * @param numCols the number of columns
      */
-    public HSLFTable(int numrows, int numcols) {
-        super();
+    public HSLFTable(int numRows, int numCols) {
+        this(numRows, numCols, null);
+    }
+    
+    /**
+     * Create a new Table of the given number of rows and columns
+     *
+     * @param numRows the number of rows
+     * @param numCols the number of columns
+     * @param parent the parent shape, or null if table is added to sheet
+     */
+    public HSLFTable(int numRows, int numCols, ShapeContainer<HSLFShape,HSLFTextParagraph> parent) {
+        super(parent);
 
-        if(numrows < 1) throw new IllegalArgumentException("The number of rows must be greater than 1");
-        if(numcols < 1) throw new IllegalArgumentException("The number of columns must be greater than 1");
+        if(numRows < 1) throw new IllegalArgumentException("The number of rows must be greater than 1");
+        if(numCols < 1) throw new IllegalArgumentException("The number of columns must be greater than 1");
 
         int x=0, y=0, tblWidth=0, tblHeight=0;
-        cells = new HSLFTableCell[numrows][numcols];
+        cells = new HSLFTableCell[numRows][numCols];
         for (int i = 0; i < cells.length; i++) {
             x = 0;
             for (int j = 0; j < cells[i].length; j++) {
@@ -85,17 +99,15 @@ public final class HSLFTable extends HSLFGroupShape implements TableShape {
         setAnchor(new Rectangle(0, 0, tblWidth, tblHeight));
 
         EscherContainerRecord spCont = (EscherContainerRecord) getSpContainer().getChild(0);
-        EscherOptRecord opt = new EscherOptRecord();
-        opt.setRecordId((short)0xF122);
+        AbstractEscherOptRecord opt = new EscherOptRecord();
+        opt.setRecordId((short)RecordTypes.EscherUserDefined);
         opt.addEscherProperty(new EscherSimpleProperty((short)0x39F, 1));
         EscherArrayProperty p = new EscherArrayProperty((short)(0x4000 | 0x3A0), false, null);
         p.setSizeOfElements(0x0004);
-        p.setNumberOfElementsInArray(numrows);
-        p.setNumberOfElementsInMemory(numrows);
+        p.setNumberOfElementsInArray(numRows);
+        p.setNumberOfElementsInMemory(numRows);
         opt.addEscherProperty(p);
-        List<EscherRecord> lst = spCont.getChildRecords();
-        lst.add(lst.size()-1, opt);
-        spCont.setChildRecords(lst);
+        spCont.addChildBefore(opt, RecordTypes.EscherClientAnchor);
     }
 
     /**
@@ -104,7 +116,7 @@ public final class HSLFTable extends HSLFGroupShape implements TableShape {
      * @param escherRecord <code>EscherSpContainer</code> container which holds information about this shape
      * @param parent       the parent of the shape
      */
-    public HSLFTable(EscherContainerRecord escherRecord, ShapeContainer<HSLFShape> parent) {
+    public HSLFTable(EscherContainerRecord escherRecord, ShapeContainer<HSLFShape,HSLFTextParagraph> parent) {
         super(escherRecord, parent);
     }
 
@@ -131,7 +143,7 @@ public final class HSLFTable extends HSLFGroupShape implements TableShape {
 
         EscherContainerRecord spCont = (EscherContainerRecord) getSpContainer().getChild(0);
         List<EscherRecord> lst = spCont.getChildRecords();
-        EscherOptRecord opt = (EscherOptRecord)lst.get(lst.size()-2);
+        AbstractEscherOptRecord opt = (AbstractEscherOptRecord)lst.get(lst.size()-2);
         EscherArrayProperty p = opt.lookup(0x3A0); 
         for (int i = 0; i < cells.length; i++) {
             HSLFTableCell cell = cells[i][0];
@@ -359,7 +371,7 @@ public final class HSLFTable extends HSLFGroupShape implements TableShape {
     public HSLFLine createBorder(){
         HSLFLine line = new HSLFLine(this);
 
-        EscherOptRecord opt = getEscherOptRecord();
+        AbstractEscherOptRecord opt = getEscherOptRecord();
         setEscherProperty(opt, EscherProperties.GEOMETRY__SHAPEPATH, -1);
         setEscherProperty(opt, EscherProperties.GEOMETRY__FILLOK, -1);
         setEscherProperty(opt, EscherProperties.SHADOWSTYLE__SHADOWOBSURED, 0x20000);
index e22db21baf2a3be713b78c2f4a27ba33a564e0a6..e3737e5e18332d98403cc60ded6e99af1dfbe11c 100644 (file)
@@ -19,18 +19,19 @@ package org.apache.poi.hslf.usermodel;
 
 import java.awt.Rectangle;
 
+import org.apache.poi.ddf.AbstractEscherOptRecord;
 import org.apache.poi.ddf.EscherContainerRecord;
-import org.apache.poi.ddf.EscherOptRecord;
 import org.apache.poi.ddf.EscherProperties;
 import org.apache.poi.sl.usermodel.ShapeContainer;
 import org.apache.poi.sl.usermodel.ShapeType;
+import org.apache.poi.sl.usermodel.TableCell;
 
 /**
  * Represents a cell in a ppt table
  *
  * @author Yegor Kozlov
  */
-public final class HSLFTableCell extends HSLFTextBox {
+public final class HSLFTableCell extends HSLFTextBox implements TableCell<HSLFShape,HSLFTextParagraph> {
     protected static final int DEFAULT_WIDTH = 100;
     protected static final int DEFAULT_HEIGHT = 40;
 
@@ -45,7 +46,7 @@ public final class HSLFTableCell extends HSLFTextBox {
      * @param escherRecord       EscherSpContainer which holds information about this shape
      * @param parent    the parent of the shape
      */
-   protected HSLFTableCell(EscherContainerRecord escherRecord, ShapeContainer<HSLFShape> parent){
+   protected HSLFTableCell(EscherContainerRecord escherRecord, ShapeContainer<HSLFShape,HSLFTextParagraph> parent){
         super(escherRecord, parent);
     }
 
@@ -55,7 +56,7 @@ public final class HSLFTableCell extends HSLFTextBox {
      * @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 HSLFTableCell(ShapeContainer<HSLFShape> parent){
+    public HSLFTableCell(ShapeContainer<HSLFShape,HSLFTextParagraph> parent){
         super(parent);
 
         setShapeType(ShapeType.RECT);
@@ -65,7 +66,7 @@ public final class HSLFTableCell extends HSLFTextBox {
 
     protected EscherContainerRecord createSpContainer(boolean isChild){
         _escherContainer = super.createSpContainer(isChild);
-        EscherOptRecord opt = getEscherOptRecord();
+        AbstractEscherOptRecord opt = getEscherOptRecord();
         setEscherProperty(opt, EscherProperties.TEXT__TEXTID, 0);
         setEscherProperty(opt, EscherProperties.TEXT__SIZE_TEXT_TO_FIT_SHAPE, 0x20000);
         setEscherProperty(opt, EscherProperties.FILL__NOFILLHITTEST, 0x150001);
index b7895a6ac59f7af1977137c60055cc8f5e7acc49..792928d1ea235526a04458ad8e75189805682462 100644 (file)
@@ -29,7 +29,7 @@ import org.apache.poi.sl.usermodel.*;
  *
  * @author Yegor Kozlov
  */
-public class HSLFTextBox extends HSLFTextShape {
+public class HSLFTextBox extends HSLFTextShape implements TextBox<HSLFShape,HSLFTextParagraph> {
 
     /**
      * Create a TextBox object and initialize it from the supplied Record container.
@@ -37,7 +37,7 @@ public class HSLFTextBox extends HSLFTextShape {
      * @param escherRecord       <code>EscherSpContainer</code> container which holds information about this shape
      * @param parent    the parent of the shape
      */
-   protected HSLFTextBox(EscherContainerRecord escherRecord, ShapeContainer<HSLFShape> parent){
+   protected HSLFTextBox(EscherContainerRecord escherRecord, ShapeContainer<HSLFShape,HSLFTextParagraph> parent){
         super(escherRecord, parent);
 
     }
@@ -48,7 +48,7 @@ public class HSLFTextBox extends HSLFTextShape {
      * @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 HSLFTextBox(ShapeContainer<HSLFShape> parent){
+    public HSLFTextBox(ShapeContainer<HSLFShape,HSLFTextParagraph> parent){
         super(parent);
     }
 
index 961c234102f4e60eff376b9f0bab93198fb1d3ce..9165bc1f3cf65a9d7c90879f531c53ea4885c402 100644 (file)
@@ -42,7 +42,7 @@ import org.apache.poi.util.*;
  * @author Nick Burch\r
  */\r
 \r
-public final class HSLFTextParagraph implements TextParagraph<HSLFTextRun> {\r
+public final class HSLFTextParagraph implements TextParagraph<HSLFShape,HSLFTextParagraph,HSLFTextRun> {\r
     protected static final POILogger logger = POILogFactory.getLogger(HSLFTextParagraph.class);\r
 \r
     /**\r
index e2f73066efd3e08cb3faf0628f25fd4547108500..5ca39b991960d5ea9cfe3c39349911b5b06d75c7 100644 (file)
@@ -39,7 +39,8 @@ import org.apache.poi.util.Units;
  *
  * @author Yegor Kozlov
  */
-public abstract class HSLFTextShape extends HSLFSimpleShape implements TextShape<HSLFTextParagraph> {
+public abstract class HSLFTextShape extends HSLFSimpleShape
+implements TextShape<HSLFShape,HSLFTextParagraph> {
 
     /**
      * How to anchor the text
@@ -93,9 +94,8 @@ public abstract class HSLFTextShape extends HSLFSimpleShape implements TextShape
      * @param escherRecord       <code>EscherSpContainer</code> container which holds information about this shape
      * @param parent    the parent of the shape
      */
-   protected HSLFTextShape(EscherContainerRecord escherRecord, ShapeContainer<HSLFShape> parent){
+    protected HSLFTextShape(EscherContainerRecord escherRecord, ShapeContainer<HSLFShape,HSLFTextParagraph> parent){
         super(escherRecord, parent);
-
     }
 
     /**
@@ -104,7 +104,7 @@ public abstract class HSLFTextShape extends HSLFSimpleShape implements TextShape
      * @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 HSLFTextShape(ShapeContainer<HSLFShape> parent){
+    public HSLFTextShape(ShapeContainer<HSLFShape,HSLFTextParagraph> parent){
         super(null, parent);
         _escherContainer = createSpContainer(parent instanceof HSLFGroupShape);
     }
@@ -241,7 +241,7 @@ public abstract class HSLFTextShape extends HSLFSimpleShape implements TextShape
      * @return the type of alignment
      */
     /* package */ int getAlignment(){
-        EscherOptRecord opt = getEscherOptRecord();
+        AbstractEscherOptRecord opt = getEscherOptRecord();
         EscherSimpleProperty prop = getEscherProperty(opt, EscherProperties.TEXT__ANCHORTEXT);
         int align = HSLFTextShape.AnchorTop;
         if (prop == null){
@@ -465,7 +465,7 @@ public abstract class HSLFTextShape extends HSLFSimpleShape implements TextShape
      * @return the inset in points
      */
     private double getInset(short propId, double defaultInch) {
-        EscherOptRecord opt = getEscherOptRecord();
+        AbstractEscherOptRecord opt = getEscherOptRecord();
         EscherSimpleProperty prop = getEscherProperty(opt, propId);
         int val = prop == null ? (int)(Units.toEMU(Units.POINT_DPI)*defaultInch) : prop.getPropertyValue();
         return Units.toPoints(val);        
@@ -494,7 +494,7 @@ public abstract class HSLFTextShape extends HSLFSimpleShape implements TextShape
      * @see <a href="https://msdn.microsoft.com/en-us/library/dd948168(v=office.12).aspx">MSOWRAPMODE</a>
      */
     public int getWordWrapEx() {
-        EscherOptRecord opt = getEscherOptRecord();
+        AbstractEscherOptRecord opt = getEscherOptRecord();
         EscherSimpleProperty prop = getEscherProperty(opt, EscherProperties.TEXT__WRAPTEXT);
         return prop == null ? WrapSquare : prop.getPropertyValue();
     }
@@ -513,7 +513,7 @@ public abstract class HSLFTextShape extends HSLFSimpleShape implements TextShape
      * @return id for the text.
      */
     public int getTextId(){
-        EscherOptRecord opt = getEscherOptRecord();
+        AbstractEscherOptRecord opt = getEscherOptRecord();
         EscherSimpleProperty prop = getEscherProperty(opt, EscherProperties.TEXT__TEXTID);
         return prop == null ? 0 : prop.getPropertyValue();
     }
@@ -527,9 +527,7 @@ public abstract class HSLFTextShape extends HSLFSimpleShape implements TextShape
         setEscherProperty(EscherProperties.TEXT__TEXTID, id);
     }
 
-    /**
-      * @return the TextParagraphs for this text box
-      */
+    @Override
     public List<HSLFTextParagraph> getTextParagraphs(){
         if (!_paragraphs.isEmpty()) return _paragraphs;
         
@@ -704,7 +702,7 @@ public abstract class HSLFTextShape extends HSLFSimpleShape implements TextShape
     @Override
     public double getTextHeight(){
         DrawFactory drawFact = DrawFactory.getInstance(null);
-        DrawTextShape<HSLFTextShape> dts = drawFact.getDrawable(this);
+        DrawTextShape dts = drawFact.getDrawable(this);
         return dts.getTextHeight();
     }
 
index eaebd5c167c81fe11fe110f63b967a52fb919501..f8b4bccb5a0bf5e4ac3ec62aa7fa20cc3fc5ad68 100644 (file)
@@ -26,9 +26,9 @@ import java.io.ByteArrayOutputStream;
 import java.util.List;
 
 import org.apache.poi.POIDataSamples;
+import org.apache.poi.ddf.AbstractEscherOptRecord;
 import org.apache.poi.ddf.EscherBSERecord;
 import org.apache.poi.ddf.EscherContainerRecord;
-import org.apache.poi.ddf.EscherOptRecord;
 import org.apache.poi.ddf.EscherProperties;
 import org.apache.poi.ddf.EscherRecord;
 import org.apache.poi.ddf.EscherSimpleProperty;
@@ -209,7 +209,7 @@ public final class TestBackground {
     }
 
     private int getFillPictureRefCount(HSLFShape shape, HSLFFill fill) {
-        EscherOptRecord opt = shape.getEscherOptRecord();
+        AbstractEscherOptRecord opt = shape.getEscherOptRecord();
         EscherSimpleProperty p = HSLFShape.getEscherProperty(opt, EscherProperties.FILL__PATTERNTEXTURE);
         if(p != null) {
             int idx = p.getPropertyValue();
index 3fca4c2571815c88f489fadad4859a3c691b0414..3dfdd578336d85366c6d137f0260ed2d72742c56 100644 (file)
@@ -36,13 +36,14 @@ import java.util.ArrayList;
 import java.util.List;
 
 import org.apache.poi.POIDataSamples;
+import org.apache.poi.ddf.AbstractEscherOptRecord;
 import org.apache.poi.ddf.EscherDgRecord;
 import org.apache.poi.ddf.EscherDggRecord;
-import org.apache.poi.ddf.EscherOptRecord;
 import org.apache.poi.ddf.EscherProperties;
 import org.apache.poi.ddf.EscherSimpleProperty;
 import org.apache.poi.hslf.usermodel.HSLFAutoShape;
 import org.apache.poi.hslf.usermodel.HSLFGroupShape;
+import org.apache.poi.hslf.usermodel.HSLFLine;
 import org.apache.poi.hslf.usermodel.HSLFPictureData;
 import org.apache.poi.hslf.usermodel.HSLFPictureShape;
 import org.apache.poi.hslf.usermodel.HSLFShape;
@@ -54,7 +55,6 @@ import org.apache.poi.hslf.usermodel.HSLFTextBox;
 import org.apache.poi.hslf.usermodel.HSLFTextParagraph;
 import org.apache.poi.hslf.usermodel.HSLFTextRun;
 import org.apache.poi.hslf.usermodel.HSLFTextShape;
-import org.apache.poi.hslf.usermodel.HSLFLine;
 import org.apache.poi.sl.usermodel.PictureData.PictureType;
 import org.apache.poi.sl.usermodel.ShapeType;
 import org.apache.poi.sl.usermodel.StrokeStyle.LineDash;
@@ -400,7 +400,7 @@ public final class TestShapes {
     public void lineWidth() {
         HSLFSimpleShape sh = new HSLFAutoShape(ShapeType.RT_TRIANGLE);
 
-        EscherOptRecord opt = sh.getEscherOptRecord();
+        AbstractEscherOptRecord opt = sh.getEscherOptRecord();
         EscherSimpleProperty prop = HSLFSimpleShape.getEscherProperty(opt, EscherProperties.LINESTYLE__LINEWIDTH);
         assertNull(prop);
         assertEquals(HSLFSimpleShape.DEFAULT_LINE_WIDTH, sh.getLineWidth(), 0);
index 70028ba4bdd8ce3330b75b340bf8685c48cf8719..8032d2da3e483c96a00c43a3157f5c0ae9095bf2 100644 (file)
@@ -126,17 +126,17 @@ public final class TestTable {
      */
     @Test
     public void test57820() throws Exception {
-        SlideShow ppt = new HSLFSlideShow(_slTests.openResourceAsStream("bug57820-initTableNullRefrenceException.ppt"));
+        SlideShow<?,?> ppt = new HSLFSlideShow(_slTests.openResourceAsStream("bug57820-initTableNullRefrenceException.ppt"));
 
-        List<? extends Slide<?,?,?>> slides = ppt.getSlides();
+        List<? extends Slide<?,?>> slides = ppt.getSlides();
         assertEquals(1, slides.size());
 
-        List<? extends Shape> shapes = slides.get(0).getShapes(); //throws NullPointerException
+        List<? extends Shape<?,?>> shapes = slides.get(0).getShapes(); //throws NullPointerException
 
-        TableShape tbl = null;
-        for(Shape s : shapes) {
+        TableShape<?,?> tbl = null;
+        for(Shape<?,?> s : shapes) {
             if(s instanceof TableShape) {
-                tbl = (TableShape)s;
+                tbl = (TableShape<?,?>)s;
                 break;
             }
         }
index 1dbd0f457f9f9c72108a438a63420360c14c6a9f..a8543924a607e44cbf4c6665a6598ffde32d4470 100644 (file)
@@ -38,9 +38,9 @@ import java.util.Set;
 import junit.framework.AssertionFailedError;
 
 import org.apache.poi.POIDataSamples;
+import org.apache.poi.ddf.AbstractEscherOptRecord;
 import org.apache.poi.ddf.EscherArrayProperty;
 import org.apache.poi.ddf.EscherColorRef;
-import org.apache.poi.ddf.EscherOptRecord;
 import org.apache.poi.ddf.EscherProperties;
 import org.apache.poi.hslf.HSLFTestDataSamples;
 import org.apache.poi.hslf.exceptions.OldPowerPointFormatException;
@@ -612,7 +612,7 @@ public final class TestBugs {
         try {
             HSLFSlideShow slideShow = new HSLFSlideShow(inputStream);
             HSLFAutoShape as = (HSLFAutoShape)slideShow.getSlides().get(0).getShapes().get(0);
-            EscherOptRecord opt = as.getEscherOptRecord();
+            AbstractEscherOptRecord opt = as.getEscherOptRecord();
             EscherArrayProperty ep = HSLFShape.getEscherProperty(opt, EscherProperties.FILL__SHADECOLORS);
             double exp[][] = {
                 // r, g, b, position
index d7adf4000e1627799ec611d86e63cd9cc7283c75..a6606571021239795ecf342a2e59f5a85ffd3259 100644 (file)
@@ -172,11 +172,11 @@ public final class TestPicture {
         
         for (String file : files) {
             InputStream is = _slTests.openResourceAsStream(file);
-            SlideShow ss;
+            SlideShow<?,?> ss;
             if (file.endsWith("pptx")) {
                 Class<?> cls = Class.forName("org.apache.poi.xslf.usermodel.XMLSlideShow");
                 Constructor<?> ct = cls.getDeclaredConstructor(InputStream.class);
-                ss = (SlideShow)ct.newInstance(is);
+                ss = (SlideShow<?,?>)ct.newInstance(is);
             } else {
                 ss = new HSLFSlideShow(is);
             }
@@ -184,7 +184,7 @@ public final class TestPicture {
             
             boolean debugOut = false;
             Dimension pg = ss.getPageSize();
-            for (Slide<?,?,?> slide : ss.getSlides()) {
+            for (Slide<?,?> slide : ss.getSlides()) {
                 int slideNo = slide.getSlideNumber();
                 if (!pages.get(slideNo-1)) {
                     if (pages.nextSetBit(slideNo-1) == -1) break; else continue;