You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@poi.apache.org by ni...@apache.org on 2008/04/23 18:49:32 UTC

svn commit: r650938 [2/2] - in /poi/branches/ooxml: ./ src/documentation/ src/documentation/content/xdocs/ src/documentation/content/xdocs/poifs/ src/documentation/content/xdocs/slideshow/ src/java/org/apache/poi/hssf/usermodel/ src/scratchpad/examples...

Modified: poi/branches/ooxml/src/scratchpad/src/org/apache/poi/hslf/model/TextShape.java
URL: http://svn.apache.org/viewvc/poi/branches/ooxml/src/scratchpad/src/org/apache/poi/hslf/model/TextShape.java?rev=650938&r1=650937&r2=650938&view=diff
==============================================================================
--- poi/branches/ooxml/src/scratchpad/src/org/apache/poi/hslf/model/TextShape.java (original)
+++ poi/branches/ooxml/src/scratchpad/src/org/apache/poi/hslf/model/TextShape.java Wed Apr 23 09:49:18 2008
@@ -184,6 +184,8 @@
      * @param sh the sheet we are adding to
      */
     protected void afterInsert(Sheet sh){
+        super.afterInsert(sh);
+
         EscherTextboxWrapper _txtbox = getEscherTextboxWrapper();
         if(_txtbox != null){
             PPDrawing ppdrawing = sh.getPPDrawing();
@@ -513,4 +515,12 @@
             }
         }
     }
+
+    public void draw(Graphics2D graphics){
+        AffineTransform at = graphics.getTransform();
+        ShapePainter.paint(this, graphics);
+        new TextPainter(this).paint(graphics);
+        graphics.setTransform(at);
+    }
+
 }

Modified: poi/branches/ooxml/src/scratchpad/src/org/apache/poi/hslf/record/ExOleObjStg.java
URL: http://svn.apache.org/viewvc/poi/branches/ooxml/src/scratchpad/src/org/apache/poi/hslf/record/ExOleObjStg.java?rev=650938&r1=650937&r2=650938&view=diff
==============================================================================
--- poi/branches/ooxml/src/scratchpad/src/org/apache/poi/hslf/record/ExOleObjStg.java (original)
+++ poi/branches/ooxml/src/scratchpad/src/org/apache/poi/hslf/record/ExOleObjStg.java Wed Apr 23 09:49:18 2008
@@ -30,7 +30,10 @@
  *
  * @author Daniel Noll
  */
