poi-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From j...@apache.org
Subject svn commit: r777204 [7/21] - in /poi/trunk/src/scratchpad: examples/src/org/apache/poi/hslf/examples/ examples/src/org/apache/poi/hwpf/ src/org/apache/poi/hdf/event/ src/org/apache/poi/hdf/extractor/ src/org/apache/poi/hdf/extractor/data/ src/org/apach...
Date Thu, 21 May 2009 18:15:01 GMT
Modified: poi/trunk/src/scratchpad/src/org/apache/poi/hslf/model/PPFont.java
URL: http://svn.apache.org/viewvc/poi/trunk/src/scratchpad/src/org/apache/poi/hslf/model/PPFont.java?rev=777204&r1=777203&r2=777204&view=diff
==============================================================================
--- poi/trunk/src/scratchpad/src/org/apache/poi/hslf/model/PPFont.java (original)
+++ poi/trunk/src/scratchpad/src/org/apache/poi/hslf/model/PPFont.java Thu May 21 18:12:22 2009
@@ -1,243 +1,243 @@
-/* ====================================================================
-   Licensed to the Apache Software Foundation (ASF) under one or more
-   contributor license agreements.  See the NOTICE file distributed with
-   this work for additional information regarding copyright ownership.
-   The ASF licenses this file to You under the Apache License, Version 2.0
-   (the "License"); you may not use this file except in compliance with
-   the License.  You may obtain a copy of the License at
-
-       http://www.apache.org/licenses/LICENSE-2.0
-
-   Unless required by applicable law or agreed to in writing, software
-   distributed under the License is distributed on an "AS IS" BASIS,
-   WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
-   See the License for the specific language governing permissions and
-   limitations under the License.
-==================================================================== */
-
-package org.apache.poi.hslf.model;
-
-import org.apache.poi.hslf.record.FontEntityAtom;
-
-/**
- * Represents a Font used in a presenation.
- * <p>
- * In PowerPoint Font is a shared resource and can be shared among text object in the presentation.
- * </p>
- * Some commonly used fonts are predefined in static constants. 
- *
- * @author Yegor Kozlov
- */
-public class PPFont {
-    /**
-     * ANSI character set
-     */
-    public final static byte ANSI_CHARSET = 0;
-
-    /**
-     * Default character set.
-     */
-    public final static byte DEFAULT_CHARSET = 1;
-
-    /**
-     * Symbol character set
-     */
-    public final static byte SYMBOL_CHARSET = 2;
-
-
-    /**
-     * Constants for the pitch and family of the font.
-     * The two low-order bits specify the pitch of the font and can be one of the following values
-     */
-    public final static byte DEFAULT_PITCH  = 0;
-    public final static byte FIXED_PITCH    = 1;
-    public final static byte VARIABLE_PITCH = 2;
-
-    /**
-     * Don't care or don't know.
-     */
-    public final static byte FF_DONTCARE    = 0;
-    /**
-     * Fonts with variable stroke width (proportional) and with serifs. Times New Roman is an example.
-     */
-    public final static byte FF_ROMAN       = 16;
-    /**
-     * Fonts with variable stroke width (proportional) and without serifs. Arial is an example.
-     */
-    public final static byte FF_SWISS       = 32;
-    /**
-     * Fonts designed to look like handwriting. Script and Cursive are examples.
-     */
-    public final static byte FF_SCRIPT      = 64;
-    /**
-     * Fonts with constant stroke width (monospace), with or without serifs.
-     * Monospace fonts are usually modern. CourierNew is an example
-     */
-    public final static byte FF_MODERN      = 48;
-    /**
-     * Novelty fonts. Old English is an example
-     */
-    public final static byte FF_DECORATIVE  = 80;
-
-
-    protected int charset;
-    protected int type;
-    protected int flags;
-    protected int pitch;
-    protected String name;
-
-    /**
-     * Creates a new instance of PPFont
-     */
-    public PPFont(){
-
-    }
-
-    /**
-     * Creates a new instance of PPFont and initialize it from the supplied font atom
-     */
-    public PPFont(FontEntityAtom fontAtom){
-        name = fontAtom.getFontName();
-        charset = fontAtom.getCharSet();
-        type = fontAtom.getFontType();
-        flags = fontAtom.getFontFlags();
-        pitch = fontAtom.getPitchAndFamily();
-    }
-
-    /**
-     * set the name for the font (i.e. Arial)
-     *
-     * @param val  String representing the name of the font to use
-     */
-     public void setFontName(String val){
-        name = val;
-    }
-
-    /**
-     * get the name for the font (i.e. Arial)
-     *
-     * @return String representing the name of the font to use
-     */
-    public String getFontName(){
-        return name;
-    }
-
-    /**
-     * set the character set
-     *
-     * @param val - characterset
-     */
-    public void setCharSet(int val){
-        charset = val;
-    }
-
-    /**
-     * get the character set
-     *
-     * @return charset - characterset
-     */
-    public int getCharSet(){
-        return charset;
-    }
-
-    /**
-     * set the font flags
-     * Bit 1: If set, font is subsetted
-     *
-     * @param val - the font flags
-     */
-    public void setFontFlags(int val){
-        flags = val;
-    }
-
-    /**
-     * get the character set
-     * Bit 1: If set, font is subsetted
-     *
-     * @return the font flags
-     */
-    public int getFontFlags(){
-        return flags;
-    }
-
-    /**
-     * set the font type
-     * <p>
-     * Bit 1: Raster Font
-     * Bit 2: Device Font
-     * Bit 3: TrueType Font
-     * </p>
-     *
-     * @param val - the font type
-     */
-    public void setFontType(int val){
-        type = val;
-    }
-
-    /**
-     * get the font type
-     * <p>
-     * Bit 1: Raster Font
-     * Bit 2: Device Font
-     * Bit 3: TrueType Font
-     * </p>
-     *
-     * @return the font type
-     */
-    public int getFontType(){
-        return type;
-    }
-
-    /**
-     * set lfPitchAndFamily
-     *
-     *
-     * @param val - Corresponds to the lfPitchAndFamily field of the Win32 API LOGFONT structure
-     */
-    public void setPitchAndFamily(int val){
-        pitch = val;
-    }
-
-    /**
-     * get lfPitchAndFamily
-     *
-     * @return corresponds to the lfPitchAndFamily field of the Win32 API LOGFONT structure
-     */
-    public int getPitchAndFamily(){
-        return pitch;
-    }
-
-    public static final PPFont ARIAL;
-    public static final PPFont TIMES_NEW_ROMAN ;
-    public static final PPFont COURIER_NEW;
-    public static final PPFont WINGDINGS;
-    static {
-        ARIAL = new PPFont();
-        ARIAL.setFontName("Arial");
-        ARIAL.setCharSet(ANSI_CHARSET);
-        ARIAL.setFontType(4);
-        ARIAL.setFontFlags(0);
-        ARIAL.setPitchAndFamily(VARIABLE_PITCH | FF_SWISS);
-
-        TIMES_NEW_ROMAN = new PPFont();
-        TIMES_NEW_ROMAN.setFontName("Times New Roman");
-        TIMES_NEW_ROMAN.setCharSet(ANSI_CHARSET);
-        TIMES_NEW_ROMAN.setFontType(4);
-        TIMES_NEW_ROMAN.setFontFlags(0);
-        TIMES_NEW_ROMAN.setPitchAndFamily(VARIABLE_PITCH | FF_ROMAN);
-
-        COURIER_NEW = new PPFont();
-        COURIER_NEW.setFontName("Courier New");
-        COURIER_NEW.setCharSet(ANSI_CHARSET);
-        COURIER_NEW.setFontType(4);
-        COURIER_NEW.setFontFlags(0);
-        COURIER_NEW.setPitchAndFamily(FIXED_PITCH | FF_MODERN);
-
-        WINGDINGS = new PPFont();
-        WINGDINGS.setFontName("Wingdings");
-        WINGDINGS.setCharSet(SYMBOL_CHARSET);
-        WINGDINGS.setFontType(4);
-        WINGDINGS.setFontFlags(0);
-        WINGDINGS.setPitchAndFamily(VARIABLE_PITCH | FF_DONTCARE);
-    }
-}
+/* ====================================================================
+   Licensed to the Apache Software Foundation (ASF) under one or more
+   contributor license agreements.  See the NOTICE file distributed with
+   this work for additional information regarding copyright ownership.
+   The ASF licenses this file to You under the Apache License, Version 2.0
+   (the "License"); you may not use this file except in compliance with
+   the License.  You may obtain a copy of the License at
+
+       http://www.apache.org/licenses/LICENSE-2.0
+
+   Unless required by applicable law or agreed to in writing, software
+   distributed under the License is distributed on an "AS IS" BASIS,
+   WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+   See the License for the specific language governing permissions and
+   limitations under the License.
+==================================================================== */
+
+package org.apache.poi.hslf.model;
+
+import org.apache.poi.hslf.record.FontEntityAtom;
+
+/**
+ * Represents a Font used in a presenation.
+ * <p>
+ * In PowerPoint Font is a shared resource and can be shared among text object in the presentation.
+ * </p>
+ * Some commonly used fonts are predefined in static constants.
+ *
+ * @author Yegor Kozlov
+ */
+public final class PPFont {
+    /**
+     * ANSI character set
+     */
+    public final static byte ANSI_CHARSET = 0;
+
+    /**
+     * Default character set.
+     */
+    public final static byte DEFAULT_CHARSET = 1;
+
+    /**
+     * Symbol character set
+     */
+    public final static byte SYMBOL_CHARSET = 2;
+
+
+    /**
+     * Constants for the pitch and family of the font.
+     * The two low-order bits specify the pitch of the font and can be one of the following values
+     */
+    public final static byte DEFAULT_PITCH  = 0;
+    public final static byte FIXED_PITCH    = 1;
+    public final static byte VARIABLE_PITCH = 2;
+
+    /**
+     * Don't care or don't know.
+     */
+    public final static byte FF_DONTCARE    = 0;
+    /**
+     * Fonts with variable stroke width (proportional) and with serifs. Times New Roman is an example.
+     */
+    public final static byte FF_ROMAN       = 16;
+    /**
+     * Fonts with variable stroke width (proportional) and without serifs. Arial is an example.
+     */
+    public final static byte FF_SWISS       = 32;
+    /**
+     * Fonts designed to look like handwriting. Script and Cursive are examples.
+     */
+    public final static byte FF_SCRIPT      = 64;
+    /**
+     * Fonts with constant stroke width (monospace), with or without serifs.
+     * Monospace fonts are usually modern. CourierNew is an example
+     */
+    public final static byte FF_MODERN      = 48;
+    /**
+     * Novelty fonts. Old English is an example
+     */
+    public final static byte FF_DECORATIVE  = 80;
+
+
+    protected int charset;
+    protected int type;
+    protected int flags;
+    protected int pitch;
+    protected String name;
+
+    /**
+     * Creates a new instance of PPFont
+     */
+    public PPFont(){
+
+    }
+
+    /**
+     * Creates a new instance of PPFont and initialize it from the supplied font atom
+     */
+    public PPFont(FontEntityAtom fontAtom){
+        name = fontAtom.getFontName();
+        charset = fontAtom.getCharSet();
+        type = fontAtom.getFontType();
+        flags = fontAtom.getFontFlags();
+        pitch = fontAtom.getPitchAndFamily();
+    }
+
+    /**
+     * set the name for the font (i.e. Arial)
+     *
+     * @param val  String representing the name of the font to use
+     */
+     public void setFontName(String val){
+        name = val;
+    }
+
+    /**
+     * get the name for the font (i.e. Arial)
+     *
+     * @return String representing the name of the font to use
+     */
+    public String getFontName(){
+        return name;
+    }
+
+    /**
+     * set the character set
+     *
+     * @param val - characterset
+     */
+    public void setCharSet(int val){
+        charset = val;
+    }
+
+    /**
+     * get the character set
+     *
+     * @return charset - characterset
+     */
+    public int getCharSet(){
+        return charset;
+    }
+
+    /**
+     * set the font flags
+     * Bit 1: If set, font is subsetted
+     *
+     * @param val - the font flags
+     */
+    public void setFontFlags(int val){
+        flags = val;
+    }
+
+    /**
+     * get the character set
+     * Bit 1: If set, font is subsetted
+     *
+     * @return the font flags
+     */
+    public int getFontFlags(){
+        return flags;
+    }
+
+    /**
+     * set the font type
+     * <p>
+     * Bit 1: Raster Font
+     * Bit 2: Device Font
+     * Bit 3: TrueType Font
+     * </p>
+     *
+     * @param val - the font type
+     */
+    public void setFontType(int val){
+        type = val;
+    }
+
+    /**
+     * get the font type
+     * <p>
+     * Bit 1: Raster Font
+     * Bit 2: Device Font
+     * Bit 3: TrueType Font
+     * </p>
+     *
+     * @return the font type
+     */
+    public int getFontType(){
+        return type;
+    }
+
+    /**
+     * set lfPitchAndFamily
+     *
+     *
+     * @param val - Corresponds to the lfPitchAndFamily field of the Win32 API LOGFONT structure
+     */
+    public void setPitchAndFamily(int val){
+        pitch = val;
+    }
+
+    /**
+     * get lfPitchAndFamily
+     *
+     * @return corresponds to the lfPitchAndFamily field of the Win32 API LOGFONT structure
+     */
+    public int getPitchAndFamily(){
+        return pitch;
+    }
+
+    public static final PPFont ARIAL;
+    public static final PPFont TIMES_NEW_ROMAN ;
+    public static final PPFont COURIER_NEW;
+    public static final PPFont WINGDINGS;
+    static {
+        ARIAL = new PPFont();
+        ARIAL.setFontName("Arial");
+        ARIAL.setCharSet(ANSI_CHARSET);
+        ARIAL.setFontType(4);
+        ARIAL.setFontFlags(0);
+        ARIAL.setPitchAndFamily(VARIABLE_PITCH | FF_SWISS);
+
+        TIMES_NEW_ROMAN = new PPFont();
+        TIMES_NEW_ROMAN.setFontName("Times New Roman");
+        TIMES_NEW_ROMAN.setCharSet(ANSI_CHARSET);
+        TIMES_NEW_ROMAN.setFontType(4);
+        TIMES_NEW_ROMAN.setFontFlags(0);
+        TIMES_NEW_ROMAN.setPitchAndFamily(VARIABLE_PITCH | FF_ROMAN);
+
+        COURIER_NEW = new PPFont();
+        COURIER_NEW.setFontName("Courier New");
+        COURIER_NEW.setCharSet(ANSI_CHARSET);
+        COURIER_NEW.setFontType(4);
+        COURIER_NEW.setFontFlags(0);
+        COURIER_NEW.setPitchAndFamily(FIXED_PITCH | FF_MODERN);
+
+        WINGDINGS = new PPFont();
+        WINGDINGS.setFontName("Wingdings");
+        WINGDINGS.setCharSet(SYMBOL_CHARSET);
+        WINGDINGS.setFontType(4);
+        WINGDINGS.setFontFlags(0);
+        WINGDINGS.setPitchAndFamily(VARIABLE_PITCH | FF_DONTCARE);
+    }
+}