-public class ExOleObjStg extends RecordAtom {
+public class ExOleObjStg extends RecordAtom implements PersistRecord {
+
+    private int _persistId; // Found from PersistPtrHolder
+
     /**
      * Record header.
      */
@@ -108,5 +111,20 @@
     public void writeOut(OutputStream out) throws IOException {
         out.write(_header);
         out.write(_data);
+    }
+
+    /**
+     * Fetch our sheet ID, as found from a PersistPtrHolder.
+     * Should match the RefId of our matching SlidePersistAtom
+     */
+    public int getPersistId() {
+        return _persistId;
+    }
+
+    /**
+     * Set our sheet ID, as found from a PersistPtrHolder
+     */
+    public void setPersistId(int id) {
+        _persistId = id;
     }
 }

Modified: poi/branches/ooxml/src/scratchpad/src/org/apache/poi/hslf/record/PPDrawingGroup.java
URL: http://svn.apache.org/viewvc/poi/branches/ooxml/src/scratchpad/src/org/apache/poi/hslf/record/PPDrawingGroup.java?rev=650938&r1=650937&r2=650938&view=diff
==============================================================================
--- poi/branches/ooxml/src/scratchpad/src/org/apache/poi/hslf/record/PPDrawingGroup.java (original)
+++ poi/branches/ooxml/src/scratchpad/src/org/apache/poi/hslf/record/PPDrawingGroup.java Wed Apr 23 09:49:18 2008
@@ -37,6 +37,8 @@
 
     private byte[] _header;
     private EscherContainerRecord dggContainer;
+    //cached dgg
+    private EscherDggRecord dgg;
 
     protected PPDrawingGroup(byte[] source, int start, int len) {
         // Get the header
@@ -115,5 +117,18 @@
 
     public EscherContainerRecord getDggContainer(){
         return dggContainer;
+    }
+
+    public EscherDggRecord getEscherDggRecord(){
+        if(dgg == null){
+            for(Iterator it = dggContainer.getChildRecords().iterator(); it.hasNext();){
+                EscherRecord r = (EscherRecord) it.next();
+                if(r instanceof EscherDggRecord){
+                    dgg = (EscherDggRecord)r;
+                    break;
+                }
+            }
+        }
+        return dgg;
     }
 }

Modified: poi/branches/ooxml/src/scratchpad/src/org/apache/poi/hslf/record/RecordTypes.java
URL: http://svn.apache.org/viewvc/poi/branches/ooxml/src/scratchpad/src/org/apache/poi/hslf/record/RecordTypes.java?rev=650938&r1=650937&r2=650938&view=diff
==============================================================================
--- poi/branches/ooxml/src/scratchpad/src/org/apache/poi/hslf/record/RecordTypes.java (original)
+++ poi/branches/ooxml/src/scratchpad/src/org/apache/poi/hslf/record/RecordTypes.java Wed Apr 23 09:49:18 2008
@@ -70,9 +70,10 @@
     public static final Type List = new Type(2000,null);
     public static final Type FontCollection = new Type(2005,FontCollection.class);
     public static final Type BookmarkCollection = new Type(2019,null);
+    public static final Type SoundCollection = new Type(2020,SoundCollection.class);
     public static final Type SoundCollAtom = new Type(2021,null);
-    public static final Type Sound = new Type(2022,null);
-    public static final Type SoundData = new Type(2023,null);
+    public static final Type Sound = new Type(2022,Sound.class);
+    public static final Type SoundData = new Type(2023,SoundData.class);
     public static final Type BookmarkSeedAtom = new Type(2025,null);
     public static final Type ColorSchemeAtom = new Type(2032,ColorSchemeAtom.class);
     public static final Type ExObjRefAtom = new Type(3009,null);

Modified: poi/branches/ooxml/src/scratchpad/src/org/apache/poi/hslf/record/StyleTextPropAtom.java
URL: http://svn.apache.org/viewvc/poi/branches/ooxml/src/scratchpad/src/org/apache/poi/hslf/record/StyleTextPropAtom.java?rev=650938&r1=650937&r2=650938&view=diff
==============================================================================
--- poi/branches/ooxml/src/scratchpad/src/org/apache/poi/hslf/record/StyleTextPropAtom.java (original)
+++ poi/branches/ooxml/src/scratchpad/src/org/apache/poi/hslf/record/StyleTextPropAtom.java Wed Apr 23 09:49:18 2008
@@ -150,7 +150,7 @@
                 new TextProp(2, 0x800000, "symbol"),
 				new TextProp(2, 0x20000, "font.size"),
 				new TextProp(4, 0x40000, "font.color"),
-				new TextProp(2, 0x80000, "offset"),
+				new TextProp(2, 0x80000, "superscript"),
 				new TextProp(2, 0x100000, "char_unknown_1"),
 				new TextProp(2, 0x1000000, "char_unknown_3"),
 				new TextProp(2, 0x2000000, "char_unknown_4"),

Modified: poi/branches/ooxml/src/scratchpad/src/org/apache/poi/hslf/usermodel/ObjectData.java
URL: http://svn.apache.org/viewvc/poi/branches/ooxml/src/scratchpad/src/org/apache/poi/hslf/usermodel/ObjectData.java?rev=650938&r1=650937&r2=650938&view=diff
==============================================================================
--- poi/branches/ooxml/src/scratchpad/src/org/apache/poi/hslf/usermodel/ObjectData.java (original)
+++ poi/branches/ooxml/src/scratchpad/src/org/apache/poi/hslf/usermodel/ObjectData.java Wed Apr 23 09:49:18 2008
@@ -48,4 +48,13 @@
     public InputStream getData() {
         return storage.getData();
     }
+
+    /**
+     * Return the record that contains the object data.
+     *
+     * @return the record that contains the object data.
+     */
+    public ExOleObjStg getExOleObjStg() {
+        return storage;
+    }
 }

Modified: poi/branches/ooxml/src/scratchpad/src/org/apache/poi/hslf/usermodel/RichTextRun.java
URL: http://svn.apache.org/viewvc/poi/branches/ooxml/src/scratchpad/src/org/apache/poi/hslf/usermodel/RichTextRun.java?rev=650938&r1=650937&r2=650938&view=diff
==============================================================================
--- poi/branches/ooxml/src/scratchpad/src/org/apache/poi/hslf/usermodel/RichTextRun.java (original)
+++ poi/branches/ooxml/src/scratchpad/src/org/apache/poi/hslf/usermodel/RichTextRun.java Wed Apr 23 09:49:18 2008
@@ -37,9 +37,6 @@
 /**
  * Represents a run of text, all with the same style
  * 
- * TODO: finish all the getters and setters to the
- *  font/character/paragraph properties (currently only
- *  has some of them) 
  */
 public class RichTextRun {
 	/** The TextRun we belong to */
@@ -125,7 +122,25 @@
 	public int getLength() {
 		return length;
 	}
-	
+
+    /**
+     * The beginning index, inclusive.
+     *
+     * @return the beginning index, inclusive.
+     */
+    public int getStartIndex(){
+        return startPos;
+    }
+
+    /**
+     *  The ending index, exclusive.
+     *
+     * @return the ending index, exclusive.
+     */
+    public int getEndIndex(){
+        return startPos + length;
+    }
+
 	/**
 	 * Fetch the text, in output suitable form
 	 */
@@ -313,35 +328,143 @@
 	
 	
 	// --------------- Friendly getters / setters on rich text properties -------
-	
+
+    /**
+     * Is the text bold?
+     */
 	public boolean isBold() {
 		return isCharFlagsTextPropVal(CharFlagsTextProp.BOLD_IDX);
 	}
+
+    /**
+     * Is the text bold?
+     */
 	public void setBold(boolean bold) {
 		setCharFlagsTextPropVal(CharFlagsTextProp.BOLD_IDX, bold);
 	}
 	
+    /**
+     * Is the text italic?
+     */
 	public boolean isItalic() {
 		return isCharFlagsTextPropVal(CharFlagsTextProp.ITALIC_IDX);
 	}
+
+    /**
+     * Is the text italic?
+     */
 	public void setItalic(boolean italic) {
 		setCharFlagsTextPropVal(CharFlagsTextProp.ITALIC_IDX, italic);
 	}
 	
+    /**
+     * Is the text underlined?
+     */
 	public boolean isUnderlined() {
 		return isCharFlagsTextPropVal(CharFlagsTextProp.UNDERLINE_IDX);
 	}
+
+    /**
+     * Is the text underlined?
+     */
 	public void setUnderlined(boolean underlined) {
 		setCharFlagsTextPropVal(CharFlagsTextProp.UNDERLINE_IDX, underlined);
 	}
-	
+
+    /**
+     * Does the text have a shadow?
+     */
+    public boolean isShadowed() {
+        return isCharFlagsTextPropVal(CharFlagsTextProp.SHADOW_IDX);
+    }
+
+    /**
+     * Does the text have a shadow?
+     */
+    public void setShadowed(boolean flag) {
+        setCharFlagsTextPropVal(CharFlagsTextProp.SHADOW_IDX, flag);
+    }
+
+    /**
+     * Is this text embossed?
+     */
+     public boolean isEmbossed() {
+        return isCharFlagsTextPropVal(CharFlagsTextProp.RELIEF_IDX);
+    }
+
+    /**
+     * Is this text embossed?
+     */
+     public void setEmbossed(boolean flag) {
+        setCharFlagsTextPropVal(CharFlagsTextProp.RELIEF_IDX, flag);
+    }
+
+    /**
+     * Gets the strikethrough flag
+     */
+    public boolean isStrikethrough() {
+        return isCharFlagsTextPropVal(CharFlagsTextProp.STRIKETHROUGH_IDX);
+    }
+
+    /**
+     * Sets the strikethrough flag
+     */
+    public void setStrikethrough(boolean flag) {
+        setCharFlagsTextPropVal(CharFlagsTextProp.STRIKETHROUGH_IDX, flag);
+    }
+
+    /**
+     * Gets the subscript/superscript option
+     *
+     * @return the percentage of the font size. If the value is positive, it is superscript, otherwise it is subscript
+     */
+	public int getSuperscript() {
+        int val = getCharTextPropVal("superscript");
+		return val == -1 ? 0 : val;
+	}
+
+    /**
+     * Sets the subscript/superscript option
+     *
+     * @param val the percentage of the font size. If the value is positive, it is superscript, otherwise it is subscript
+     */
+	public void setSuperscript(int val) {
+		setCharTextPropVal("superscript", val);
+	}
+
+    /**
+     * Gets the font size
+     */
 	public int getFontSize() {
 		return getCharTextPropVal("font.size");
 	}
+
+
+    /**
+     * Sets the font size
+     */
 	public void setFontSize(int fontSize) {
 		setCharTextPropVal("font.size", fontSize);
 	}
-	
+
+    /**
+     * Gets the font index
+     */
+	public int getFontIndex() {
+		return getCharTextPropVal("font.index");
+	}
+
+    /**
+     * Sets the font index
+     */
+	public void setFontIndex(int idx) {
+		setCharTextPropVal("font.index", idx);
+	}
+
+
+    /**
+     * Sets the font name to use
+     */
 	public void setFontName(String fontName) {
         if (slideShow == null) {
             //we can't set font since slideshow is not assigned yet
@@ -352,6 +475,10 @@
 		    setCharTextPropVal("font.index", fontIdx);
         }
 	}
+
+    /**
+     * Gets the font name
+     */
 	public String getFontName() {
         if (slideShow == null) {
             return _fontname;
@@ -368,12 +495,12 @@
 	 */
 	public Color getFontColor() {
         int rgb = getCharTextPropVal("font.color");
-        if (rgb >= 0x8000000) {
-            int idx = rgb % 0x8000000;
+
+        int cidx = rgb >> 24;
+        if (rgb % 0x1000000 == 0){
             ColorSchemeAtom ca = parentRun.getSheet().getColorScheme();
-            if(idx >= 0 && idx <= 7) rgb = ca.getColor(idx);
+            if(cidx >= 0 && cidx <= 7) rgb = ca.getColor(cidx);
         }
-
         Color tmp = new Color(rgb, true);
         return new Color(tmp.getBlue(), tmp.getGreen(), tmp.getRed());
 	}
@@ -427,7 +554,7 @@
     /**
      * Sets indentation level
      *
-     * @param level indentation level. Must be in the range [0, 5]
+     * @param level indentation level. Must be in the range [0, 4]
      */
     public void setIndentLevel(int level) {
         if(paragraphStyle != null ) paragraphStyle.setReservedField((short)level);
@@ -487,6 +614,133 @@
      */
     public int getTextOffset() {
         return getParaTextPropVal("text.offset")*Shape.POINT_DPI/Shape.MASTER_DPI;
+    }
+
+    /**
+     * Sets the bullet size
+     */
+    public void setBulletSize(int size) {
+        setParaTextPropVal("bullet.size", size);
+    }
+
+    /**
+     * Returns the bullet size
+     */
+    public int getBulletSize() {
+        return getParaTextPropVal("bullet.size");
+    }
+
+    /**
+     * Sets the bullet color
+     */
+    public void setBulletColor(Color color) {
+        int rgb = new Color(color.getBlue(), color.getGreen(), color.getRed(), 254).getRGB();
+        setParaTextPropVal("bullet.color", rgb);
+    }
+
+    /**
+     * Returns the bullet color
+     */
+    public Color getBulletColor() {
+        int rgb = getParaTextPropVal("bullet.color");
+        if(rgb == -1) return getFontColor();
+
+        int cidx = rgb >> 24;
+        if (rgb % 0x1000000 == 0){
+            ColorSchemeAtom ca = parentRun.getSheet().getColorScheme();
+            if(cidx >= 0 && cidx <= 7) rgb = ca.getColor(cidx);
+        }
+        Color tmp = new Color(rgb, true);
+        return new Color(tmp.getBlue(), tmp.getGreen(), tmp.getRed());
+    }
+
+    /**
+     * Sets the bullet font
+     */
+    public void setBulletFont(int idx) {
+        setParaTextPropVal("bullet.font", idx);
+    }
+
+    /**
+     * Returns the bullet font
+     */
+    public int getBulletFont() {
+        return getParaTextPropVal("bullet.font");
+    }
+
+    /**
+     * Sets the line spacing.
+     * <p>
+     * If linespacing >= 0, then linespacing is a percentage of normal line height.
+     * If linespacing < 0, the absolute value of linespacing is the spacing in master coordinates.
+     * </p>
+     */
+    public void setLineSpacing(int val) {
+        setParaTextPropVal("linespacing", val);
+    }
+
+    /**
+     * Returns the line spacing
+     * <p>
+     * If linespacing >= 0, then linespacing is a percentage of normal line height.
+     * If linespacing < 0, the absolute value of linespacing is the spacing in master coordinates.
+     * </p>
+     *
+     * @return the spacing between lines
+     */
+    public int getLineSpacing() {
+        int val = getParaTextPropVal("linespacing");
+        return val == -1 ? 0 : val;
+    }
+
+    /**
+     * Sets spacing before a paragraph.
+     * <p>
+     * If spacebefore >= 0, then spacebefore is a percentage of normal line height.
+     * If spacebefore < 0, the absolute value of spacebefore is the spacing in master coordinates.
+     * </p>
+     */
+    public void setSpaceBefore(int val) {
+        setParaTextPropVal("spacebefore", val);
+    }
+
+    /**
+     * Returns spacing before a paragraph
+     * <p>
+     * If spacebefore >= 0, then spacebefore is a percentage of normal line height.
+     * If spacebefore < 0, the absolute value of spacebefore is the spacing in master coordinates.
+     * </p>
+     *
+     * @return the spacing before a paragraph
+     */
+    public int getSpaceBefore() {
+        int val = getParaTextPropVal("spacebefore");
+        return val == -1 ? 0 : val;
+    }
+
+    /**
+     * Sets spacing after a paragraph.
+     * <p>
+     * If spaceafter >= 0, then spaceafter is a percentage of normal line height.
+     * If spaceafter < 0, the absolute value of spaceafter is the spacing in master coordinates.
+     * </p>
+     */
+    public void setSpaceAfter(int val) {
+        setParaTextPropVal("spaceafter", val);
+    }
+
+    /**
+     * Returns spacing after a paragraph
+     * <p>
+     * If spaceafter >= 0, then spaceafter is a percentage of normal line height.
+     * If spaceafter < 0, the absolute value of spaceafter is the spacing in master coordinates.
+     * </p>
+     *
+     * @return the spacing before a paragraph
+     */
+    public int getSpaceAfter() {
+        int val = getParaTextPropVal("spaceafter");
+        return val == -1 ? 0 : val;
     }
 	// --------------- Internal HSLF methods, not intended for end-user use! -------
 	

Modified: poi/branches/ooxml/src/scratchpad/src/org/apache/poi/hslf/usermodel/SlideShow.java
URL: http://svn.apache.org/viewvc/poi/branches/ooxml/src/scratchpad/src/org/apache/poi/hslf/usermodel/SlideShow.java?rev=650938&r1=650937&r2=650938&view=diff
==============================================================================
--- poi/branches/ooxml/src/scratchpad/src/org/apache/poi/hslf/usermodel/SlideShow.java (original)
+++ poi/branches/ooxml/src/scratchpad/src/org/apache/poi/hslf/usermodel/SlideShow.java Wed Apr 23 09:49:18 2008
@@ -487,7 +487,21 @@
 	public PictureData[] getPictureData() {
 		return _hslfSlideShow.getPictures();
 	}
-	
+
+    /**
+     * Returns the data of all the embedded OLE object in the SlideShow
+     */
+    public ObjectData[] getEmbeddedObjects() {
+        return _hslfSlideShow.getEmbeddedObjects();
+    }
+
+    /**
+     * Returns the data of all the embedded sounds in the SlideShow
+     */
+    public SoundData[] getSoundData() {
+        return SoundData.find(_documentRecord);
+    }
+
 	/**
 	 * Return the current page size
 	 */

Modified: poi/branches/ooxml/src/scratchpad/testcases/org/apache/poi/hslf/model/TestOleEmbedding.java
URL: http://svn.apache.org/viewvc/poi/branches/ooxml/src/scratchpad/testcases/org/apache/poi/hslf/model/TestOleEmbedding.java?rev=650938&r1=650937&r2=650938&view=diff
==============================================================================
--- poi/branches/ooxml/src/scratchpad/testcases/org/apache/poi/hslf/model/TestOleEmbedding.java (original)
+++ poi/branches/ooxml/src/scratchpad/testcases/org/apache/poi/hslf/model/TestOleEmbedding.java Wed Apr 23 09:49:18 2008
@@ -21,10 +21,19 @@
 package org.apache.poi.hslf.model;
 
 import java.io.*;
+import java.util.List;
+import java.util.ArrayList;
 
 import org.apache.poi.hslf.HSLFSlideShow;
 import org.apache.poi.hslf.usermodel.ObjectData;
 import org.apache.poi.hslf.usermodel.PictureData;
+import org.apache.poi.hslf.usermodel.SlideShow;
+import org.apache.poi.hssf.usermodel.HSSFWorkbook;
+import org.apache.poi.hssf.usermodel.HSSFSheet;
+import org.apache.poi.poifs.filesystem.POIFSFileSystem;
+import org.apache.poi.hwpf.HWPFDocument;
+import org.apache.poi.hwpf.usermodel.Range;
+import org.apache.poi.hwpf.usermodel.Paragraph;
 
 import junit.framework.TestCase;
 
@@ -58,5 +67,42 @@
         {
             slideShow.close();
         }
+    }
+
+    public void testOLEShape() throws Exception {
+        String dirname = System.getProperty("HSLF.testdata.path");
+        File file = new File(dirname, "ole2-embedding-2003.ppt");
+        FileInputStream is = new FileInputStream(file);
+        SlideShow ppt = new SlideShow(is);
+        is.close();
+
+        Slide slide = ppt.getSlides()[0];
+        Shape[] sh = slide.getShapes();
+        int cnt = 0;
+        for (int i = 0; i < sh.length; i++) {
+            if(sh[i] instanceof OLEShape){
+                cnt++;
+                OLEShape ole = (OLEShape)sh[i];
+                ObjectData data = ole.getObjectData();
+                if("Worksheet".equals(ole.getInstanceName())){
+                    //Voila! we created a workbook from the embedded OLE data
+                    HSSFWorkbook wb = new HSSFWorkbook(data.getData());
+                    HSSFSheet sheet = wb.getSheetAt(0);
+                    //verify we can access the xls data
+                    assertEquals(1, sheet.getRow(0).getCell((short)0).getNumericCellValue(), 0);
+                    assertEquals(1, sheet.getRow(1).getCell((short)0).getNumericCellValue(), 0);
+                    assertEquals(2, sheet.getRow(2).getCell((short)0).getNumericCellValue(), 0);
+                    assertEquals(3, sheet.getRow(3).getCell((short)0).getNumericCellValue(), 0);
+                    assertEquals(8, sheet.getRow(5).getCell((short)0).getNumericCellValue(), 0);
+                } else if ("Document".equals(ole.getInstanceName())){
+                    //creating a HWPF document 
+                    HWPFDocument doc = new HWPFDocument(data.getData());
+                    String txt = doc.getRange().getParagraph(0).text();
+                    assertEquals("OLE embedding is thoroughly unremarkable.\r", txt);
+                }
+            }
+
+        }
+        assertEquals("Expected 2 OLE shapes", 2, cnt);
     }
 }

Modified: poi/branches/ooxml/src/scratchpad/testcases/org/apache/poi/hslf/model/TestShapes.java
URL: http://svn.apache.org/viewvc/poi/branches/ooxml/src/scratchpad/testcases/org/apache/poi/hslf/model/TestShapes.java?rev=650938&r1=650937&r2=650938&view=diff
==============================================================================
--- poi/branches/ooxml/src/scratchpad/testcases/org/apache/poi/hslf/model/TestShapes.java (original)
+++ poi/branches/ooxml/src/scratchpad/testcases/org/apache/poi/hslf/model/TestShapes.java Wed Apr 23 09:49:18 2008
@@ -307,4 +307,22 @@
         sl = ppt.getSlides()[0];
         assertEquals("expected 0 shaped in " + file, 0, sl.getShapes().length);
     }
+
+    public void testShapeId() throws IOException {
+        SlideShow ppt = new SlideShow();
+        Slide slide = ppt.createSlide();
+        Shape shape;
+
+        shape = new Line();
+        assertEquals(0, shape.getShapeId());
+        slide.addShape(shape);
+        assertTrue(shape.getShapeId() > 0);
+
+        int shapeId = shape.getShapeId();
+
+        shape = new Line();
+        assertEquals(0, shape.getShapeId());
+        slide.addShape(shape);
+        assertEquals(shapeId + 1, shape.getShapeId());
+    }
 }

Modified: poi/branches/ooxml/src/scratchpad/testcases/org/apache/poi/hslf/usermodel/TestBugs.java
URL: http://svn.apache.org/viewvc/poi/branches/ooxml/src/scratchpad/testcases/org/apache/poi/hslf/usermodel/TestBugs.java?rev=650938&r1=650937&r2=650938&view=diff
==============================================================================
--- poi/branches/ooxml/src/scratchpad/testcases/org/apache/poi/hslf/usermodel/TestBugs.java (original)
+++ poi/branches/ooxml/src/scratchpad/testcases/org/apache/poi/hslf/usermodel/TestBugs.java Wed Apr 23 09:49:18 2008
@@ -360,4 +360,24 @@
 
         assertTrue("No Exceptions while reading file", true);
     }