Modified: poi/trunk/src/scratchpad/src/org/apache/poi/hslf/model/PPGraphics2D.java
URL: http://svn.apache.org/viewvc/poi/trunk/src/scratchpad/src/org/apache/poi/hslf/model/PPGraphics2D.java?rev=777204&r1=777203&r2=777204&view=diff
==============================================================================
--- poi/trunk/src/scratchpad/src/org/apache/poi/hslf/model/PPGraphics2D.java (original)
+++ poi/trunk/src/scratchpad/src/org/apache/poi/hslf/model/PPGraphics2D.java Thu May 21 18:12:22 2009
@@ -14,6 +14,7 @@
    See the License for the specific language governing permissions and
    limitations under the License.
 ==================================================================== */
+
 package org.apache.poi.hslf.model;
 
 
@@ -37,7 +38,7 @@
  *
  * @author Yegor Kozlov
  */
-public class PPGraphics2D extends Graphics2D implements Cloneable {
+public final class PPGraphics2D extends Graphics2D implements Cloneable {
 
     protected POILogger log = POILogFactory.getLogger(this.getClass());
 

Modified: poi/trunk/src/scratchpad/src/org/apache/poi/hslf/model/Picture.java
URL: http://svn.apache.org/viewvc/poi/trunk/src/scratchpad/src/org/apache/poi/hslf/model/Picture.java?rev=777204&r1=777203&r2=777204&view=diff
==============================================================================
--- poi/trunk/src/scratchpad/src/org/apache/poi/hslf/model/Picture.java (original)
+++ poi/trunk/src/scratchpad/src/org/apache/poi/hslf/model/Picture.java Thu May 21 18:12:22 2009
@@ -1,19 +1,20 @@
-/*
-* Licensed to the Apache Software Foundation (ASF) under one or more
-* contributor license agreements.  See the NOTICE file distributed with
-* this work for additional information regarding copyright ownership.
-* The ASF licenses this file to You under the Apache License, Version 2.0
-* (the "License"); you may not use this file except in compliance with
-* the License.  You may obtain a copy of the License at
-*
-*     http://www.apache.org/licenses/LICENSE-2.0
-*
-* Unless required by applicable law or agreed to in writing, software
-* distributed under the License is distributed on an "AS IS" BASIS,
-* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
-* See the License for the specific language governing permissions and
-* limitations under the License.
-*/
+/* ====================================================================
+   Licensed to the Apache Software Foundation (ASF) under one or more
+   contributor license agreements.  See the NOTICE file distributed with
+   this work for additional information regarding copyright ownership.
+   The ASF licenses this file to You under the Apache License, Version 2.0
+   (the "License"); you may not use this file except in compliance with
+   the License.  You may obtain a copy of the License at
+
+       http://www.apache.org/licenses/LICENSE-2.0
+
+   Unless required by applicable law or agreed to in writing, software
+   distributed under the License is distributed on an "AS IS" BASIS,
+   WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+   See the License for the specific language governing permissions and
+   limitations under the License.
+==================================================================== */
+
 package org.apache.poi.hslf.model;
 
 import org.apache.poi.ddf.*;
@@ -72,7 +73,7 @@
      * Windows DIB (BMP)
      */
     public static final byte DIB = 7;
-    
+
     /**
      * Create a new <code>Picture</code>
      *
@@ -143,7 +144,7 @@
     /**
      * Resize this picture to the default size.
      * For PNG and JPEG resizes the image to 100%,
-     * for other types sets the default size of 200x200 pixels.  
+     * for other types sets the default size of 200x200 pixels.
      */
     public void setDefaultSize(){
         PictureData pict = getPictureData();
@@ -151,10 +152,10 @@
             BufferedImage img = null;
             try {
                	img = ImageIO.read(new ByteArrayInputStream(pict.getData()));
-            } 
+            }
             catch (IOException e){}
         	catch (NegativeArraySizeException ne) {}
-        	
+
             if(img != null) {
             	// Valid image, set anchor from it
             	setAnchor(new java.awt.Rectangle(0, 0, img.getWidth()*POINT_DPI/PIXEL_DPI, img.getHeight()*POINT_DPI/PIXEL_DPI));
@@ -163,7 +164,7 @@
             	setAnchor(new java.awt.Rectangle(0, 0, 200, 200));
             }
         } else {
-            //default size of a metafile picture is 200x200 
+            //default size of a metafile picture is 200x200
             setAnchor(new java.awt.Rectangle(50, 50, 200, 200));
         }
     }