+
+    /**
+     * Bug 41071: Will not extract text from Powerpoint TextBoxes
+     */
+    public void test41071() throws Exception {
+        FileInputStream is = new FileInputStream(new File(cwd, "41071.ppt"));
+        SlideShow ppt = new SlideShow(is);
+        is.close();
+
+        Slide slide = ppt.getSlides()[0];
+        Shape[] sh = slide.getShapes();
+        assertEquals(1, sh.length);
+        assertTrue(sh[0] instanceof TextShape);
+        TextShape tx = (TextShape)sh[0];
+        assertEquals("Fundera, planera och involvera.", tx.getTextRun().getText());
+
+        TextRun[] run = slide.getTextRuns();
+        assertEquals(1, run.length);
+        assertEquals("Fundera, planera och involvera.", run[0].getText());
+    }
 }

Modified: poi/branches/ooxml/src/scratchpad/testcases/org/apache/poi/hslf/usermodel/TestPictures.java
URL: http://svn.apache.org/viewvc/poi/branches/ooxml/src/scratchpad/testcases/org/apache/poi/hslf/usermodel/TestPictures.java?rev=650938&r1=650937&r2=650938&view=diff
==============================================================================
--- poi/branches/ooxml/src/scratchpad/testcases/org/apache/poi/hslf/usermodel/TestPictures.java (original)
+++ poi/branches/ooxml/src/scratchpad/testcases/org/apache/poi/hslf/usermodel/TestPictures.java Wed Apr 23 09:49:18 2008
@@ -437,4 +437,33 @@
         assertTrue(pdata instanceof WMF);
         assertEquals(Picture.WMF, pdata.getType());
 	}