Modified: poi/trunk/src/scratchpad/src/org/apache/poi/hslf/model/Placeholder.java
URL: http://svn.apache.org/viewvc/poi/trunk/src/scratchpad/src/org/apache/poi/hslf/model/Placeholder.java?rev=777204&r1=777203&r2=777204&view=diff
==============================================================================
--- poi/trunk/src/scratchpad/src/org/apache/poi/hslf/model/Placeholder.java (original)
+++ poi/trunk/src/scratchpad/src/org/apache/poi/hslf/model/Placeholder.java Thu May 21 18:12:22 2009
@@ -29,7 +29,7 @@
  *
  * @author Yegor Kozlov
  */
-public class Placeholder extends TextBox {
+public final class Placeholder extends TextBox {
 
     protected Placeholder(EscherContainerRecord escherRecord, Shape parent){
         super(escherRecord, parent);

Modified: poi/trunk/src/scratchpad/src/org/apache/poi/hslf/model/Polygon.java
URL: http://svn.apache.org/viewvc/poi/trunk/src/scratchpad/src/org/apache/poi/hslf/model/Polygon.java?rev=777204&r1=777203&r2=777204&view=diff
==============================================================================
--- poi/trunk/src/scratchpad/src/org/apache/poi/hslf/model/Polygon.java (original)
+++ poi/trunk/src/scratchpad/src/org/apache/poi/hslf/model/Polygon.java Thu May 21 18:12:22 2009
@@ -1,160 +1,161 @@
-/* ====================================================================
-   Licensed to the Apache Software Foundation (ASF) under one or more
-   contributor license agreements.  See the NOTICE file distributed with
-   this work for additional information regarding copyright ownership.
-   The ASF licenses this file to You under the Apache License, Version 2.0
-   (the "License"); you may not use this file except in compliance with
-   the License.  You may obtain a copy of the License at
-
-       http://www.apache.org/licenses/LICENSE-2.0
-
-   Unless required by applicable law or agreed to in writing, software
-   distributed under the License is distributed on an "AS IS" BASIS,
-   WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
-   See the License for the specific language governing permissions and
-   limitations under the License.
-==================================================================== */
-package org.apache.poi.hslf.model;
-
-import org.apache.poi.ddf.*;
-import org.apache.poi.util.LittleEndian;
-
-import java.awt.geom.Point2D;
-
-/**
- * A simple closed polygon shape
- *
- * @author Yegor Kozlov
- */
-public class Polygon extends AutoShape {
-    /**
-     * Create a Polygon 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 Polygon(EscherContainerRecord escherRecord, Shape parent){
-        super(escherRecord, parent);
-
-    }
-
-    /**
-     * Create a new Polygon. This constructor is used when a new shape is created.
-     *
-     * @param parent    the parent of this Shape. For example, if this text box is a cell
-     * in a table then the parent is Table.
-     */
-    public Polygon(Shape parent){
-        super(null, parent);
-        _escherContainer = createSpContainer(ShapeTypes.NotPrimitive, parent instanceof ShapeGroup);
-    }
-
-    /**
-     * Create a new Polygon. This constructor is used when a new shape is created.
-     *
-     */
-    public Polygon(){
-        this(null);
-    }
-
-    /**
-     * Set the polygon vertices
-     *
-     * @param xPoints
-     * @param yPoints
-     */
-    public void setPoints(float[] xPoints, float[] yPoints)
-    {
-        float right  = findBiggest(xPoints);
-        float bottom = findBiggest(yPoints);
-        float left   = findSmallest(xPoints);
-        float top    = findSmallest(yPoints);
-
-        EscherOptRecord opt = (EscherOptRecord)getEscherChild(_escherContainer, EscherOptRecord.RECORD_ID);
-        opt.addEscherProperty(new EscherSimpleProperty(EscherProperties.GEOMETRY__RIGHT, (int)((right - left)*POINT_DPI/MASTER_DPI)));
-        opt.addEscherProperty(new EscherSimpleProperty(EscherProperties.GEOMETRY__BOTTOM, (int)((bottom - top)*POINT_DPI/MASTER_DPI)));
-
-        for (int i = 0; i < xPoints.length; i++) {
-            xPoints[i] += -left;
-            yPoints[i] += -top;
-        }
-
-        int numpoints = xPoints.length;
-
-        EscherArrayProperty verticesProp = new EscherArrayProperty(EscherProperties.GEOMETRY__VERTICES, false, new byte[0] );
-        verticesProp.setNumberOfElementsInArray(numpoints+1);
-        verticesProp.setNumberOfElementsInMemory(numpoints+1);
-        verticesProp.setSizeOfElements(0xFFF0);
-        for (int i = 0; i < numpoints; i++)
-        {
-            byte[] data = new byte[4];
-            LittleEndian.putShort(data, 0, (short)(xPoints[i]*POINT_DPI/MASTER_DPI));
-            LittleEndian.putShort(data, 2, (short)(yPoints[i]*POINT_DPI/MASTER_DPI));
-            verticesProp.setElement(i, data);
-        }
-        byte[] data = new byte[4];
-        LittleEndian.putShort(data, 0, (short)(xPoints[0]*POINT_DPI/MASTER_DPI));
-        LittleEndian.putShort(data, 2, (short)(yPoints[0]*POINT_DPI/MASTER_DPI));
-        verticesProp.setElement(numpoints, data);
-        opt.addEscherProperty(verticesProp);
-
-        EscherArrayProperty segmentsProp = new EscherArrayProperty(EscherProperties.GEOMETRY__SEGMENTINFO, false, null );
-        segmentsProp.setSizeOfElements(0x0002);
-        segmentsProp.setNumberOfElementsInArray(numpoints * 2 + 4);
-        segmentsProp.setNumberOfElementsInMemory(numpoints * 2 + 4);
-        segmentsProp.setElement(0, new byte[] { (byte)0x00, (byte)0x40 } );
-        segmentsProp.setElement(1, new byte[] { (byte)0x00, (byte)0xAC } );
-        for (int i = 0; i < numpoints; i++)
-        {
-            segmentsProp.setElement(2 + i * 2, new byte[] { (byte)0x01, (byte)0x00 } );
-            segmentsProp.setElement(3 + i * 2, new byte[] { (byte)0x00, (byte)0xAC } );
-        }
-        segmentsProp.setElement(segmentsProp.getNumberOfElementsInArray() - 2, new byte[] { (byte)0x01, (byte)0x60 } );
-        segmentsProp.setElement(segmentsProp.getNumberOfElementsInArray() - 1, new byte[] { (byte)0x00, (byte)0x80 } );
-        opt.addEscherProperty(segmentsProp);
-
-        opt.sortProperties();
-    }
-
-    /**
-     * Set the polygon vertices
-     *
-     * @param points the polygon vertices
-     */
-      public void setPoints(Point2D[] points)
-     {
-        float[] xpoints = new float[points.length];
-        float[] ypoints = new float[points.length];
-        for (int i = 0; i < points.length; i++) {
-            xpoints[i] = (float)points[i].getX();
-            ypoints[i] = (float)points[i].getY();
-
-        }
-
-        setPoints(xpoints, ypoints);
-    }
-
-    private float findBiggest( float[] values )
-    {
-        float result = Float.MIN_VALUE;
-        for ( int i = 0; i < values.length; i++ )
-        {
-            if (values[i] > result)
-                result = values[i];
-        }
-        return result;
-    }
-
-    private float findSmallest( float[] values )
-    {
-        float result = Float.MAX_VALUE;
-        for ( int i = 0; i < values.length; i++ )
-        {
-            if (values[i] < result)
-                result = values[i];
-        }
-        return result;
-    }
-
-
-}
+/* ====================================================================
+   Licensed to the Apache Software Foundation (ASF) under one or more
+   contributor license agreements.  See the NOTICE file distributed with
+   this work for additional information regarding copyright ownership.
+   The ASF licenses this file to You under the Apache License, Version 2.0
+   (the "License"); you may not use this file except in compliance with
+   the License.  You may obtain a copy of the License at
+
+       http://www.apache.org/licenses/LICENSE-2.0
+
+   Unless required by applicable law or agreed to in writing, software
+   distributed under the License is distributed on an "AS IS" BASIS,
+   WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+   See the License for the specific language governing permissions and
+   limitations under the License.
+==================================================================== */
+
+package org.apache.poi.hslf.model;
+
+import org.apache.poi.ddf.*;
+import org.apache.poi.util.LittleEndian;
+
+import java.awt.geom.Point2D;
+
+/**
+ * A simple closed polygon shape
+ *
+ * @author Yegor Kozlov
+ */
+public final class Polygon extends AutoShape {
+    /**
+     * Create a Polygon 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 Polygon(EscherContainerRecord escherRecord, Shape parent){
+        super(escherRecord, parent);
+
+    }
+
+    /**
+     * Create a new Polygon. This constructor is used when a new shape is created.
+     *
+     * @param parent    the parent of this Shape. For example, if this text box is a cell
+     * in a table then the parent is Table.
+     */
+    public Polygon(Shape parent){
+        super(null, parent);
+        _escherContainer = createSpContainer(ShapeTypes.NotPrimitive, parent instanceof ShapeGroup);
+    }
+
+    /**
+     * Create a new Polygon. This constructor is used when a new shape is created.
+     *
+     */
+    public Polygon(){
+        this(null);
+    }
+
+    /**
+     * Set the polygon vertices
+     *
+     * @param xPoints
+     * @param yPoints
+     */
+    public void setPoints(float[] xPoints, float[] yPoints)
+    {
+        float right  = findBiggest(xPoints);
+        float bottom = findBiggest(yPoints);
+        float left   = findSmallest(xPoints);
+        float top    = findSmallest(yPoints);
+
+        EscherOptRecord opt = (EscherOptRecord)getEscherChild(_escherContainer, EscherOptRecord.RECORD_ID);
+        opt.addEscherProperty(new EscherSimpleProperty(EscherProperties.GEOMETRY__RIGHT, (int)((right - left)*POINT_DPI/MASTER_DPI)));
+        opt.addEscherProperty(new EscherSimpleProperty(EscherProperties.GEOMETRY__BOTTOM, (int)((bottom - top)*POINT_DPI/MASTER_DPI)));
+
+        for (int i = 0; i < xPoints.length; i++) {
+            xPoints[i] += -left;
+            yPoints[i] += -top;
+        }
+
+        int numpoints = xPoints.length;
+
+        EscherArrayProperty verticesProp = new EscherArrayProperty(EscherProperties.GEOMETRY__VERTICES, false, new byte[0] );
+        verticesProp.setNumberOfElementsInArray(numpoints+1);
+        verticesProp.setNumberOfElementsInMemory(numpoints+1);
+        verticesProp.setSizeOfElements(0xFFF0);
+        for (int i = 0; i < numpoints; i++)
+        {
+            byte[] data = new byte[4];
+            LittleEndian.putShort(data, 0, (short)(xPoints[i]*POINT_DPI/MASTER_DPI));
+            LittleEndian.putShort(data, 2, (short)(yPoints[i]*POINT_DPI/MASTER_DPI));
+            verticesProp.setElement(i, data);
+        }
+        byte[] data = new byte[4];
+        LittleEndian.putShort(data, 0, (short)(xPoints[0]*POINT_DPI/MASTER_DPI));
+        LittleEndian.putShort(data, 2, (short)(yPoints[0]*POINT_DPI/MASTER_DPI));
+        verticesProp.setElement(numpoints, data);
+        opt.addEscherProperty(verticesProp);
+
+        EscherArrayProperty segmentsProp = new EscherArrayProperty(EscherProperties.GEOMETRY__SEGMENTINFO, false, null );
+        segmentsProp.setSizeOfElements(0x0002);
+        segmentsProp.setNumberOfElementsInArray(numpoints * 2 + 4);
+        segmentsProp.setNumberOfElementsInMemory(numpoints * 2 + 4);
+        segmentsProp.setElement(0, new byte[] { (byte)0x00, (byte)0x40 } );
+        segmentsProp.setElement(1, new byte[] { (byte)0x00, (byte)0xAC } );
+        for (int i = 0; i < numpoints; i++)
+        {
+            segmentsProp.setElement(2 + i * 2, new byte[] { (byte)0x01, (byte)0x00 } );
+            segmentsProp.setElement(3 + i * 2, new byte[] { (byte)0x00, (byte)0xAC } );
+        }
+        segmentsProp.setElement(segmentsProp.getNumberOfElementsInArray() - 2, new byte[] { (byte)0x01, (byte)0x60 } );
+        segmentsProp.setElement(segmentsProp.getNumberOfElementsInArray() - 1, new byte[] { (byte)0x00, (byte)0x80 } );
+        opt.addEscherProperty(segmentsProp);
+
+        opt.sortProperties();
+    }
+
+    /**
+     * Set the polygon vertices
+     *
+     * @param points the polygon vertices
+     */
+      public void setPoints(Point2D[] points)
+     {
+        float[] xpoints = new float[points.length];
+        float[] ypoints = new float[points.length];
+        for (int i = 0; i < points.length; i++) {
+            xpoints[i] = (float)points[i].getX();
+            ypoints[i] = (float)points[i].getY();
+
+        }
+
+        setPoints(xpoints, ypoints);
+    }
+
+    private float findBiggest( float[] values )
+    {
+        float result = Float.MIN_VALUE;
+        for ( int i = 0; i < values.length; i++ )
+        {
+            if (values[i] > result)
+                result = values[i];
+        }
+        return result;
+    }
+
+    private float findSmallest( float[] values )
+    {
+        float result = Float.MAX_VALUE;
+        for ( int i = 0; i < values.length; i++ )
+        {
+            if (values[i] < result)
+                result = values[i];
+        }
+        return result;
+    }
+
+
+}

Modified: poi/trunk/src/scratchpad/src/org/apache/poi/hslf/model/Shape.java
URL: http://svn.apache.org/viewvc/poi/trunk/src/scratchpad/src/org/apache/poi/hslf/model/Shape.java?rev=777204&r1=777203&r2=777204&view=diff
==============================================================================
--- poi/trunk/src/scratchpad/src/org/apache/poi/hslf/model/Shape.java (original)
+++ poi/trunk/src/scratchpad/src/org/apache/poi/hslf/model/Shape.java Thu May 21 18:12:22 2009
@@ -14,6 +14,7 @@
    See the License for the specific language governing permissions and
    limitations under the License.
 ==================================================================== */
+
 package org.apache.poi.hslf.model;
 
 import org.apache.poi.ddf.*;

Modified: poi/trunk/src/scratchpad/src/org/apache/poi/hslf/model/ShapeFactory.java
URL: http://svn.apache.org/viewvc/poi/trunk/src/scratchpad/src/org/apache/poi/hslf/model/ShapeFactory.java?rev=777204&r1=777203&r2=777204&view=diff
==============================================================================
--- poi/trunk/src/scratchpad/src/org/apache/poi/hslf/model/ShapeFactory.java (original)
+++ poi/trunk/src/scratchpad/src/org/apache/poi/hslf/model/ShapeFactory.java Thu May 21 18:12:22 2009
@@ -14,6 +14,7 @@
    See the License for the specific language governing permissions and
    limitations under the License.
 ==================================================================== */
+
 package org.apache.poi.hslf.model;
 
 import org.apache.poi.ddf.*;
@@ -29,12 +30,12 @@
  *
  * @author Yegor Kozlov
  */
-public class ShapeFactory {
+public final class ShapeFactory {
     // For logging
     protected static POILogger logger = POILogFactory.getLogger(ShapeFactory.class);
 
     /**
-     * Create a new shape from the data provided.  
+     * Create a new shape from the data provided.
      */
     public static Shape createShape(EscherContainerRecord spContainer, Shape parent){
         if (spContainer.getRecordId() == EscherContainerRecord.SPGR_CONTAINER){
@@ -96,7 +97,7 @@
                 } else if (oes != null){
                     shape = new OLEShape(spContainer, parent);
                 }
-                
+
                 if(shape == null) shape = new Picture(spContainer, parent);
                 break;
             }

Modified: poi/trunk/src/scratchpad/src/org/apache/poi/hslf/model/ShapeGroup.java
URL: http://svn.apache.org/viewvc/poi/trunk/src/scratchpad/src/org/apache/poi/hslf/model/ShapeGroup.java?rev=777204&r1=777203&r2=777204&view=diff
==============================================================================
--- poi/trunk/src/scratchpad/src/org/apache/poi/hslf/model/ShapeGroup.java (original)
+++ poi/trunk/src/scratchpad/src/org/apache/poi/hslf/model/ShapeGroup.java Thu May 21 18:12:22 2009
@@ -86,7 +86,7 @@
         		logger.log(POILogger.ERROR, "Shape contained non container escher record, was " + r.getClass().getName());
         	}
         }
-        
+
         // Put the shapes into an array, and return
         Shape[] shapes = shapeList.toArray(new Shape[shapeList.size()]);
         return shapes;

Modified: poi/trunk/src/scratchpad/src/org/apache/poi/hslf/model/ShapeOutline.java
URL: http://svn.apache.org/viewvc/poi/trunk/src/scratchpad/src/org/apache/poi/hslf/model/ShapeOutline.java?rev=777204&r1=777203&r2=777204&view=diff
==============================================================================
--- poi/trunk/src/scratchpad/src/org/apache/poi/hslf/model/ShapeOutline.java (original)
+++ poi/trunk/src/scratchpad/src/org/apache/poi/hslf/model/ShapeOutline.java Thu May 21 18:12:22 2009
@@ -1,27 +1,28 @@
-/* ====================================================================
-   Licensed to the Apache Software Foundation (ASF) under one or more
-   contributor license agreements.  See the NOTICE file distributed with
-   this work for additional information regarding copyright ownership.
-   The ASF licenses this file to You under the Apache License, Version 2.0
-   (the "License"); you may not use this file except in compliance with
-   the License.  You may obtain a copy of the License at
-
-       http://www.apache.org/licenses/LICENSE-2.0
-
-   Unless required by applicable law or agreed to in writing, software
-   distributed under the License is distributed on an "AS IS" BASIS,
-   WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
-   See the License for the specific language governing permissions and
-   limitations under the License.
-==================================================================== */
-package org.apache.poi.hslf.model;
-
-/**
- * Date: Apr 17, 2008
- * 
- * @author Yegor Kozlov
- */
-public interface ShapeOutline {
-    java.awt.Shape getOutline(Shape shape);
-
-}
+/* ====================================================================
+   Licensed to the Apache Software Foundation (ASF) under one or more
+   contributor license agreements.  See the NOTICE file distributed with
+   this work for additional information regarding copyright ownership.
+   The ASF licenses this file to You under the Apache License, Version 2.0
+   (the "License"); you may not use this file except in compliance with
+   the License.  You may obtain a copy of the License at
+
+       http://www.apache.org/licenses/LICENSE-2.0
+
+   Unless required by applicable law or agreed to in writing, software
+   distributed under the License is distributed on an "AS IS" BASIS,
+   WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+   See the License for the specific language governing permissions and
+   limitations under the License.
+==================================================================== */
+
+package org.apache.poi.hslf.model;
+
+/**
+ * Date: Apr 17, 2008
+ *
+ * @author Yegor Kozlov
+ */
+public interface ShapeOutline {
+    java.awt.Shape getOutline(Shape shape);
+
+}

Modified: poi/trunk/src/scratchpad/src/org/apache/poi/hslf/model/ShapePainter.java
URL: http://svn.apache.org/viewvc/poi/trunk/src/scratchpad/src/org/apache/poi/hslf/model/ShapePainter.java?rev=777204&r1=777203&r2=777204&view=diff
==============================================================================
--- poi/trunk/src/scratchpad/src/org/apache/poi/hslf/model/ShapePainter.java (original)
+++ poi/trunk/src/scratchpad/src/org/apache/poi/hslf/model/ShapePainter.java Thu May 21 18:12:22 2009
@@ -1,102 +1,103 @@
-/* ====================================================================
-   Licensed to the Apache Software Foundation (ASF) under one or more
-   contributor license agreements.  See the NOTICE file distributed with
-   this work for additional information regarding copyright ownership.
-   The ASF licenses this file to You under the Apache License, Version 2.0
-   (the "License"); you may not use this file except in compliance with
-   the License.  You may obtain a copy of the License at
-
-       http://www.apache.org/licenses/LICENSE-2.0
-
-   Unless required by applicable law or agreed to in writing, software
-   distributed under the License is distributed on an "AS IS" BASIS,
-   WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
-   See the License for the specific language governing permissions and
-   limitations under the License.
-==================================================================== */
-package org.apache.poi.hslf.model;
-
-
-import org.apache.poi.util.POILogger;
-import org.apache.poi.util.POILogFactory;
-
-import java.awt.*;
-import java.awt.geom.Rectangle2D;
-
-/**
- * Paint a shape into java.awt.Graphics2D
- * 
- * @author Yegor Kozlov
- */
-public class ShapePainter {
-    protected static POILogger logger = POILogFactory.getLogger(ShapePainter.class);
-
-    public static void paint(SimpleShape shape, Graphics2D graphics){
-        Rectangle2D anchor = shape.getLogicalAnchor2D();
-        java.awt.Shape outline = shape.getOutline();
-
-        //flip vertical
-        if(shape.getFlipVertical()){
-            graphics.translate(anchor.getX(), anchor.getY() + anchor.getHeight());
-            graphics.scale(1, -1);
-            graphics.translate(-anchor.getX(), -anchor.getY());
-        }
-        //flip horizontal
-        if(shape.getFlipHorizontal()){
-            graphics.translate(anchor.getX() + anchor.getWidth(), anchor.getY());
-            graphics.scale(-1, 1);
-            graphics.translate(-anchor.getX() , -anchor.getY());
-        }
-
-        //rotate transform
-        double angle = shape.getRotation();
-
-        if(angle != 0){
-            double centerX = anchor.getX() + anchor.getWidth()/2;
-            double centerY = anchor.getY() + anchor.getHeight()/2;
-
-            graphics.translate(centerX, centerY);
-            graphics.rotate(Math.toRadians(angle));
-            graphics.translate(-centerX, -centerY);
-        }
-
-        //fill
-        Color fillColor = shape.getFill().getForegroundColor();
-        if (fillColor != null) {
-            //TODO: implement gradient and texture fill patterns
-            graphics.setPaint(fillColor);
-            graphics.fill(outline);
-        }
-
-        //border
-        Color lineColor = shape.getLineColor();
-        if (lineColor != null){
-            graphics.setPaint(lineColor);
-            float width = (float)shape.getLineWidth();
-            if(width == 0) width = 0.75f;
-
-            int dashing = shape.getLineDashing();
-            //TODO: implement more dashing styles
-            float[] dashptrn = null;
-            switch(dashing){
-                case Line.PEN_SOLID:
-                    dashptrn = null;
-                    break;
-                case Line.PEN_PS_DASH:
-                    dashptrn = new float[]{width, width};
-                    break;
-                case Line.PEN_DOTGEL:
-                    dashptrn = new float[]{width*4, width*3};
-                    break;
-               default:
-                    logger.log(POILogger.WARN, "unsupported dashing: " + dashing);
-                    dashptrn = new float[]{width, width};
-                    break;
-            }
-
-            Stroke stroke = new BasicStroke(width, BasicStroke.CAP_BUTT, BasicStroke.JOIN_MITER, 10.0f, dashptrn, 0.0f);
-            graphics.setStroke(stroke);
-            graphics.draw(outline);
-        }
-    }
-}
+/* ====================================================================
+   Licensed to the Apache Software Foundation (ASF) under one or more
+   contributor license agreements.  See the NOTICE file distributed with
+   this work for additional information regarding copyright ownership.
+   The ASF licenses this file to You under the Apache License, Version 2.0
+   (the "License"); you may not use this file except in compliance with
+   the License.  You may obtain a copy of the License at
+
+       http://www.apache.org/licenses/LICENSE-2.0
+
+   Unless required by applicable law or agreed to in writing, software
+   distributed under the License is distributed on an "AS IS" BASIS,
+   WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+   See the License for the specific language governing permissions and
+   limitations under the License.
+==================================================================== */
+
+package org.apache.poi.hslf.model;
+
+
+import org.apache.poi.util.POILogger;
+import org.apache.poi.util.POILogFactory;
+
+import java.awt.*;
+import java.awt.geom.Rectangle2D;
+
+/**
+ * Paint a shape into java.awt.Graphics2D
+ *
+ * @author Yegor Kozlov
+ */
+public final class ShapePainter {
+    protected static POILogger logger = POILogFactory.getLogger(ShapePainter.class);
+
+    public static void paint(SimpleShape shape, Graphics2D graphics){
+        Rectangle2D anchor = shape.getLogicalAnchor2D();
+        java.awt.Shape outline = shape.getOutline();
+
+        //flip vertical
+        if(shape.getFlipVertical()){
+            graphics.translate(anchor.getX(), anchor.getY() + anchor.getHeight());
+            graphics.scale(1, -1);
+            graphics.translate(-anchor.getX(), -anchor.getY());
+        }
+        //flip horizontal
+        if(shape.getFlipHorizontal()){
+            graphics.translate(anchor.getX() + anchor.getWidth(), anchor.getY());
+            graphics.scale(-1, 1);
+            graphics.translate(-anchor.getX() , -anchor.getY());
+        }
+
+        //rotate transform
+        double angle = shape.getRotation();
+
+        if(angle != 0){
+            double centerX = anchor.getX() + anchor.getWidth()/2;
+            double centerY = anchor.getY() + anchor.getHeight()/2;
+
+            graphics.translate(centerX, centerY);
+            graphics.rotate(Math.toRadians(angle));
+            graphics.translate(-centerX, -centerY);
+        }
+
+        //fill
+        Color fillColor = shape.getFill().getForegroundColor();
+        if (fillColor != null) {
+            //TODO: implement gradient and texture fill patterns
+            graphics.setPaint(fillColor);
+            graphics.fill(outline);
+        }
+
+        //border
+        Color lineColor = shape.getLineColor();
+        if (lineColor != null){
+            graphics.setPaint(lineColor);
+            float width = (float)shape.getLineWidth();
+            if(width == 0) width = 0.75f;
+
+            int dashing = shape.getLineDashing();
+            //TODO: implement more dashing styles
+            float[] dashptrn = null;
+            switch(dashing){
+                case Line.PEN_SOLID:
+                    dashptrn = null;
+                    break;
+                case Line.PEN_PS_DASH:
+                    dashptrn = new float[]{width, width};
+                    break;
+                case Line.PEN_DOTGEL:
+                    dashptrn = new float[]{width*4, width*3};
+                    break;
+               default:
+                    logger.log(POILogger.WARN, "unsupported dashing: " + dashing);
+                    dashptrn = new float[]{width, width};
+                    break;
+            }
+
+            Stroke stroke = new BasicStroke(width, BasicStroke.CAP_BUTT, BasicStroke.JOIN_MITER, 10.0f, dashptrn, 0.0f);
+            graphics.setStroke(stroke);
+            graphics.draw(outline);
+        }
+    }
+}

Modified: poi/trunk/src/scratchpad/src/org/apache/poi/hslf/model/ShapeTypes.java
URL: http://svn.apache.org/viewvc/poi/trunk/src/scratchpad/src/org/apache/poi/hslf/model/ShapeTypes.java?rev=777204&r1=777203&r2=777204&view=diff
==============================================================================
--- poi/trunk/src/scratchpad/src/org/apache/poi/hslf/model/ShapeTypes.java (original)
+++ poi/trunk/src/scratchpad/src/org/apache/poi/hslf/model/ShapeTypes.java Thu May 21 18:12:22 2009
@@ -14,6 +14,7 @@
    See the License for the specific language governing permissions and
    limitations under the License.
 ==================================================================== */
+
 package org.apache.poi.hslf.model;
 
 import org.apache.poi.hslf.exceptions.HSLFException;
@@ -26,7 +27,7 @@
  *
  * @author Yegor Kozlov
  */
-public class ShapeTypes implements org.apache.poi.sl.usermodel.ShapeTypes {
+public final class ShapeTypes implements org.apache.poi.sl.usermodel.ShapeTypes {
     /**
      * Return name of the shape by id
      * @param type  - the id of the shape, one of the static constants defined in this class

Modified: poi/trunk/src/scratchpad/src/org/apache/poi/hslf/model/Sheet.java
URL: http://svn.apache.org/viewvc/poi/trunk/src/scratchpad/src/org/apache/poi/hslf/model/Sheet.java?rev=777204&r1=777203&r2=777204&view=diff
==============================================================================
--- poi/trunk/src/scratchpad/src/org/apache/poi/hslf/model/Sheet.java (original)
+++ poi/trunk/src/scratchpad/src/org/apache/poi/hslf/model/Sheet.java Thu May 21 18:12:22 2009
@@ -15,7 +15,6 @@
    limitations under the License.
 ==================================================================== */
 
-
 package org.apache.poi.hslf.model;
 
 import org.apache.poi.ddf.*;
@@ -190,7 +189,7 @@
                     lst.toArray(recs);
                     trun._records = recs;
                     trun.setIndex(slwtIndex);
-                    
+
                     found.add(trun);
                     i++;
                 } else {
@@ -379,7 +378,7 @@
      * @param shape
      */
     protected void onAddTextShape(TextShape shape) {
-    
+
     }
 
     /**

Modified: poi/trunk/src/scratchpad/src/org/apache/poi/hslf/model/SimpleShape.java
URL: http://svn.apache.org/viewvc/poi/trunk/src/scratchpad/src/org/apache/poi/hslf/model/SimpleShape.java?rev=777204&r1=777203&r2=777204&view=diff
==============================================================================
--- poi/trunk/src/scratchpad/src/org/apache/poi/hslf/model/SimpleShape.java (original)
+++ poi/trunk/src/scratchpad/src/org/apache/poi/hslf/model/SimpleShape.java Thu May 21 18:12:22 2009
@@ -38,7 +38,7 @@
  *
  *  @author Yegor Kozlov
  */
-public class SimpleShape extends Shape {
+public abstract class SimpleShape extends Shape {
 
     /**
      * Records stored in EscherClientDataRecord

Modified: poi/trunk/src/scratchpad/src/org/apache/poi/hslf/model/Slide.java
URL: http://svn.apache.org/viewvc/poi/trunk/src/scratchpad/src/org/apache/poi/hslf/model/Slide.java?rev=777204&r1=777203&r2=777204&view=diff
==============================================================================
--- poi/trunk/src/scratchpad/src/org/apache/poi/hslf/model/Slide.java (original)
+++ poi/trunk/src/scratchpad/src/org/apache/poi/hslf/model/Slide.java Thu May 21 18:12:22 2009
@@ -1,4 +1,3 @@
-
 /* ====================================================================
    Licensed to the Apache Software Foundation (ASF) under one or more
    contributor license agreements.  See the NOTICE file distributed with
@@ -15,8 +14,6 @@
    See the License for the specific language governing permissions and
    limitations under the License.
 ==================================================================== */
-        
-
 
 package org.apache.poi.hslf.model;
 
@@ -32,7 +29,7 @@
 import org.apache.poi.ddf.EscherSpRecord;
 
 /**
- * This class represents a slide in a PowerPoint Document. It allows 
+ * This class represents a slide in a PowerPoint Document. It allows
  *  access to the text within, and the layout. For now, it only does
  *  the text side of things though
  *
@@ -40,7 +37,7 @@
  * @author Yegor Kozlov
  */
 
-public class Slide extends Sheet
+public final class Slide extends Sheet
 {
 	private int _slideNo;
 	private SlideAtomsSet _atomSet;
@@ -90,7 +87,7 @@
             _runs[i].setSheet(this);
 		}
 	}
-  
+
 	/**
 	* Create a new Slide instance
 	* @param sheetNumber The internal number of the sheet, as used by PersistPtrHolder
@@ -120,7 +117,7 @@
 			sa.setNotesID(notes._getSheetNumber());
 		}
 	}
-  
+
 	/**
 	* Changes the Slide's (external facing) page number.
 	* @see org.apache.poi.hslf.usermodel.SlideShow#reorderSlide(int, int)
@@ -128,7 +125,7 @@
 	public void setSlideNumber(int newSlideNumber) {
 		_slideNo = newSlideNumber;
 	}
-  
+
     /**
      * Called by SlideShow ater a new slide is created.
      * <p>
@@ -162,7 +159,7 @@
             if(spr != null) spr.setShapeId(allocateShapeId());
         }
 
-        //PPT doen't increment the number of saved shapes for group descriptor and background 
+        //PPT doen't increment the number of saved shapes for group descriptor and background
         dg.setNumShapes(1);
     }
 
@@ -207,7 +204,7 @@
 		}
 		return null;
 	}
-  
+
 	// Simple Accesser methods follow
 
 	/**
@@ -361,10 +358,10 @@
         }
         return super.getColorScheme();
     }
-    
+
     /**
      * Get the comment(s) for this slide.
-     * Note - for now, only works on PPT 2000 and 
+     * Note - for now, only works on PPT 2000 and
      *  PPT 2003 files. Doesn't work for PPT 97
      *  ones, as they do their comments oddly.
      */
@@ -393,7 +390,7 @@
     						count++;
     					}
     				}
-    				
+
     				// Now build
     				Comment[] comments = new Comment[count];
     				count = 0;
@@ -405,12 +402,12 @@
     						count++;
     					}
     				}
-    				
+
     				return comments;
     			}
     		}
     	}