+
+    public void testGetPictureName() throws Exception {
+        SlideShow ppt = new SlideShow(new HSLFSlideShow(new File(cwd, "ppt_with_png.ppt").getPath()));
+        Slide slide = ppt.getSlides()[0];
+
+        Picture p = (Picture)slide.getShapes()[0]; //the first slide contains JPEG
+        assertEquals("test", p.getPictureName());
+    }
+
+    public void testSetPictureName() throws Exception {
+        SlideShow ppt = new SlideShow();
+
+        Slide slide = ppt.createSlide();
+        File img = new File(cwd, "tomcat.png");
+        int idx = ppt.addPicture(img, Picture.PNG);
+        Picture pict = new Picture(idx);
+        pict.setPictureName("tomcat.png");
+        slide.addShape(pict);
+
+        //serialize and read again
+        ByteArrayOutputStream out = new ByteArrayOutputStream();
+        ppt.write(out);
+        out.close();
+
+        ppt = new SlideShow(new ByteArrayInputStream(out.toByteArray()));
+
+        Picture p = (Picture)ppt.getSlides()[0].getShapes()[0];
+        assertEquals("tomcat.png", p.getPictureName());
+    }
 }

Modified: poi/branches/ooxml/src/scratchpad/testcases/org/apache/poi/hslf/usermodel/TestSlideOrdering.java
URL: http://svn.apache.org/viewvc/poi/branches/ooxml/src/scratchpad/testcases/org/apache/poi/hslf/usermodel/TestSlideOrdering.java?rev=650938&r1=650937&r2=650938&view=diff
==============================================================================
--- poi/branches/ooxml/src/scratchpad/testcases/org/apache/poi/hslf/usermodel/TestSlideOrdering.java (original)
+++ poi/branches/ooxml/src/scratchpad/testcases/org/apache/poi/hslf/usermodel/TestSlideOrdering.java Wed Apr 23 09:49:18 2008
@@ -141,7 +141,7 @@
                     "ROMANCE: AN ANALYSIS",
                     "AGENDA",
                     "You are an important supplier of various items that I need",
-                    (char)0x0B + "Although The Psycho set back my relationship process, recovery is luckily enough under way",
+                    '\n' + "Although The Psycho set back my relationship process, recovery is luckily enough under way",
                     "Since the time that we seriously go out together, you rank highly among existing relationships",
                     "Although our personal interests are mostly compatible, the greatest gap exists in Sex and Shopping",
                     "Your physical characteristics are strong when compared with your competition",

Modified: poi/branches/ooxml/src/testcases/org/apache/poi/hssf/usermodel/TestBugs.java
URL: http://svn.apache.org/viewvc/poi/branches/ooxml/src/testcases/org/apache/poi/hssf/usermodel/TestBugs.java?rev=650938&r1=650937&r2=650938&view=diff
==============================================================================
--- poi/branches/ooxml/src/testcases/org/apache/poi/hssf/usermodel/TestBugs.java (original)
+++ poi/branches/ooxml/src/testcases/org/apache/poi/hssf/usermodel/TestBugs.java Wed Apr 23 09:49:18 2008
@@ -878,4 +878,15 @@
         }
         assertEquals(713, rowsSeen);
     }
+
+    /**
+     * Bug 28774: Excel will crash when opening xls-files with images.
+     */
+    public void test28774() {
+
+        HSSFWorkbook wb = openSample("28774.xls");
+        assertTrue("no errors reading sample xls", true);
+        writeOutAndReadBack(wb);
+        assertTrue("no errors writing sample xls", true);
+    }
 }