-    	
+
     	// None found
     	return new Comment[0];
     }
@@ -433,7 +430,7 @@
     }
 
     /**
-     * Header / Footer settings for this slide.  
+     * Header / Footer settings for this slide.
      *
      * @return Header / Footer settings for this slide
      */

Modified: poi/trunk/src/scratchpad/src/org/apache/poi/hslf/model/SlideMaster.java
URL: http://svn.apache.org/viewvc/poi/trunk/src/scratchpad/src/org/apache/poi/hslf/model/SlideMaster.java?rev=777204&r1=777203&r2=777204&view=diff
==============================================================================
--- poi/trunk/src/scratchpad/src/org/apache/poi/hslf/model/SlideMaster.java (original)
+++ poi/trunk/src/scratchpad/src/org/apache/poi/hslf/model/SlideMaster.java Thu May 21 18:12:22 2009
@@ -29,7 +29,7 @@
  *
  * @author Yegor Kozlov
  */
-public class SlideMaster extends MasterSheet {
+public final class SlideMaster extends MasterSheet {
     private TextRun[] _runs;
 
     /**
@@ -64,7 +64,7 @@
 
     /**
      * Pickup a style attribute from the master.
-     * This is the "workhorse" which returns the default style attrubutes. 
+     * This is the "workhorse" which returns the default style attrubutes.
      */
     public TextProp getStyleAttribute(int txtype, int level, String name, boolean isCharacter) {
 
@@ -111,7 +111,7 @@
     /**
      * Assign SlideShow for this slide master.
      * (Used interanlly)
-     */ 
+     */
     public void setSlideShow(SlideShow ss) {
         super.setSlideShow(ss);
 

Modified: poi/trunk/src/scratchpad/src/org/apache/poi/hslf/model/Table.java
URL: http://svn.apache.org/viewvc/poi/trunk/src/scratchpad/src/org/apache/poi/hslf/model/Table.java?rev=777204&r1=777203&r2=777204&view=diff
==============================================================================
--- poi/trunk/src/scratchpad/src/org/apache/poi/hslf/model/Table.java (original)
+++ poi/trunk/src/scratchpad/src/org/apache/poi/hslf/model/Table.java Thu May 21 18:12:22 2009
@@ -1,343 +1,343 @@
-
-/* ====================================================================
-   Licensed to the Apache Software Foundation (ASF) under one or more
-   contributor license agreements.  See the NOTICE file distributed with
-   this work for additional information regarding copyright ownership.
-   The ASF licenses this file to You under the Apache License, Version 2.0
-   (the "License"); you may not use this file except in compliance with
-   the License.  You may obtain a copy of the License at
-
-       http://www.apache.org/licenses/LICENSE-2.0
-
-   Unless required by applicable law or agreed to in writing, software
-   distributed under the License is distributed on an "AS IS" BASIS,
-   WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
-   See the License for the specific language governing permissions and
-   limitations under the License.
-==================================================================== */
-package org.apache.poi.hslf.model;
-
-import org.apache.poi.ddf.*;
-import org.apache.poi.util.LittleEndian;
-
-import java.util.*;
-import java.util.List;
-import java.awt.*;
-
-/**
- * Represents a table in a PowerPoint presentation
- * 
- * @author Yegor Kozlov
- */
-public class Table extends ShapeGroup {
-
-    protected static final int BORDER_TOP = 1;
-    protected static final int BORDER_RIGHT = 2;
-    protected static final int BORDER_BOTTOM = 3;
-    protected static final int BORDER_LEFT = 4;
-
-    protected static final int BORDERS_ALL = 5;
-    protected static final int BORDERS_OUTSIDE = 6;
-    protected static final int BORDERS_INSIDE = 7;
-    protected static final int BORDERS_NONE = 8;
-
-
-    protected TableCell[][] cells;
-
-    /**
-     * Create a new Table of the given number of rows and columns
-     *
-     * @param numrows the number of rows
-     * @param numcols the number of columns
-     */
-    public Table(int numrows, int numcols) {
-        super();
-
-        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 TableCell[numrows][numcols];
-        for (int i = 0; i < cells.length; i++) {
-            x = 0;
-            for (int j = 0; j < cells[i].length; j++) {
-                cells[i][j] = new TableCell(this);
-                Rectangle anchor = new Rectangle(x, y, TableCell.DEFAULT_WIDTH, TableCell.DEFAULT_HEIGHT);
-                cells[i][j].setAnchor(anchor);
-                x += TableCell.DEFAULT_WIDTH;
-            }
-            y += TableCell.DEFAULT_HEIGHT;
-        }
-        tblWidth = x;
-        tblHeight = y;
-        setAnchor(new Rectangle(0, 0, tblWidth, tblHeight));
-
-        EscherContainerRecord spCont = (EscherContainerRecord) getSpContainer().getChild(0);
-        EscherOptRecord opt = new EscherOptRecord();
-        opt.setRecordId((short)0xF122);
-        opt.addEscherProperty(new EscherSimpleProperty((short)0x39F, 1));
-        EscherArrayProperty p = new EscherArrayProperty((short)0x43A0, false, null);
-        p.setSizeOfElements(0x0004);
-        p.setNumberOfElementsInArray(numrows);
-        p.setNumberOfElementsInMemory(numrows);
-        opt.addEscherProperty(p);
-        List<EscherRecord> lst = spCont.getChildRecords();
-        lst.add(lst.size()-1, opt);
-        spCont.setChildRecords(lst);
-    }
-
-    /**
-     * Create a Table object and initilize 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
-     */
-    public Table(EscherContainerRecord escherRecord, Shape parent) {
-        super(escherRecord, parent);
-    }
-
-    /**
-     * Gets a cell
-     *
-     * @param row the row index (0-based)
-     * @param col the column index (0-based)
-     * @return the cell
-     */
-    public TableCell getCell(int row, int col) {
-        return cells[row][col];
-    }
-
-    public int getNumberOfColumns() {
-        return cells[0].length;
-    }
-    public int getNumberOfRows() {
-        return cells.length;
-    }
-
-    protected void afterInsert(Sheet sh){
-        super.afterInsert(sh);
-
-        EscherContainerRecord spCont = (EscherContainerRecord) getSpContainer().getChild(0);
-        List<EscherRecord> lst = spCont.getChildRecords();
-        EscherOptRecord opt = (EscherOptRecord)lst.get(lst.size()-2);
-        EscherArrayProperty p = (EscherArrayProperty)opt.getEscherProperty(1);
-        for (int i = 0; i < cells.length; i++) {
-            TableCell cell = cells[i][0];
-            int rowHeight = cell.getAnchor().height*MASTER_DPI/POINT_DPI;
-            byte[] val = new byte[4];
-            LittleEndian.putInt(val, rowHeight);
-            p.setElement(i, val);
-            for (int j = 0; j < cells[i].length; j++) {
-                TableCell c = cells[i][j];
-                addShape(c);
-
-                Line bt = c.getBorderTop();
-                if(bt != null) addShape(bt);
-
-                Line br = c.getBorderRight();
-                if(br != null) addShape(br);
-
-                Line bb = c.getBorderBottom();
-                if(bb != null) addShape(bb);
-
-                Line bl = c.getBorderLeft();
-                if(bl != null) addShape(bl);
-
-            }
-        }
-
-    }
-
-    protected void initTable(){
-        Shape[] sh = getShapes();
-        Arrays.sort(sh, new Comparator(){
-            public int compare( Object o1, Object o2 ) {
-                Rectangle anchor1 = ((Shape)o1).getAnchor();
-                Rectangle anchor2 = ((Shape)o2).getAnchor();
-                int delta = anchor1.y - anchor2.y;
-                if(delta == 0) delta = anchor1.x - anchor2.y;
-                return delta;
-            }
-        });
-        int y0 = -1;
-        int maxrowlen = 0;
-        ArrayList lst = new ArrayList();
-        ArrayList row = null;
-        for (int i = 0; i < sh.length; i++) {
-            if(sh[i] instanceof TextShape){
-                Rectangle anchor = sh[i].getAnchor();
-                if(anchor.y != y0){
-                    y0 = anchor.y;
-                    row = new ArrayList();
-                    lst.add(row);
-                }
-                row.add(sh[i]);
-                maxrowlen = Math.max(maxrowlen, row.size());
-            }
-        }
-        cells = new TableCell[lst.size()][maxrowlen];
-        for (int i = 0; i < lst.size(); i++) {
-            row = (ArrayList)lst.get(i);
-            for (int j = 0; j < row.size(); j++) {
-                TextShape tx = (TextShape)row.get(j);
-                cells[i][j] = new TableCell(tx.getSpContainer(), getParent());
-                cells[i][j].setSheet(tx.getSheet());
-            }
-        }
-    }
-
-    /**
-     * Assign the <code>SlideShow</code> this shape belongs to
-     *
-     * @param sheet owner of this shape
-     */
-    public void setSheet(Sheet sheet){
-        super.setSheet(sheet);
-        if(cells == null) initTable();
-    }
-
-    /**
-     * Sets the row height.
-     *
-     * @param row the row index (0-based)
-     * @param height the height to set (in pixels)
-     */
-    public void setRowHeight(int row, int height){
-        int currentHeight = cells[row][0].getAnchor().height;
-        int dy = height - currentHeight;
-
-        for (int i = row; i < cells.length; i++) {
-            for (int j = 0; j < cells[i].length; j++) {
-                Rectangle anchor = cells[i][j].getAnchor();
-                if(i == row) anchor.height = height;
-                else anchor.y += dy;
-                cells[i][j].setAnchor(anchor);
-            }
-        }
-        Rectangle tblanchor = getAnchor();
-        tblanchor.height += dy;
-        setAnchor(tblanchor);
-
-    }
-
-    /**
-     * Sets the column width.
-     *
-     * @param col the column index (0-based)
-     * @param width the width to set (in pixels)
-     */
-    public void setColumnWidth(int col, int width){
-        int currentWidth = cells[0][col].getAnchor().width;
-        int dx = width - currentWidth;
-        for (int i = 0; i < cells.length; i++) {
-            Rectangle anchor = cells[i][col].getAnchor();
-            anchor.width = width;
-            cells[i][col].setAnchor(anchor);
-
-            if(col < cells[i].length - 1) for (int j = col+1; j < cells[i].length; j++) {
-                anchor = cells[i][j].getAnchor();
-                anchor.x += dx;
-                cells[i][j].setAnchor(anchor);
-            }
-        }
-        Rectangle tblanchor = getAnchor();
-        tblanchor.width += dx;
-        setAnchor(tblanchor);
-    }
-
-    /**
-     * Format the table and apply the specified Line to all cell boundaries,
-     * both outside and inside
-     *
-     * @param line the border line
-     */
-    public void setAllBorders(Line line){
-        for (int i = 0; i < cells.length; i++) {
-            for (int j = 0; j < cells[i].length; j++) {
-                TableCell cell = cells[i][j];
-                cell.setBorderTop(cloneBorder(line));
-                cell.setBorderLeft(cloneBorder(line));
-                if(j == cells[i].length - 1) cell.setBorderRight(cloneBorder(line));
-                if(i == cells.length - 1) cell.setBorderBottom(cloneBorder(line));
-            }
-        }
-    }
-
-    /**
-     * Format the outside border using the specified Line object
-     *
-     * @param line the border line
-     */
-    public void setOutsideBorders(Line line){
-        for (int i = 0; i < cells.length; i++) {
-            for (int j = 0; j < cells[i].length; j++) {
-                TableCell cell = cells[i][j];
-
-                if(j == 0) cell.setBorderLeft(cloneBorder(line));
-                if(j == cells[i].length - 1) cell.setBorderRight(cloneBorder(line));
-                else {
-                    cell.setBorderLeft(null);
-                    cell.setBorderLeft(null);
-                }
-
-                if(i == 0) cell.setBorderTop(cloneBorder(line));
-                else if(i == cells.length - 1) cell.setBorderBottom(cloneBorder(line));
-                else {
-                    cell.setBorderTop(null);
-                    cell.setBorderBottom(null);
-                }
-            }
-        }
-    }
-
-    /**
-     * Format the inside border using the specified Line object
-     *
-     * @param line the border line
-     */
-    public void setInsideBorders(Line line){
-        for (int i = 0; i < cells.length; i++) {
-            for (int j = 0; j < cells[i].length; j++) {
-                TableCell cell = cells[i][j];
-
-                if(j != cells[i].length - 1)
-                    cell.setBorderRight(cloneBorder(line));
-                else {
-                    cell.setBorderLeft(null);
-                    cell.setBorderLeft(null);
-                }
-                if(i != cells.length - 1) cell.setBorderBottom(cloneBorder(line));
-                else {
-                    cell.setBorderTop(null);
-                    cell.setBorderBottom(null);
-                }
-            }
-        }
-    }
-
-    private Line cloneBorder(Line line){
-        Line border = createBorder();
-        border.setLineWidth(line.getLineWidth());
-        border.setLineStyle(line.getLineStyle());
-        border.setLineDashing(line.getLineDashing());
-        border.setLineColor(line.getLineColor());
-        return border;
-    }
-
-    /**
-     * Create a border to format this table
-     *
-     * @return the created border
-     */
-    public Line createBorder(){
-        Line line = new Line(this);
-
-        EscherOptRecord opt = (EscherOptRecord)getEscherChild(line.getSpContainer(), EscherOptRecord.RECORD_ID);
-        setEscherProperty(opt, EscherProperties.GEOMETRY__SHAPEPATH, -1);
-        setEscherProperty(opt, EscherProperties.GEOMETRY__FILLOK, -1);
-        setEscherProperty(opt, EscherProperties.SHADOWSTYLE__SHADOWOBSURED, 0x20000);
-        setEscherProperty(opt, EscherProperties.THREED__LIGHTFACE, 0x80000);
-
-        return line;
-    }
-}
+/* ====================================================================
+   Licensed to the Apache Software Foundation (ASF) under one or more
+   contributor license agreements.  See the NOTICE file distributed with
+   this work for additional information regarding copyright ownership.
+   The ASF licenses this file to You under the Apache License, Version 2.0
+   (the "License"); you may not use this file except in compliance with
+   the License.  You may obtain a copy of the License at
+
+       http://www.apache.org/licenses/LICENSE-2.0
+
+   Unless required by applicable law or agreed to in writing, software
+   distributed under the License is distributed on an "AS IS" BASIS,
+   WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+   See the License for the specific language governing permissions and
+   limitations under the License.
+==================================================================== */
+
+package org.apache.poi.hslf.model;
+
+import org.apache.poi.ddf.*;
+import org.apache.poi.util.LittleEndian;
+
+import java.util.*;
+import java.util.List;
+import java.awt.*;
+
+/**
+ * Represents a table in a PowerPoint presentation
+ *
+ * @author Yegor Kozlov
+ */
+public final class Table extends ShapeGroup {
+
+    protected static final int BORDER_TOP = 1;
+    protected static final int BORDER_RIGHT = 2;
+    protected static final int BORDER_BOTTOM = 3;
+    protected static final int BORDER_LEFT = 4;
+
+    protected static final int BORDERS_ALL = 5;
+    protected static final int BORDERS_OUTSIDE = 6;
+    protected static final int BORDERS_INSIDE = 7;
+    protected static final int BORDERS_NONE = 8;
+
+
+    protected TableCell[][] cells;
+
+    /**
+     * Create a new Table of the given number of rows and columns
+     *
+     * @param numrows the number of rows
+     * @param numcols the number of columns
+     */
+    public Table(int numrows, int numcols) {
+        super();
+
+        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 TableCell[numrows][numcols];
+        for (int i = 0; i < cells.length; i++) {
+            x = 0;
+            for (int j = 0; j < cells[i].length; j++) {
+                cells[i][j] = new TableCell(this);
+                Rectangle anchor = new Rectangle(x, y, TableCell.DEFAULT_WIDTH, TableCell.DEFAULT_HEIGHT);
+                cells[i][j].setAnchor(anchor);
+                x += TableCell.DEFAULT_WIDTH;
+            }
+            y += TableCell.DEFAULT_HEIGHT;
+        }
+        tblWidth = x;
+        tblHeight = y;
+        setAnchor(new Rectangle(0, 0, tblWidth, tblHeight));
+
+        EscherContainerRecord spCont = (EscherContainerRecord) getSpContainer().getChild(0);
+        EscherOptRecord opt = new EscherOptRecord();
+        opt.setRecordId((short)0xF122);
+        opt.addEscherProperty(new EscherSimpleProperty((short)0x39F, 1));
+        EscherArrayProperty p = new EscherArrayProperty((short)0x43A0, false, null);
+        p.setSizeOfElements(0x0004);
+        p.setNumberOfElementsInArray(numrows);
+        p.setNumberOfElementsInMemory(numrows);
+        opt.addEscherProperty(p);
+        List<EscherRecord> lst = spCont.getChildRecords();
+        lst.add(lst.size()-1, opt);
+        spCont.setChildRecords(lst);
+    }
+
+    /**
+     * Create a Table object and initilize 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
+     */
+    public Table(EscherContainerRecord escherRecord, Shape parent) {
+        super(escherRecord, parent);
+    }
+
+    /**
+     * Gets a cell
+     *
+     * @param row the row index (0-based)
+     * @param col the column index (0-based)
+     * @return the cell
+     */
+    public TableCell getCell(int row, int col) {
+        return cells[row][col];
+    }
+
+    public int getNumberOfColumns() {
+        return cells[0].length;
+    }
+    public int getNumberOfRows() {
+        return cells.length;
+    }
+
+    protected void afterInsert(Sheet sh){
+        super.afterInsert(sh);
+
+        EscherContainerRecord spCont = (EscherContainerRecord) getSpContainer().getChild(0);
+        List<EscherRecord> lst = spCont.getChildRecords();
+        EscherOptRecord opt = (EscherOptRecord)lst.get(lst.size()-2);
+        EscherArrayProperty p = (EscherArrayProperty)opt.getEscherProperty(1);
+        for (int i = 0; i < cells.length; i++) {
+            TableCell cell = cells[i][0];
+            int rowHeight = cell.getAnchor().height*MASTER_DPI/POINT_DPI;
+            byte[] val = new byte[4];
+            LittleEndian.putInt(val, rowHeight);
+            p.setElement(i, val);
+            for (int j = 0; j < cells[i].length; j++) {
+                TableCell c = cells[i][j];
+                addShape(c);
+
+                Line bt = c.getBorderTop();
+                if(bt != null) addShape(bt);
+
+                Line br = c.getBorderRight();
+                if(br != null) addShape(br);
+
+                Line bb = c.getBorderBottom();
+                if(bb != null) addShape(bb);
+
+                Line bl = c.getBorderLeft();
+                if(bl != null) addShape(bl);
+
+            }
+        }
+
+    }
+
+    protected void initTable(){
+        Shape[] sh = getShapes();
+        Arrays.sort(sh, new Comparator(){
+            public int compare( Object o1, Object o2 ) {
+                Rectangle anchor1 = ((Shape)o1).getAnchor();
+                Rectangle anchor2 = ((Shape)o2).getAnchor();
+                int delta = anchor1.y - anchor2.y;
+                if(delta == 0) delta = anchor1.x - anchor2.y;
+                return delta;
+            }
+        });
+        int y0 = -1;
+        int maxrowlen = 0;
+        ArrayList lst = new ArrayList();
+        ArrayList row = null;
+        for (int i = 0; i < sh.length; i++) {
+            if(sh[i] instanceof TextShape){
+                Rectangle anchor = sh[i].getAnchor();
+                if(anchor.y != y0){
+                    y0 = anchor.y;
+                    row = new ArrayList();
+                    lst.add(row);
+                }
+                row.add(sh[i]);
+                maxrowlen = Math.max(maxrowlen, row.size());
+            }
+        }
+        cells = new TableCell[lst.size()][maxrowlen];
+        for (int i = 0; i < lst.size(); i++) {
+            row = (ArrayList)lst.get(i);
+            for (int j = 0; j < row.size(); j++) {
+                TextShape tx = (TextShape)row.get(j);
+                cells[i][j] = new TableCell(tx.getSpContainer(), getParent());
+                cells[i][j].setSheet(tx.getSheet());
+            }
+        }
+    }
+
+    /**
+     * Assign the <code>SlideShow</code> this shape belongs to
+     *
+     * @param sheet owner of this shape
+     */
+    public void setSheet(Sheet sheet){
+        super.setSheet(sheet);
+        if(cells == null) initTable();
+    }
+
+    /**
+     * Sets the row height.
+     *
+     * @param row the row index (0-based)
+     * @param height the height to set (in pixels)
+     */
+    public void setRowHeight(int row, int height){
+        int currentHeight = cells[row][0].getAnchor().height;
+        int dy = height - currentHeight;
+
+        for (int i = row; i < cells.length; i++) {
+            for (int j = 0; j < cells[i].length; j++) {
+                Rectangle anchor = cells[i][j].getAnchor();
+                if(i == row) anchor.height = height;
+                else anchor.y += dy;
+                cells[i][j].setAnchor(anchor);
+            }
+        }
+        Rectangle tblanchor = getAnchor();
+        tblanchor.height += dy;
+        setAnchor(tblanchor);
+
+    }
+
+    /**
+     * Sets the column width.
+     *
+     * @param col the column index (0-based)
+     * @param width the width to set (in pixels)
+     */
+    public void setColumnWidth(int col, int width){
+        int currentWidth = cells[0][col].getAnchor().width;
+        int dx = width - currentWidth;
+        for (int i = 0; i < cells.length; i++) {
+            Rectangle anchor = cells[i][col].getAnchor();
+            anchor.width = width;
+            cells[i][col].setAnchor(anchor);
+
+            if(col < cells[i].length - 1) for (int j = col+1; j < cells[i].length; j++) {
+                anchor = cells[i][j].getAnchor();
+                anchor.x += dx;
+                cells[i][j].setAnchor(anchor);
+            }
+        }
+        Rectangle tblanchor = getAnchor();
+        tblanchor.width += dx;
+        setAnchor(tblanchor);
+    }
+
+    /**
+     * Format the table and apply the specified Line to all cell boundaries,
+     * both outside and inside
+     *
+     * @param line the border line
+     */
+    public void setAllBorders(Line line){
+        for (int i = 0; i < cells.length; i++) {
+            for (int j = 0; j < cells[i].length; j++) {
+                TableCell cell = cells[i][j];
+                cell.setBorderTop(cloneBorder(line));
+                cell.setBorderLeft(cloneBorder(line));
+                if(j == cells[i].length - 1) cell.setBorderRight(cloneBorder(line));
+                if(i == cells.length - 1) cell.setBorderBottom(cloneBorder(line));
+            }
+        }
+    }
+
+    /**
+     * Format the outside border using the specified Line object
+     *
+     * @param line the border line
+     */
+    public void setOutsideBorders(Line line){
+        for (int i = 0; i < cells.length; i++) {
+            for (int j = 0; j < cells[i].length; j++) {
+                TableCell cell = cells[i][j];
+
+                if(j == 0) cell.setBorderLeft(cloneBorder(line));
+                if(j == cells[i].length - 1) cell.setBorderRight(cloneBorder(line));
+                else {
+                    cell.setBorderLeft(null);
+                    cell.setBorderLeft(null);
+                }
+
+                if(i == 0) cell.setBorderTop(cloneBorder(line));
+                else if(i == cells.length - 1) cell.setBorderBottom(cloneBorder(line));
+                else {
+                    cell.setBorderTop(null);
+                    cell.setBorderBottom(null);
+                }
+            }
+        }
+    }
+
+    /**
+     * Format the inside border using the specified Line object
+     *
+     * @param line the border line
+     */
+    public void setInsideBorders(Line line){
+        for (int i = 0; i < cells.length; i++) {
+            for (int j = 0; j < cells[i].length; j++) {
+                TableCell cell = cells[i][j];
+
+                if(j != cells[i].length - 1)
+                    cell.setBorderRight(cloneBorder(line));
+                else {
+                    cell.setBorderLeft(null);
+                    cell.setBorderLeft(null);
+                }
+                if(i != cells.length - 1) cell.setBorderBottom(cloneBorder(line));
+                else {
+                    cell.setBorderTop(null);
+                    cell.setBorderBottom(null);
+                }
+            }
+        }
+    }
+
+    private Line cloneBorder(Line line){
+        Line border = createBorder();
+        border.setLineWidth(line.getLineWidth());
+        border.setLineStyle(line.getLineStyle());
+        border.setLineDashing(line.getLineDashing());
+        border.setLineColor(line.getLineColor());
+        return border;
+    }
+
+    /**
+     * Create a border to format this table
+     *
+     * @return the created border
+     */
+    public Line createBorder(){
+        Line line = new Line(this);
+
+        EscherOptRecord opt = (EscherOptRecord)getEscherChild(line.getSpContainer(), EscherOptRecord.RECORD_ID);
+        setEscherProperty(opt, EscherProperties.GEOMETRY__SHAPEPATH, -1);
+        setEscherProperty(opt, EscherProperties.GEOMETRY__FILLOK, -1);
+        setEscherProperty(opt, EscherProperties.SHADOWSTYLE__SHADOWOBSURED, 0x20000);
+        setEscherProperty(opt, EscherProperties.THREED__LIGHTFACE, 0x80000);
+
+        return line;
+    }
+}



---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@poi.apache.org
For additional commands, e-mail: commits-help@poi.apache.org


Mime
View raw message