Modified: poi/branches/ooxml/src/testcases/org/apache/poi/hssf/usermodel/TestHSSFTextbox.java
URL: http://svn.apache.org/viewvc/poi/branches/ooxml/src/testcases/org/apache/poi/hssf/usermodel/TestHSSFTextbox.java?rev=650938&r1=650937&r2=650938&view=diff
==============================================================================
--- poi/branches/ooxml/src/testcases/org/apache/poi/hssf/usermodel/TestHSSFTextbox.java (original)
+++ poi/branches/ooxml/src/testcases/org/apache/poi/hssf/usermodel/TestHSSFTextbox.java Wed Apr 23 09:49:18 2008
@@ -49,4 +49,23 @@
         assertEquals(HSSFTextbox.VERTICAL_ALIGNMENT_CENTER, textbox.getVerticalAlignment());
     }
 
+    /**
+     * Excel requires at least one format run in HSSFTextbox.
+     * When inserting text make sure that if font is not set we must set the default one.
+     */
+    public void testSetDeafultTextFormat() {
+        HSSFWorkbook wb = new HSSFWorkbook();
+        HSSFSheet sheet = wb.createSheet();
+        HSSFPatriarch patriarch = sheet.createDrawingPatriarch();
+
+        HSSFTextbox textbox1 = patriarch.createTextbox(new HSSFClientAnchor(0,0,0,0,(short)1,1,(short)3,3));
+        HSSFRichTextString rt1 = new HSSFRichTextString("Hello, World!");
+        assertEquals(0, rt1.numFormattingRuns());
+        textbox1.setString(rt1);
+
+        HSSFRichTextString rt2 = textbox1.getString();
+        assertEquals(1, rt2.numFormattingRuns());
+        assertEquals(HSSFRichTextString.NO_FONT, rt2.getFontOfFormattingRun(0));
+    }
+
  }



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