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 [1/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...

Author: nick
Date: Wed Apr 23 09:49:18 2008
New Revision: 650938

URL: http://svn.apache.org/viewvc?rev=650938&view=rev
Log:
Merged revisions 638786-638802,638805-638811,638813-638814,638816-639230,639233-639241,639243-639253,639255-639486,639488-639601,639603-639835,639837-639917,639919-640056,640058-640710,640712-641156,641158-641184,641186-641795,641797-641798,641800-641933,641935-641963,641965-641966,641968-641995,641997-642230,642232-642562,642564-642565,642568-642570,642572-642573,642576-642736,642739-642877,642879,642881-642890,642892-642903,642905-642945,642947-643624,643626-643653,643655-643669,643671,643673-643830,643832-643833,643835-644342,644344-644472,644474-644508,644510-645347,645349-645351,645353-645559,645561-645565,645568-645951,645953-646193,646195-646311,646313-646404,646406-646665,646667-646853,646855-646869,646871-647151,647153-647185,647187-647277,647279-647566,647568-647573,647575,647578-647711,647714-647737,647739-647823,647825-648155,648157-648202,648204-648273,648275,648277-648302,648304-648333,648335-650914,650916-650920 via svnmerge from 
https://svn.apache.org:443/repos/asf/poi/trunk

........
  r648589 | yegor | 2008-04-16 08:47:16 +0100 (Wed, 16 Apr 2008) | 1 line
  
  bug #41071 is fixed in trunk. Added a unit test and resolved.
........
  r648623 | yegor | 2008-04-16 09:43:08 +0100 (Wed, 16 Apr 2008) | 1 line
  
  Rich text in HSSFTextbox must have at least one format run. Make sure it is so and apply th default fopnt if no formats were applied.
........
  r648624 | yegor | 2008-04-16 09:44:07 +0100 (Wed, 16 Apr 2008) | 1 line
  
  Misc improvements in Freeform shape
........
  r648674 | yegor | 2008-04-16 12:57:15 +0100 (Wed, 16 Apr 2008) | 1 line
  
  Support for getting OLE object data from slide show
........
  r649142 | yegor | 2008-04-17 16:06:01 +0100 (Thu, 17 Apr 2008) | 1 line
  
  added a unit test and closed bug #28774
........
  r649143 | yegor | 2008-04-17 16:08:03 +0100 (Thu, 17 Apr 2008) | 1 line
  
  initial support for rendering powerpoint slides into images
........
  r649145 | yegor | 2008-04-17 16:09:37 +0100 (Thu, 17 Apr 2008) | 1 line
  
  updated the list of changes
........
  r649557 | yegor | 2008-04-18 15:57:07 +0100 (Fri, 18 Apr 2008) | 1 line
  
  improved rendering of text
........
  r649796 | yegor | 2008-04-19 12:09:59 +0100 (Sat, 19 Apr 2008) | 1 line
  
  Support for getting embedded sounds from slide show
........
  r649797 | yegor | 2008-04-19 12:16:53 +0100 (Sat, 19 Apr 2008) | 1 line
  
  properly set shapeId for new shapes
........
  r649798 | yegor | 2008-04-19 12:17:37 +0100 (Sat, 19 Apr 2008) | 1 line
  
  misc improvements in slide rendering
........
  r649800 | yegor | 2008-04-19 12:52:36 +0100 (Sat, 19 Apr 2008) | 1 line
  
  updated the docs
........
  r649911 | yegor | 2008-04-20 12:17:48 +0100 (Sun, 20 Apr 2008) | 1 line
  
  more improvements in slide rendering
........
  r649914 | yegor | 2008-04-20 12:58:08 +0100 (Sun, 20 Apr 2008) | 1 line
  
  set version.id=3.0.3-beta1
........
  r650129 | yegor | 2008-04-21 13:51:47 +0100 (Mon, 21 Apr 2008) | 1 line
  
  more improvements in slide rendering
........
  r650130 | yegor | 2008-04-21 13:52:23 +0100 (Mon, 21 Apr 2008) | 1 line
  
  a couple of HSLF examples
........
  r650133 | yegor | 2008-04-21 14:10:33 +0100 (Mon, 21 Apr 2008) | 1 line
  
  update current version to 3.1-beta1
........
  r650138 | yegor | 2008-04-21 14:29:59 +0100 (Mon, 21 Apr 2008) | 1 line
  
  unfinished release guide. It would be nice to have a html version.
........
  r650139 | yegor | 2008-04-21 14:31:53 +0100 (Mon, 21 Apr 2008) | 1 line
  
  unfinished release guide. It would be nice to have a html version.
........

Added:
    poi/branches/ooxml/src/documentation/release-guide.txt
      - copied unchanged from r650139, poi/trunk/src/documentation/release-guide.txt
    poi/branches/ooxml/src/scratchpad/examples/src/org/apache/poi/hslf/examples/DataExtraction.java
      - copied unchanged from r650139, poi/trunk/src/scratchpad/examples/src/org/apache/poi/hslf/examples/DataExtraction.java
    poi/branches/ooxml/src/scratchpad/examples/src/org/apache/poi/hslf/examples/Graphics2DDemo.java
      - copied unchanged from r650139, poi/trunk/src/scratchpad/examples/src/org/apache/poi/hslf/examples/Graphics2DDemo.java
    poi/branches/ooxml/src/scratchpad/examples/src/org/apache/poi/hslf/examples/PPT2PNG.java
      - copied unchanged from r650139, poi/trunk/src/scratchpad/examples/src/org/apache/poi/hslf/examples/PPT2PNG.java
    poi/branches/ooxml/src/scratchpad/src/org/apache/poi/hslf/model/AutoShapes.java
      - copied unchanged from r650139, poi/trunk/src/scratchpad/src/org/apache/poi/hslf/model/AutoShapes.java
    poi/branches/ooxml/src/scratchpad/src/org/apache/poi/hslf/model/OLEShape.java
      - copied unchanged from r650139, poi/trunk/src/scratchpad/src/org/apache/poi/hslf/model/OLEShape.java
    poi/branches/ooxml/src/scratchpad/src/org/apache/poi/hslf/model/ShapeOutline.java
      - copied unchanged from r650139, poi/trunk/src/scratchpad/src/org/apache/poi/hslf/model/ShapeOutline.java
    poi/branches/ooxml/src/scratchpad/src/org/apache/poi/hslf/model/ShapePainter.java
      - copied unchanged from r650139, poi/trunk/src/scratchpad/src/org/apache/poi/hslf/model/ShapePainter.java
    poi/branches/ooxml/src/scratchpad/src/org/apache/poi/hslf/model/TextPainter.java
      - copied unchanged from r650139, poi/trunk/src/scratchpad/src/org/apache/poi/hslf/model/TextPainter.java
    poi/branches/ooxml/src/scratchpad/src/org/apache/poi/hslf/record/PersistRecord.java
      - copied unchanged from r650139, poi/trunk/src/scratchpad/src/org/apache/poi/hslf/record/PersistRecord.java
    poi/branches/ooxml/src/scratchpad/src/org/apache/poi/hslf/record/Sound.java
      - copied unchanged from r650139, poi/trunk/src/scratchpad/src/org/apache/poi/hslf/record/Sound.java
    poi/branches/ooxml/src/scratchpad/src/org/apache/poi/hslf/record/SoundCollection.java
      - copied unchanged from r650139, poi/trunk/src/scratchpad/src/org/apache/poi/hslf/record/SoundCollection.java
    poi/branches/ooxml/src/scratchpad/src/org/apache/poi/hslf/record/SoundData.java
      - copied unchanged from r650139, poi/trunk/src/scratchpad/src/org/apache/poi/hslf/record/SoundData.java
    poi/branches/ooxml/src/scratchpad/src/org/apache/poi/hslf/usermodel/SoundData.java
      - copied unchanged from r650139, poi/trunk/src/scratchpad/src/org/apache/poi/hslf/usermodel/SoundData.java
    poi/branches/ooxml/src/scratchpad/testcases/org/apache/poi/hslf/data/41071.ppt
      - copied unchanged from r650139, poi/trunk/src/scratchpad/testcases/org/apache/poi/hslf/data/41071.ppt
    poi/branches/ooxml/src/scratchpad/testcases/org/apache/poi/hslf/data/ringin.wav
      - copied unchanged from r650139, poi/trunk/src/scratchpad/testcases/org/apache/poi/hslf/data/ringin.wav
    poi/branches/ooxml/src/scratchpad/testcases/org/apache/poi/hslf/data/sound.ppt
      - copied unchanged from r650139, poi/trunk/src/scratchpad/testcases/org/apache/poi/hslf/data/sound.ppt
    poi/branches/ooxml/src/scratchpad/testcases/org/apache/poi/hslf/model/TestFreeform.java
      - copied unchanged from r650139, poi/trunk/src/scratchpad/testcases/org/apache/poi/hslf/model/TestFreeform.java
    poi/branches/ooxml/src/scratchpad/testcases/org/apache/poi/hslf/record/TestSound.java
      - copied unchanged from r650139, poi/trunk/src/scratchpad/testcases/org/apache/poi/hslf/record/TestSound.java
    poi/branches/ooxml/src/scratchpad/testcases/org/apache/poi/hslf/usermodel/TestSoundData.java
      - copied unchanged from r650139, poi/trunk/src/scratchpad/testcases/org/apache/poi/hslf/usermodel/TestSoundData.java
    poi/branches/ooxml/src/testcases/org/apache/poi/hssf/data/28774.xls
      - copied unchanged from r650139, poi/trunk/src/testcases/org/apache/poi/hssf/data/28774.xls
Modified:
    poi/branches/ooxml/   (props changed)
    poi/branches/ooxml/src/documentation/content/xdocs/changes.xml
    poi/branches/ooxml/src/documentation/content/xdocs/index.xml
    poi/branches/ooxml/src/documentation/content/xdocs/poifs/embeded.xml
    poi/branches/ooxml/src/documentation/content/xdocs/slideshow/how-to-shapes.xml
    poi/branches/ooxml/src/documentation/content/xdocs/slideshow/index.xml
    poi/branches/ooxml/src/documentation/content/xdocs/status.xml
    poi/branches/ooxml/src/java/org/apache/poi/hssf/usermodel/HSSFTextbox.java
    poi/branches/ooxml/src/scratchpad/src/org/apache/poi/hslf/HSLFSlideShow.java
    poi/branches/ooxml/src/scratchpad/src/org/apache/poi/hslf/model/AutoShape.java
    poi/branches/ooxml/src/scratchpad/src/org/apache/poi/hslf/model/Background.java
    poi/branches/ooxml/src/scratchpad/src/org/apache/poi/hslf/model/Fill.java
    poi/branches/ooxml/src/scratchpad/src/org/apache/poi/hslf/model/Freeform.java
    poi/branches/ooxml/src/scratchpad/src/org/apache/poi/hslf/model/Line.java
    poi/branches/ooxml/src/scratchpad/src/org/apache/poi/hslf/model/MasterSheet.java
    poi/branches/ooxml/src/scratchpad/src/org/apache/poi/hslf/model/PPGraphics2D.java
    poi/branches/ooxml/src/scratchpad/src/org/apache/poi/hslf/model/Picture.java
    poi/branches/ooxml/src/scratchpad/src/org/apache/poi/hslf/model/Shape.java
    poi/branches/ooxml/src/scratchpad/src/org/apache/poi/hslf/model/ShapeFactory.java
    poi/branches/ooxml/src/scratchpad/src/org/apache/poi/hslf/model/ShapeGroup.java
    poi/branches/ooxml/src/scratchpad/src/org/apache/poi/hslf/model/Sheet.java
    poi/branches/ooxml/src/scratchpad/src/org/apache/poi/hslf/model/SimpleShape.java
    poi/branches/ooxml/src/scratchpad/src/org/apache/poi/hslf/model/Slide.java
    poi/branches/ooxml/src/scratchpad/src/org/apache/poi/hslf/model/SlideMaster.java
    poi/branches/ooxml/src/scratchpad/src/org/apache/poi/hslf/model/Table.java
    poi/branches/ooxml/src/scratchpad/src/org/apache/poi/hslf/model/TableCell.java
    poi/branches/ooxml/src/scratchpad/src/org/apache/poi/hslf/model/TextBox.java
    poi/branches/ooxml/src/scratchpad/src/org/apache/poi/hslf/model/TextRun.java
    poi/branches/ooxml/src/scratchpad/src/org/apache/poi/hslf/model/TextShape.java
    poi/branches/ooxml/src/scratchpad/src/org/apache/poi/hslf/record/ExOleObjStg.java
    poi/branches/ooxml/src/scratchpad/src/org/apache/poi/hslf/record/PPDrawingGroup.java
    poi/branches/ooxml/src/scratchpad/src/org/apache/poi/hslf/record/RecordTypes.java
    poi/branches/ooxml/src/scratchpad/src/org/apache/poi/hslf/record/StyleTextPropAtom.java
    poi/branches/ooxml/src/scratchpad/src/org/apache/poi/hslf/usermodel/ObjectData.java
    poi/branches/ooxml/src/scratchpad/src/org/apache/poi/hslf/usermodel/RichTextRun.java
    poi/branches/ooxml/src/scratchpad/src/org/apache/poi/hslf/usermodel/SlideShow.java
    poi/branches/ooxml/src/scratchpad/testcases/org/apache/poi/hslf/model/TestOleEmbedding.java
    poi/branches/ooxml/src/scratchpad/testcases/org/apache/poi/hslf/model/TestShapes.java
    poi/branches/ooxml/src/scratchpad/testcases/org/apache/poi/hslf/usermodel/TestBugs.java
    poi/branches/ooxml/src/scratchpad/testcases/org/apache/poi/hslf/usermodel/TestPictures.java
    poi/branches/ooxml/src/scratchpad/testcases/org/apache/poi/hslf/usermodel/TestSlideOrdering.java
    poi/branches/ooxml/src/testcases/org/apache/poi/hssf/usermodel/TestBugs.java
    poi/branches/ooxml/src/testcases/org/apache/poi/hssf/usermodel/TestHSSFTextbox.java

Propchange: poi/branches/ooxml/
------------------------------------------------------------------------------
--- svnmerge-integrated (original)
+++ svnmerge-integrated Wed Apr 23 09:49:18 2008
@@ -1 +1 @@
-/poi/trunk:1-638784,638786-639486,639488-639601,639603-640056,640058-642562,642564-642566,642568-642574,642576-642736,642739-648417
+/poi/trunk:1-638784,638786-639486,639488-639601,639603-640056,640058-642562,642564-642566,642568-642574,642576-642736,642739-650914,650916-650920

Modified: poi/branches/ooxml/src/documentation/content/xdocs/changes.xml
URL: http://svn.apache.org/viewvc/poi/branches/ooxml/src/documentation/content/xdocs/changes.xml?rev=650938&r1=650937&r2=650938&view=diff
==============================================================================
--- poi/branches/ooxml/src/documentation/content/xdocs/changes.xml (original)
+++ poi/branches/ooxml/src/documentation/content/xdocs/changes.xml Wed Apr 23 09:49:18 2008
@@ -43,7 +43,13 @@
            <action dev="POI-DEVELOPERS" type="add">Created a common interface for handling PowerPoint files, irrespective of if they are .ppt or .pptx</action>
            <action dev="POI-DEVELOPERS" type="add">Created a common interface for handling Excel files, irrespective of if they are .xls or .xlsx</action>
         </release>
-        <release version="3.0.3-beta1" date="2008-04-??">
+        <release version="3.1-beta1" date="2008-04-??">
+           <action dev="POI-DEVELOPERS" type="add">HSLF: Support for getting embedded sounds from slide show </action>
+           <action dev="POI-DEVELOPERS" type="add">HSLF: Initial support for rendering slides into images</action>
+           <action dev="POI-DEVELOPERS" type="add">HSLF: Support for getting OLE object data from slide show </action>
+           <action dev="POI-DEVELOPERS" type="add">HSLF: Implemented more methods in PPGraphics2D</action>
+           <action dev="POI-DEVELOPERS" type="add">HSLF: Added Freeform shape which can contain both lines and Bezier curves</action>
+           <action dev="POI-DEVELOPERS" type="fix">41071 - Improved text extraction in HSLF</action>
            <action dev="POI-DEVELOPERS" type="add">30311 - Conditional Formatting - improved API, added HSSFSheetConditionalFormatting</action>
            <action dev="POI-DEVELOPERS" type="fix">Update the formula parser code to use a HSSFWorkbook, rather than the low level model.Workbook, to make things cleaner and make supporting XSSF formulas in future much easier</action>
            <action dev="POI-DEVELOPERS" type="fix">Fix the logger used by POIFSFileSystem, so that commons-logging isn't required when not used</action>

Modified: poi/branches/ooxml/src/documentation/content/xdocs/index.xml
URL: http://svn.apache.org/viewvc/poi/branches/ooxml/src/documentation/content/xdocs/index.xml?rev=650938&r1=650937&r2=650938&view=diff
==============================================================================
--- poi/branches/ooxml/src/documentation/content/xdocs/index.xml (original)
+++ poi/branches/ooxml/src/documentation/content/xdocs/index.xml Wed Apr 23 09:49:18 2008
@@ -136,8 +136,7 @@
         </section>
         <section><title>HSLF for PowerPoint Documents</title>
 	<p>HSLF is our port of the Microsoft PowerPoint 97(-2003) file format to pure
-	  Java. It supports read and write capabilities of some, but not yet all
-      of the core records. Please see <link
+	  Java. It supports read and write capabilities. Please see <link
 	    href="./slideshow/index.html">the HSLF project page for more
 	    information</link>.</p>
         </section>

Modified: poi/branches/ooxml/src/documentation/content/xdocs/poifs/embeded.xml
URL: http://svn.apache.org/viewvc/poi/branches/ooxml/src/documentation/content/xdocs/poifs/embeded.xml?rev=650938&r1=650937&r2=650938&view=diff
==============================================================================
--- poi/branches/ooxml/src/documentation/content/xdocs/poifs/embeded.xml (original)
+++ poi/branches/ooxml/src/documentation/content/xdocs/poifs/embeded.xml Wed Apr 23 09:49:18 2008
@@ -61,9 +61,9 @@
        <section><title>Files embeded in PowerPoint</title>
          <p>PowerPoint does not normally store embeded files
          in the OLE2 layer. Instead, they are held within records
-         of the main PowerPoint file. To get at them, you need to
-         find the appropriate data within the PowerPoint stream,
-         and work from that.</p>
+         of the main PowerPoint file. 
+         <br/>See the <link href="./../hslf/how-to-shapes.html#OLE">HSLF Tutorial</link> 
+         for how to retrieve embedded OLE objects from a presentation</p>
        </section>
     </section>
 

Modified: poi/branches/ooxml/src/documentation/content/xdocs/slideshow/how-to-shapes.xml
URL: http://svn.apache.org/viewvc/poi/branches/ooxml/src/documentation/content/xdocs/slideshow/how-to-shapes.xml?rev=650938&r1=650937&r2=650938&view=diff
==============================================================================
--- poi/branches/ooxml/src/documentation/content/xdocs/slideshow/how-to-shapes.xml (original)
+++ poi/branches/ooxml/src/documentation/content/xdocs/slideshow/how-to-shapes.xml Wed Apr 23 09:49:18 2008
@@ -40,6 +40,12 @@
                     <li><link href="#Bullets">How to create bulleted lists</link></li>
                     <li><link href="#Hyperlinks">Hyperlinks</link></li>
                     <li><link href="#Tables">Tables</link></li>
+                    <li><link href="#RemoveShape">How to remove shapes</link></li>
+                    <li><link href="#OLE">How to retrieve embedded OLE objects</link></li>
+                    <li><link href="#Sound">How to retrieve embedded sounds</link></li>
+                    <li><link href="#Freeform">How to create shapes of arbitrary geometry</link></li>
+                    <li><link href="#Graphics2D">Shapes and Graphics2D</link></li>
+                    <li><link href="#Render">How to convert slides into images</link></li>
                 </ul>
             </section>
             <section><title>Features</title>
@@ -80,14 +86,8 @@
                 </section>
                 <anchor id="GetShapes"/>
                 <section><title>How to get shapes contained in a particular slide</title>
-                  <p>The superclass of all shapes in HSLF is the Shape class - the elemental object that composes a drawing.
-                    The following pictute shows the class tree of HSLF shapes:
-                  </p>
-                  <p>
-			  <img src="images/hslf_shapes.gif" alt="Class Tree of HSLF Shapes" width="611" height="412"/>
-                  </p>
                   <p>
-                    The following fragment demonstrates how to iterate over shapes for each slide.
+                    The following code demonstrates how to iterate over shapes for each slide.
                   </p>
                     <source>
   SlideShow ppt = new SlideShow(new HSLFSlideShow("slideshow.ppt"));
@@ -440,7 +440,186 @@
                     </source>
                 </section>
                   
-            </section>
+                <anchor id="RemoveShape"/>
+                <section><title>How to remove shapes from a slide</title>
+                  <source>
+
+        Shape[] shape = slide.getShapes();
+        for (int i = 0; i &lt; shape.length; i++) {
+    
+            //remove the shape
+            boolean ok = slide.removeShape(shape[i]);
+            if(ok){
+              //the shape was removed. Do something.
+            }
+        }
+                    </source>
+                  </section>
+                <anchor id="OLE"/>
+                <section><title>How to retrieve embedded OLE objects</title>
+                  <source>
+
+        Shape[] shape = slide.getShapes();
+        for (int i = 0; i &lt; shape.length; i++) {
+            if (shape[i] instanceof OLEShape) {
+                OLEShape ole = (OLEShape) shape[i];
+                ObjectData data = ole.getObjectData();
+                String name = ole.getInstanceName();
+                if ("Worksheet".equals(name)) {
+                    HSSFWorkbook wb = new HSSFWorkbook(data.getData());
+                } else if ("Document".equals(name)) {
+                    HWPFDocument doc = new HWPFDocument(data.getData());
+                }
+            }
+        }
+                    </source>
+                  </section>
+
+                <anchor id="Sound"/>
+                <section><title>How to retrieve embedded sounds</title>
+                  <source>
+
+        FileInputStream is = new FileInputStream(args[0]);
+        SlideShow ppt = new SlideShow(is);
+        is.close();
+
+        SoundData[] sound = ppt.getSoundData();
+        for (int i = 0; i &lt; sound.length; i++) {
+            //save *WAV sounds on disk
+            if(sound[i].getSoundType().equals(".WAV")){
+                FileOutputStream out = new FileOutputStream(sound[i].getSoundName());
+                out.write(sound[i].getData());
+                out.close();
+            }
+        }
+                    </source>
+                  </section>
+                  
+                <anchor id="Freeform"/>
+                <section><title>How to create shapes of arbitrary geometry</title>
+                  <source>
+
+        SlideShow ppt = new SlideShow();
+        Slide slide = ppt.createSlide();
+
+        java.awt.geom.GeneralPath path = new java.awt.geom.GeneralPath();
+        path.moveTo(100, 100);
+        path.lineTo(200, 100);
+        path.curveTo(50, 45, 134, 22, 78, 133);
+        path.curveTo(10, 45, 134, 56, 78, 100);
+        path.lineTo(100, 200);
+        path.closePath();
+        
+        Freeform shape = new Freeform();
+        shape.setPath(path);
+        slide.addShape(shape);
+                    </source>
+                  </section>
+
+                <anchor id="Graphics2D"/>
+                <section><title>How to draw into a slide using Graphics2D</title>
+                  <warning>
+                   Current implementation of the PowerPoint Graphics2D driver is not fully compliant with the java.awt.Graphics2D specification.
+                   Some features like clipping, drawing of images are not yet supported. 
+                  </warning>
+                  <source>
+        SlideShow ppt = new SlideShow();
+        Slide slide = ppt.createSlide();
+
+        //draw a simple bar graph
+        //bar chart data. The first value is the bar color, the second is the width
+        Object[] def = new Object[]{
+            Color.yellow, new Integer(100),
+            Color.green, new Integer(150),
+            Color.gray, new Integer(75),
+            Color.red, new Integer(200),
+        };
+
+        //all objects are drawn into a shape group so we need to create one
+
+        ShapeGroup group = new ShapeGroup();
+        //define position of the drawing in the slide
+        Rectangle bounds = new java.awt.Rectangle(200, 100, 350, 300);
+        //if you want to draw in the entire slide area then define the anchor as follows:
+        //Dimension pgsize = ppt.getPageSize();
+        //java.awt.Rectangle bounds = new java.awt.Rectangle(0, 0, pgsize.width, pgsize.height);
+
+        group.setAnchor(bounds);
+        slide.addShape(group);
+
+        //draw a simple bar chart
+        Graphics2D graphics = new PPGraphics2D(group);
+        int x = bounds.x + 50, y = bounds.y + 50;
+        graphics.setFont(new Font("Arial", Font.BOLD, 10));
+        for (int i = 0, idx = 1; i &lt; def.length; i+=2, idx++) {
+            graphics.setColor(Color.black);
+            int width = ((Integer)def[i+1]).intValue();
+            graphics.drawString("Q" + idx, x-20, y+20);
+            graphics.drawString(width + "%", x + width + 10, y + 20);
+            graphics.setColor((Color)def[i]);
+            graphics.fill(new Rectangle(x, y, width, 30));
+            y += 40;
+        }
+        graphics.setColor(Color.black);
+        graphics.setFont(new Font("Arial", Font.BOLD, 14));
+        graphics.draw(bounds);
+        graphics.drawString("Performance", x + 70, y + 40);
+
+        FileOutputStream out = new FileOutputStream("hslf-graphics2d.ppt");
+        ppt.write(out);
+        out.close();
+
+                   </source>
+                  </section>
+
+                <anchor id="Render"/>
+                <section><title>Export PowerPoint slides into java.awt.Graphics2D</title>
+                  <p>
+                    HSLF provides a way to export slides into images. You can capture slides into java.awt.Graphics2D object (or any other) 
+                    and serialize it into a PNG or JPEG format. Please note, although HSLF attempts to render slides as close to PowerPoint as possible, 
+                    the output may look differently from PowerPoint due to the following reasons: 
+                  </p>
+            <ul>
+              <li>Java2D renders fonts differently vs PowerPoint. There are always some differences in the way the font glyphs are painted</li>   
+              <li>HSLF uses java.awt.font.LineBreakMeasurer to break text into lines. PowerPoint may do it in a different way.</li>
+              <li>If a font from the presentation is not avaiable, then the JDK default font will be used.</li>
+            </ul>
+            <p>
+            Current Limitations:
+            </p>
+            <ul>
+              <li>Some types of shapes are not yet supported (WordArt, complex auto-shapes)</li>
+              <li>Only Bitmap images (PNG, JPEG, DIB) can be rendered in Java</li>  
+            </ul>
+                  <source>
+        FileInputStream is = new FileInputStream("slideshow.ppt");
+        SlideShow ppt = new SlideShow(is);
+        is.close();
+        
+        Dimension pgsize = ppt.getPageSize();
+
+        Slide[] slide = ppt.getSlides();
+        for (int i = 0; i &lt; slide.length; i++) {
+
+            BufferedImage img = new BufferedImage(pgsize.width, pgsize.height, BufferedImage.TYPE_INT_RGB);
+            Graphics2D graphics = img.createGraphics();
+            //clear the drawing area
+            graphics.setPaint(Color.white);
+            graphics.fill(new Rectangle2D.Float(0, 0, pgsize.width, pgsize.height));
+
+            //render
+            slide[i].draw(graphics);
+
+            //save the output
+            FileOutputStream out = new FileOutputStream("slide-"  + (i+1) + ".png");
+            javax.imageio.ImageIO.write(img, "png", out);
+            out.close();
+        }
+
+                  </source>
+                  </section>
+                  
+                </section>
         </section>
     </body>
 </document>

Modified: poi/branches/ooxml/src/documentation/content/xdocs/slideshow/index.xml
URL: http://svn.apache.org/viewvc/poi/branches/ooxml/src/documentation/content/xdocs/slideshow/index.xml?rev=650938&r1=650937&r2=650938&view=diff
==============================================================================
--- poi/branches/ooxml/src/documentation/content/xdocs/slideshow/index.xml (original)
+++ poi/branches/ooxml/src/documentation/content/xdocs/slideshow/index.xml Wed Apr 23 09:49:18 2008
@@ -26,6 +26,7 @@
         <authors>
             <person name="Avik Sengupta" email="avik at apache dot org"/>
             <person name="Nick Burch" email="nick at apache dot org"/>
+            <person name="Yegor Kozlov" email="yegor at apache dot org"/>
         </authors>
     </header>
 
@@ -37,9 +38,12 @@
 			Powerpoint '97(-2007) file format. It <em>does not</em> support
 			the new PowerPoint 2007 .pptx file format, which is not OLE2 
 			based.</p>
-            <p>HSLF provides a way to read powerpoint presentations, and extract text from it.
-            It also provides some (currently limited) edit capabilities.
+    <p>HSLF provides a way to read, create or modify PowerPoint  presentations. In particular, it provides:
             </p>
+            <ul>
+                <li>api for data extraction (text, pictures, embedded objects, sounds)</li>
+                <li>usermodel api for creating, reading and modifying ppt files</li>
+            </ul>
             <note> 
                 This code currently lives the 
                 <link href="http://svn.apache.org/viewcvs.cgi/poi/trunk/src/scratchpad/">scratchpad area</link> 

Modified: poi/branches/ooxml/src/documentation/content/xdocs/status.xml
URL: http://svn.apache.org/viewvc/poi/branches/ooxml/src/documentation/content/xdocs/status.xml?rev=650938&r1=650937&r2=650938&view=diff
==============================================================================
--- poi/branches/ooxml/src/documentation/content/xdocs/status.xml (original)
+++ poi/branches/ooxml/src/documentation/content/xdocs/status.xml Wed Apr 23 09:49:18 2008
@@ -40,7 +40,13 @@
            <action dev="POI-DEVELOPERS" type="add">Created a common interface for handling PowerPoint files, irrespective of if they are .ppt or .pptx</action>
            <action dev="POI-DEVELOPERS" type="add">Created a common interface for handling Excel files, irrespective of if they are .xls or .xlsx</action>
         </release>
-        <release version="3.0.3-beta1" date="2008-04-??">
+        <release version="3.1-beta1" date="2008-04-??">
+           <action dev="POI-DEVELOPERS" type="add">HSLF: Support for getting embedded sounds from slide show </action>
+           <action dev="POI-DEVELOPERS" type="add">HSLF: Initial support for rendering slides into images</action>
+           <action dev="POI-DEVELOPERS" type="add">HSLF: Support for getting OLE object data from slide show </action>
+           <action dev="POI-DEVELOPERS" type="add">HSLF: Implemented more methods in PPGraphics2D</action>
+           <action dev="POI-DEVELOPERS" type="add">HSLF: Added Freeform shape which can contain both lines and Bezier curves</action>
+           <action dev="POI-DEVELOPERS" type="fix">41071 - Improved text extraction in HSLF</action>
            <action dev="POI-DEVELOPERS" type="add">30311 - Conditional Formatting - improved API, added HSSFSheetConditionalFormatting</action>
            <action dev="POI-DEVELOPERS" type="fix">Update the formula parser code to use a HSSFWorkbook, rather than the low level model.Workbook, to make things cleaner and make supporting XSSF formulas in future much easier</action>
            <action dev="POI-DEVELOPERS" type="fix">Fix the logger used by POIFSFileSystem, so that commons-logging isn't required when not used</action>

Modified: poi/branches/ooxml/src/java/org/apache/poi/hssf/usermodel/HSSFTextbox.java
URL: http://svn.apache.org/viewvc/poi/branches/ooxml/src/java/org/apache/poi/hssf/usermodel/HSSFTextbox.java?rev=650938&r1=650937&r2=650938&view=diff
==============================================================================
--- poi/branches/ooxml/src/java/org/apache/poi/hssf/usermodel/HSSFTextbox.java (original)
+++ poi/branches/ooxml/src/java/org/apache/poi/hssf/usermodel/HSSFTextbox.java Wed Apr 23 09:49:18 2008
@@ -83,7 +83,12 @@
      */
     public void setString( RichTextString string )
     {
-        this.string = (HSSFRichTextString) string;
+        HSSFRichTextString rtr = (HSSFRichTextString)string;
+
+        // If font is not set we must set the default one
+        if (rtr.numFormattingRuns() == 0) rtr.applyFont((short)0);
+
+        this.string = rtr;
     }
 
     /**

Modified: poi/branches/ooxml/src/scratchpad/src/org/apache/poi/hslf/HSLFSlideShow.java
URL: http://svn.apache.org/viewvc/poi/branches/ooxml/src/scratchpad/src/org/apache/poi/hslf/HSLFSlideShow.java?rev=650938&r1=650937&r2=650938&view=diff
==============================================================================
--- poi/branches/ooxml/src/scratchpad/src/org/apache/poi/hslf/HSLFSlideShow.java (original)
+++ poi/branches/ooxml/src/scratchpad/src/org/apache/poi/hslf/HSLFSlideShow.java Wed Apr 23 09:49:18 2008
@@ -27,22 +27,13 @@
 import java.io.IOException;
 import java.io.InputStream;
 import java.io.OutputStream;
-import java.util.ArrayList;
-import java.util.Arrays;
-import java.util.Hashtable;
-import java.util.Iterator;
-import java.util.List;
+import java.util.*;
 
 import org.apache.poi.POIDocument;
 import org.apache.poi.hslf.exceptions.CorruptPowerPointFileException;
 import org.apache.poi.hslf.exceptions.EncryptedPowerPointFileException;
 import org.apache.poi.hslf.exceptions.HSLFException;
-import org.apache.poi.hslf.record.CurrentUserAtom;
-import org.apache.poi.hslf.record.ExOleObjStg;
-import org.apache.poi.hslf.record.PersistPtrHolder;
-import org.apache.poi.hslf.record.PositionDependentRecord;
-import org.apache.poi.hslf.record.Record;
-import org.apache.poi.hslf.record.UserEditAtom;
+import org.apache.poi.hslf.record.*;
 import org.apache.poi.hslf.usermodel.ObjectData;
 import org.apache.poi.hslf.usermodel.PictureData;
 import org.apache.poi.hslf.model.Shape;
@@ -253,6 +244,7 @@
 
     private Record[] read(byte[] docstream, int usrOffset){
         ArrayList lst = new ArrayList();
+        HashMap offset2id = new HashMap(); 
         while (usrOffset != 0){
             UserEditAtom usr = (UserEditAtom) Record.buildRecordAtOffset(docstream, usrOffset);
             lst.add(new Integer(usrOffset));
@@ -266,6 +258,7 @@
                 Integer offset = (Integer)entries.get(id);
 
                 lst.add(offset);
+                offset2id.put(offset, id);
             }
 
             usrOffset = usr.getLastUserEditAtomOffset();
@@ -278,6 +271,11 @@
         for (int i = 0; i < a.length; i++) {
             Integer offset = (Integer)a[i];
             rec[i] = (Record)Record.buildRecordAtOffset(docstream, offset.intValue());
+            if(rec[i] instanceof PersistRecord) {
+                PersistRecord psr = (PersistRecord)rec[i];
+                Integer id = (Integer)offset2id.get(offset);
+                psr.setPersistId(id.intValue());
+            }
         }
 
         return rec;

Modified: poi/branches/ooxml/src/scratchpad/src/org/apache/poi/hslf/model/AutoShape.java
URL: http://svn.apache.org/viewvc/poi/branches/ooxml/src/scratchpad/src/org/apache/poi/hslf/model/AutoShape.java?rev=650938&r1=650937&r2=650938&view=diff
==============================================================================
--- poi/branches/ooxml/src/scratchpad/src/org/apache/poi/hslf/model/AutoShape.java (original)
+++ poi/branches/ooxml/src/scratchpad/src/org/apache/poi/hslf/model/AutoShape.java Wed Apr 23 09:49:18 2008
@@ -18,6 +18,9 @@
 package org.apache.poi.hslf.model;
 
 import org.apache.poi.ddf.*;
+import org.apache.poi.util.POILogger;
+
+import java.awt.geom.Rectangle2D;
 
 /**
  * Represents an AutoShape.
@@ -102,4 +105,17 @@
 
         setEscherProperty((short)(EscherProperties.GEOMETRY__ADJUSTVALUE + idx), val);
     }
+
+    public java.awt.Shape getOutline(){
+        ShapeOutline outline = AutoShapes.getShapeOutline(getShapeType());
+        Rectangle2D anchor = getLogicalAnchor2D();
+        if(outline == null){
+            logger.log(POILogger.WARN, "Outline not found for " + ShapeTypes.typeName(getShapeType()));
+            return anchor;
+        } else {
+            java.awt.Shape shape = outline.getOutline(this);
+            return AutoShapes.transform(shape, anchor);
+        }
+    }
+
 }

Modified: poi/branches/ooxml/src/scratchpad/src/org/apache/poi/hslf/model/Background.java
URL: http://svn.apache.org/viewvc/poi/branches/ooxml/src/scratchpad/src/org/apache/poi/hslf/model/Background.java?rev=650938&r1=650937&r2=650938&view=diff
==============================================================================
--- poi/branches/ooxml/src/scratchpad/src/org/apache/poi/hslf/model/Background.java (original)
+++ poi/branches/ooxml/src/scratchpad/src/org/apache/poi/hslf/model/Background.java Wed Apr 23 09:49:18 2008
@@ -1,4 +1,3 @@
-
 /* ====================================================================
    Licensed to the Apache Software Foundation (ASF) under one or more
    contributor license agreements.  See the NOTICE file distributed with
@@ -19,6 +18,14 @@
 package org.apache.poi.hslf.model;
 
 import org.apache.poi.ddf.EscherContainerRecord;
+import org.apache.poi.hslf.usermodel.PictureData;
+import org.apache.poi.hslf.blip.Bitmap;
+import org.apache.poi.util.POILogger;
+
+import javax.imageio.ImageIO;
+import java.awt.*;
+import java.awt.image.BufferedImage;
+import java.io.ByteArrayInputStream;
 
 /**
  * Background shape
@@ -27,12 +34,42 @@
  */
 public class Background extends Shape {
 
-    protected Background(EscherContainerRecord escherRecord, Shape parent){
+    protected Background(EscherContainerRecord escherRecord, Shape parent) {
         super(escherRecord, parent);
     }
 
-    protected EscherContainerRecord createSpContainer(boolean isChild){
+    protected EscherContainerRecord createSpContainer(boolean isChild) {
         return null;
     }
 
+    public void draw(Graphics2D graphics) {
+        Fill f = getFill();
+        Dimension pg = getSheet().getSlideShow().getPageSize();
+        Rectangle anchor = new Rectangle(0, 0, pg.width, pg.height);
+        switch (f.getFillType()) {
+            case Fill.FILL_SOLID:
+                Color color = f.getForegroundColor();
+                graphics.setPaint(color);
+                graphics.fill(anchor);
+                break;
+            case Fill.FILL_PICTURE:
+                PictureData data = f.getPictureData();
+                if (data instanceof Bitmap) {
+                    BufferedImage img = null;
+                    try {
+                        img = ImageIO.read(new ByteArrayInputStream(data.getData()));
+                    } catch (Exception e) {
+                        logger.log(POILogger.WARN, "ImageIO failed to create image. image.type: " + data.getType());
+                        return;
+                    }
+                    Image scaledImg = img.getScaledInstance(anchor.width, anchor.height, Image.SCALE_SMOOTH);
+                    graphics.drawImage(scaledImg, anchor.x, anchor.y, null);
+
+                }
+                break;
+            default:
+                logger.log(POILogger.WARN, "unsuported fill type: " + f.getFillType());
+                break;
+        }
+    }
 }

Modified: poi/branches/ooxml/src/scratchpad/src/org/apache/poi/hslf/model/Fill.java
URL: http://svn.apache.org/viewvc/poi/branches/ooxml/src/scratchpad/src/org/apache/poi/hslf/model/Fill.java?rev=650938&r1=650937&r2=650938&view=diff
==============================================================================
--- poi/branches/ooxml/src/scratchpad/src/org/apache/poi/hslf/model/Fill.java (original)
+++ poi/branches/ooxml/src/scratchpad/src/org/apache/poi/hslf/model/Fill.java Wed Apr 23 09:49:18 2008
@@ -22,12 +22,10 @@
 import org.apache.poi.hslf.record.*;
 import org.apache.poi.hslf.usermodel.PictureData;
 import org.apache.poi.hslf.usermodel.SlideShow;
-import org.apache.poi.hslf.exceptions.HSLFException;
 import org.apache.poi.util.POILogger;
 import org.apache.poi.util.POILogFactory;
 
 import java.awt.*;
-import java.util.*;
 
 /**
  * Represents functionality provided by the 'Fill Effects' dialog in PowerPoint.
@@ -137,13 +135,15 @@
         EscherOptRecord opt = (EscherOptRecord)Shape.getEscherChild(shape.getSpContainer(), EscherOptRecord.RECORD_ID);
         EscherSimpleProperty p1 = (EscherSimpleProperty)Shape.getEscherProperty(opt, EscherProperties.FILL__FILLCOLOR);
         EscherSimpleProperty p2 = (EscherSimpleProperty)Shape.getEscherProperty(opt, EscherProperties.FILL__NOFILLHITTEST);
+        EscherSimpleProperty p3 = (EscherSimpleProperty)Shape.getEscherProperty(opt, EscherProperties.FILL__FILLOPACITY);
 
         int p2val = p2 == null ? 0 : p2.getPropertyValue();
+        int alpha =  p3 == null ? 255 : ((p3.getPropertyValue() >> 8) & 0xFF);
 
         Color clr = null;
         if (p1 != null && (p2val  & 0x10) != 0){
             int rgb = p1.getPropertyValue();
-            clr = shape.getColor(rgb);
+            clr = shape.getColor(rgb, alpha);
         }
         return clr;
     }
@@ -176,7 +176,7 @@
         Color clr = null;
         if (p1 != null && (p2val  & 0x10) != 0){
             int rgb = p1.getPropertyValue();
-            clr = shape.getColor(rgb);
+            clr = shape.getColor(rgb, 255);
         }
         return clr;
     }

Modified: poi/branches/ooxml/src/scratchpad/src/org/apache/poi/hslf/model/Freeform.java
URL: http://svn.apache.org/viewvc/poi/branches/ooxml/src/scratchpad/src/org/apache/poi/hslf/model/Freeform.java?rev=650938&r1=650937&r2=650938&view=diff
==============================================================================
--- poi/branches/ooxml/src/scratchpad/src/org/apache/poi/hslf/model/Freeform.java (original)
+++ poi/branches/ooxml/src/scratchpad/src/org/apache/poi/hslf/model/Freeform.java Wed Apr 23 09:49:18 2008
@@ -22,6 +22,7 @@
 
 import java.awt.geom.*;
 import java.util.ArrayList;
+import java.util.Arrays;
 
 /**
  * A "Freeform" shape.
@@ -33,6 +34,16 @@
  * @author Yegor Kozlov
  */
 public class Freeform extends AutoShape {
+
+    public static final byte[] SEGMENTINFO_MOVETO   = new byte[]{0x00, 0x40};
+    public static final byte[] SEGMENTINFO_LINETO   = new byte[]{0x00, (byte)0xAC};
+    public static final byte[] SEGMENTINFO_ESCAPE   = new byte[]{0x01, 0x00};
+    public static final byte[] SEGMENTINFO_ESCAPE2  = new byte[]{0x01, 0x20};
+    public static final byte[] SEGMENTINFO_CUBICTO  = new byte[]{0x00, (byte)0xAD};
+    public static final byte[] SEGMENTINFO_CUBICTO2 = new byte[]{0x00, (byte)0xB3}; //OpenOffice inserts 0xB3 instead of 0xAD.
+    public static final byte[] SEGMENTINFO_CLOSE    = new byte[]{0x01, (byte)0x60};
+    public static final byte[] SEGMENTINFO_END      = new byte[]{0x00, (byte)0x80};
+
     /**
      * Create a Freeform object and initialize it from the supplied Record container.
      *
@@ -82,36 +93,37 @@
             switch (type) {
                 case PathIterator.SEG_MOVETO:
                     pntInfo.add(new Point2D.Double(vals[0], vals[1]));
-                    segInfo.add(new byte[]{0x00, 0x40});
+                    segInfo.add(SEGMENTINFO_MOVETO);
                     break;
                 case PathIterator.SEG_LINETO:
                     pntInfo.add(new Point2D.Double(vals[0], vals[1]));
-                    segInfo.add(new byte[]{0x00, (byte)0xAC});
-                    segInfo.add(new byte[]{0x01, 0x00 });
+                    segInfo.add(SEGMENTINFO_LINETO);
+                    segInfo.add(SEGMENTINFO_ESCAPE);
                     break;
                 case PathIterator.SEG_CUBICTO:
                     pntInfo.add(new Point2D.Double(vals[0], vals[1]));
                     pntInfo.add(new Point2D.Double(vals[2], vals[3]));
                     pntInfo.add(new Point2D.Double(vals[4], vals[5]));
-                    segInfo.add(new byte[]{0x00, (byte)0xAD});
-                    segInfo.add(new byte[]{0x01, 0x20 });
+                    segInfo.add(SEGMENTINFO_CUBICTO);
+                    segInfo.add(SEGMENTINFO_ESCAPE2);
                     break;
                 case PathIterator.SEG_QUADTO:
+                    //TODO: figure out how to convert SEG_QUADTO into SEG_CUBICTO  
                     logger.log(POILogger.WARN, "SEG_QUADTO is not supported");
                     break;
                 case PathIterator.SEG_CLOSE:
                     pntInfo.add(pntInfo.get(0));
-                    segInfo.add(new byte[]{0x00, (byte)0xAC});
-                    segInfo.add(new byte[]{0x01, 0x00 });
-                    segInfo.add(new byte[]{0x00, (byte)0xAC});
-                    segInfo.add(new byte[]{0x01, (byte)0x60});
+                    segInfo.add(SEGMENTINFO_LINETO);
+                    segInfo.add(SEGMENTINFO_ESCAPE);
+                    segInfo.add(SEGMENTINFO_LINETO);
+                    segInfo.add(SEGMENTINFO_CLOSE);
                     isClosed = true;
                     break;
             }
 
             it.next();
         }
-        if(!isClosed) segInfo.add(new byte[]{0x00, (byte)0xAC});
+        if(!isClosed) segInfo.add(SEGMENTINFO_LINETO);
         segInfo.add(new byte[]{0x00, (byte)0x80});
 
         EscherOptRecord opt = (EscherOptRecord)getEscherChild(_escherContainer, EscherOptRecord.RECORD_ID);
@@ -146,5 +158,86 @@
         opt.sortProperties();
 
         setAnchor(bounds);
+    }
+
+    /**
+     * Gets the freeform path
+     *
+     * @return the freeform path
+     */
+     public GeneralPath getPath(){
+        EscherOptRecord opt = (EscherOptRecord)getEscherChild(_escherContainer, EscherOptRecord.RECORD_ID);
+        opt.addEscherProperty(new EscherSimpleProperty(EscherProperties.GEOMETRY__SHAPEPATH, 0x4));
+
+        EscherArrayProperty verticesProp = (EscherArrayProperty)getEscherProperty(opt, (short)(EscherProperties.GEOMETRY__VERTICES + 0x4000));
+        if(verticesProp == null) verticesProp = (EscherArrayProperty)getEscherProperty(opt, (short)(EscherProperties.GEOMETRY__VERTICES));
+
+        EscherArrayProperty segmentsProp = (EscherArrayProperty)getEscherProperty(opt, (short)(EscherProperties.GEOMETRY__SEGMENTINFO + 0x4000));
+        if(segmentsProp == null) segmentsProp = (EscherArrayProperty)getEscherProperty(opt, (short)(EscherProperties.GEOMETRY__SEGMENTINFO));
+
+        //sanity check
+        if(verticesProp == null) {
+            logger.log(POILogger.WARN, "Freeform is missing GEOMETRY__VERTICES ");
+            return null;
+        }
+        if(segmentsProp == null) {
+            logger.log(POILogger.WARN, "Freeform is missing GEOMETRY__SEGMENTINFO ");
+            return null;
+        }
+
+        Rectangle2D bounds = getAnchor2D();
+        float right = (float)bounds.getX();
+        float bottom = (float)bounds.getY();
+
+        GeneralPath path = new GeneralPath();
+        int numPoints = verticesProp.getNumberOfElementsInArray();
+        int numSegments = segmentsProp.getNumberOfElementsInArray();
+        for (int i = 0, j = 0; i < numSegments && j < numPoints; i++) {
+            byte[] elem = segmentsProp.getElement(i);
+            if(Arrays.equals(elem, SEGMENTINFO_MOVETO)){
+                byte[] p = verticesProp.getElement(j++);
+                short x = LittleEndian.getShort(p, 0);
+                short y = LittleEndian.getShort(p, 2);
+                path.moveTo(
+                        ((float)x*POINT_DPI/MASTER_DPI + right),
+                        ((float)y*POINT_DPI/MASTER_DPI + bottom));
+            } else if (Arrays.equals(elem, SEGMENTINFO_CUBICTO) || Arrays.equals(elem, SEGMENTINFO_CUBICTO2)){
+                i++;
+                byte[] p1 = verticesProp.getElement(j++);
+                short x1 = LittleEndian.getShort(p1, 0);
+                short y1 = LittleEndian.getShort(p1, 2);
+                byte[] p2 = verticesProp.getElement(j++);
+                short x2 = LittleEndian.getShort(p2, 0);
+                short y2 = LittleEndian.getShort(p2, 2);
+                byte[] p3 = verticesProp.getElement(j++);
+                short x3 = LittleEndian.getShort(p3, 0);
+                short y3 = LittleEndian.getShort(p3, 2);
+                path.curveTo(
+                        ((float)x1*POINT_DPI/MASTER_DPI + right), ((float)y1*POINT_DPI/MASTER_DPI + bottom),
+                        ((float)x2*POINT_DPI/MASTER_DPI + right), ((float)y2*POINT_DPI/MASTER_DPI + bottom),
+                        ((float)x3*POINT_DPI/MASTER_DPI + right), ((float)y3*POINT_DPI/MASTER_DPI + bottom));
+
+            } else if (Arrays.equals(elem, SEGMENTINFO_LINETO)){
+                i++;
+                byte[] pnext = segmentsProp.getElement(i);
+                if(Arrays.equals(pnext, SEGMENTINFO_ESCAPE)){
+                    if(j + 1 < numPoints){
+                        byte[] p = verticesProp.getElement(j++);
+                        short x = LittleEndian.getShort(p, 0);
+                        short y = LittleEndian.getShort(p, 2);
+                        path.lineTo(
+                                ((float)x*POINT_DPI/MASTER_DPI + right), ((float)y*POINT_DPI/MASTER_DPI + bottom));
+                    }
+                } else if (Arrays.equals(pnext, SEGMENTINFO_CLOSE)){
+                    path.closePath();
+                }
+            }
+        }
+
+        return path;
+    }
+
+    public java.awt.Shape getOutline(){
+        return getPath();
     }
 }

Modified: poi/branches/ooxml/src/scratchpad/src/org/apache/poi/hslf/model/Line.java
URL: http://svn.apache.org/viewvc/poi/branches/ooxml/src/scratchpad/src/org/apache/poi/hslf/model/Line.java?rev=650938&r1=650937&r2=650938&view=diff
==============================================================================
--- poi/branches/ooxml/src/scratchpad/src/org/apache/poi/hslf/model/Line.java (original)
+++ poi/branches/ooxml/src/scratchpad/src/org/apache/poi/hslf/model/Line.java Wed Apr 23 09:49:18 2008
@@ -19,6 +19,9 @@
 
 import org.apache.poi.ddf.*;
 
+import java.awt.geom.Rectangle2D;
+import java.awt.geom.Line2D;
+
 /**
  * Represents a line in a PowerPoint drawing
  *
@@ -126,4 +129,8 @@
         return _escherContainer;
     }
 
+    public java.awt.Shape getOutline(){
+        Rectangle2D anchor = getLogicalAnchor2D();
+        return new Line2D.Double(anchor.getX(), anchor.getY(), anchor.getX() + anchor.getWidth(), anchor.getY() + anchor.getHeight());
+    }
 }

Modified: poi/branches/ooxml/src/scratchpad/src/org/apache/poi/hslf/model/MasterSheet.java
URL: http://svn.apache.org/viewvc/poi/branches/ooxml/src/scratchpad/src/org/apache/poi/hslf/model/MasterSheet.java?rev=650938&r1=650937&r2=650938&view=diff
==============================================================================
--- poi/branches/ooxml/src/scratchpad/src/org/apache/poi/hslf/model/MasterSheet.java (original)
+++ poi/branches/ooxml/src/scratchpad/src/org/apache/poi/hslf/model/MasterSheet.java Wed Apr 23 09:49:18 2008
@@ -17,6 +17,8 @@
 package org.apache.poi.hslf.model;
 
 import org.apache.poi.hslf.record.SheetContainer;
+import org.apache.poi.hslf.record.Record;
+import org.apache.poi.hslf.record.RecordTypes;
 import org.apache.poi.hslf.model.textproperties.TextProp;
 
 /**
@@ -37,4 +39,32 @@
      */
     public abstract TextProp getStyleAttribute(int txtype, int level, String name, boolean isCharacter) ;
 
+
+    /**
+     * Checks if the shape is a placeholder.
+     * (placeholders aren't normal shapes, they are visible only in the Edit Master mode)
+     *
+     *
+     * @return true if the shape is a placeholder
+     */
+    public static boolean isPlaceholder(Shape shape){
+        if(!(shape instanceof TextShape)) return false;
+
+        TextShape tx = (TextShape)shape;
+        TextRun run = tx.getTextRun();
+        if(run == null) return false;
+
+        Record[] records = run._records;
+        for (int i = 0; i < records.length; i++) {
+            int type = (int)records[i].getRecordType();
+            if (type == RecordTypes.BaseTextPropAtom.typeID ||
+                type == RecordTypes.DateTimeMCAtom.typeID ||
+                type == RecordTypes.GenericDateMCAtom.typeID ||
+                type == RecordTypes.FooterMCAtom.typeID ||
+                type == RecordTypes.SlideNumberMCAtom.typeID
+                    ) return true;
+
+        }
+        return false;
+    }
 }

Modified: poi/branches/ooxml/src/scratchpad/src/org/apache/poi/hslf/model/PPGraphics2D.java
URL: http://svn.apache.org/viewvc/poi/branches/ooxml/src/scratchpad/src/org/apache/poi/hslf/model/PPGraphics2D.java?rev=650938&r1=650937&r2=650938&view=diff
==============================================================================
--- poi/branches/ooxml/src/scratchpad/src/org/apache/poi/hslf/model/PPGraphics2D.java (original)
+++ poi/branches/ooxml/src/scratchpad/src/org/apache/poi/hslf/model/PPGraphics2D.java Wed Apr 23 09:49:18 2008
@@ -27,7 +27,6 @@
 import java.awt.geom.*;
 import java.text.AttributedCharacterIterator;
 import java.util.Map;
-import java.util.ArrayList;
 import org.apache.poi.hslf.usermodel.RichTextRun;
 import org.apache.poi.hslf.exceptions.HSLFException;
 import org.apache.poi.util.POILogger;

Modified: poi/branches/ooxml/src/scratchpad/src/org/apache/poi/hslf/model/Picture.java
URL: http://svn.apache.org/viewvc/poi/branches/ooxml/src/scratchpad/src/org/apache/poi/hslf/model/Picture.java?rev=650938&r1=650937&r2=650938&view=diff
==============================================================================
--- poi/branches/ooxml/src/scratchpad/src/org/apache/poi/hslf/model/Picture.java (original)
+++ poi/branches/ooxml/src/scratchpad/src/org/apache/poi/hslf/model/Picture.java Wed Apr 23 09:49:18 2008
@@ -21,13 +21,16 @@
 import org.apache.poi.hslf.usermodel.SlideShow;
 import org.apache.poi.hslf.record.Document;
 import org.apache.poi.hslf.blip.Bitmap;
+import org.apache.poi.hslf.exceptions.HSLFException;
 import org.apache.poi.util.POILogger;
 
 import javax.imageio.ImageIO;
 import java.awt.image.BufferedImage;
 import java.awt.*;
+import java.awt.geom.Rectangle2D;
 import java.io.ByteArrayInputStream;
 import java.io.IOException;
+import java.io.UnsupportedEncodingException;
 import java.util.List;
 import java.util.Arrays;
 
@@ -128,7 +131,7 @@
 
         //set default properties for a picture
         EscherOptRecord opt = (EscherOptRecord)getEscherChild(_escherContainer, EscherOptRecord.RECORD_ID);
-        setEscherProperty(opt, EscherProperties.PROTECTION__LOCKAGAINSTGROUPING, 8388736);
+        setEscherProperty(opt, EscherProperties.PROTECTION__LOCKAGAINSTGROUPING, 0x800080);
 
         //another weird feature of powerpoint: for picture id we must add 0x4000.
         setEscherProperty(opt, (short)(EscherProperties.BLIP__BLIPTODISPLAY + 0x4000), idx);
@@ -193,13 +196,69 @@
     }
 
     /**
+     * Name of this picture.
+     *
+     * @return name of this picture
+     */
+    public String getPictureName(){
+        EscherOptRecord opt = (EscherOptRecord)getEscherChild(_escherContainer, EscherOptRecord.RECORD_ID);
+        EscherComplexProperty prop = (EscherComplexProperty)getEscherProperty(opt, EscherProperties.BLIP__BLIPFILENAME);
+        String name = null;
+        if(prop != null){
+            try {
+                name = new String(prop.getComplexData(), "UTF-16LE");
+                int idx = name.indexOf('\u0000');
+                return idx == -1 ? name : name.substring(0, idx);
+            } catch (UnsupportedEncodingException e){
+                throw new HSLFException(e);
+            }
+        }
+        return name;
+    }
+
+    /**
+     * Name of this picture.
+     *
+     * @param name of this picture
+     */
+    public void setPictureName(String name){
+        EscherOptRecord opt = (EscherOptRecord)getEscherChild(_escherContainer, EscherOptRecord.RECORD_ID);
+        try {
+            byte[] data = (name + '\u0000').getBytes("UTF-16LE");
+            EscherComplexProperty prop = new EscherComplexProperty(EscherProperties.BLIP__BLIPFILENAME, false, data);
+            opt.addEscherProperty(prop);
+        } catch (UnsupportedEncodingException e){
+            throw new HSLFException(e);
+        }
+    }
+
+    /**
      * By default set the orininal image size
      */
     protected void afterInsert(Sheet sh){
+        super.afterInsert(sh);
         java.awt.Rectangle anchor = getAnchor();
         if (anchor.equals(new java.awt.Rectangle())){
             setDefaultSize();
         }
     }
 
+    public void draw(Graphics2D graphics){
+        PictureData data = getPictureData();
+        if (data  instanceof Bitmap){
+            BufferedImage img = null;
+            try {
+               	img = ImageIO.read(new ByteArrayInputStream(data.getData()));
+            }
+            catch (Exception e){
+                logger.log(POILogger.WARN, "ImageIO failed to create image. image.type: " + data.getType());
+                return;
+            }
+            Rectangle anchor = getAnchor();
+            Image scaledImg = img.getScaledInstance(anchor.width, anchor.height, Image.SCALE_SMOOTH);
+            graphics.drawImage(scaledImg, anchor.x, anchor.y, null);
+        } else {
+            logger.log(POILogger.WARN, "Rendering of metafiles is not yet supported. image.type: " + (data == null ? "NA" : data.getClass().getName()));
+        }
+    }
 }

Modified: poi/branches/ooxml/src/scratchpad/src/org/apache/poi/hslf/model/Shape.java
URL: http://svn.apache.org/viewvc/poi/branches/ooxml/src/scratchpad/src/org/apache/poi/hslf/model/Shape.java?rev=650938&r1=650937&r2=650938&view=diff
==============================================================================
--- poi/branches/ooxml/src/scratchpad/src/org/apache/poi/hslf/model/Shape.java (original)
+++ poi/branches/ooxml/src/scratchpad/src/org/apache/poi/hslf/model/Shape.java Wed Apr 23 09:49:18 2008
@@ -17,12 +17,12 @@
 package org.apache.poi.hslf.model;
 
 import org.apache.poi.ddf.*;
-import org.apache.poi.hslf.model.ShapeTypes;
 import org.apache.poi.hslf.record.ColorSchemeAtom;
+import org.apache.poi.hslf.record.PPDrawing;
 import org.apache.poi.util.POILogger;
 import org.apache.poi.util.POILogFactory;
 
-import java.util.Iterator;
+import java.util.*;
 import java.awt.*;
 import java.awt.geom.Rectangle2D;
 
@@ -166,12 +166,24 @@
         if ((flags & EscherSpRecord.FLAG_CHILD) != 0){
             EscherChildAnchorRecord rec = (EscherChildAnchorRecord)getEscherChild(_escherContainer, EscherChildAnchorRecord.RECORD_ID);
             anchor = new java.awt.Rectangle();
-            anchor = new Rectangle2D.Float(
-                (float)rec.getDx1()*POINT_DPI/MASTER_DPI,
-                (float)rec.getDy1()*POINT_DPI/MASTER_DPI,
-                (float)(rec.getDx2()-rec.getDx1())*POINT_DPI/MASTER_DPI,
-                (float)(rec.getDy2()-rec.getDy1())*POINT_DPI/MASTER_DPI
-            );
+            if(rec == null){
+                logger.log(POILogger.WARN, "EscherSpRecord.FLAG_CHILD is set but EscherChildAnchorRecord was not found");
+                EscherClientAnchorRecord clrec = (EscherClientAnchorRecord)getEscherChild(_escherContainer, EscherClientAnchorRecord.RECORD_ID);
+                anchor = new java.awt.Rectangle();
+                anchor = new Rectangle2D.Float(
+                    (float)clrec.getCol1()*POINT_DPI/MASTER_DPI,
+                    (float)clrec.getFlag()*POINT_DPI/MASTER_DPI,
+                    (float)(clrec.getDx1()-clrec.getCol1())*POINT_DPI/MASTER_DPI,
+                    (float)(clrec.getRow1()-clrec.getFlag())*POINT_DPI/MASTER_DPI
+                );
+            } else {
+                anchor = new Rectangle2D.Float(
+                    (float)rec.getDx1()*POINT_DPI/MASTER_DPI,
+                    (float)rec.getDy1()*POINT_DPI/MASTER_DPI,
+                    (float)(rec.getDx2()-rec.getDx1())*POINT_DPI/MASTER_DPI,
+                    (float)(rec.getDy2()-rec.getDy1())*POINT_DPI/MASTER_DPI
+                );
+            }
         }
         else {
             EscherClientAnchorRecord rec = (EscherClientAnchorRecord)getEscherChild(_escherContainer, EscherClientAnchorRecord.RECORD_ID);
@@ -186,6 +198,10 @@
         return anchor;
     }
 
+    public Rectangle2D getLogicalAnchor2D(){
+        return getAnchor2D();
+    }
+
     /**
      * Sets the anchor (the bounding box rectangle) of this shape.
      * All coordinates should be expressed in points (72 dpi).
@@ -245,7 +261,7 @@
      * @return escher property or <code>null</code> if not found.
      */
      public static EscherProperty getEscherProperty(EscherOptRecord opt, int propId){
-        for ( Iterator iterator = opt.getEscherProperties().iterator(); iterator.hasNext(); )
+        if(opt != null) for ( Iterator iterator = opt.getEscherProperties().iterator(); iterator.hasNext(); )
         {
             EscherProperty prop = (EscherProperty) iterator.next();
             if (prop.getPropertyNumber() == propId)
@@ -294,7 +310,18 @@
    public int getEscherProperty(short propId){
         EscherOptRecord opt = (EscherOptRecord)getEscherChild(_escherContainer, EscherOptRecord.RECORD_ID);
         EscherSimpleProperty prop = (EscherSimpleProperty)getEscherProperty(opt, propId);
-        return prop == null ? 0 : prop.getPropertyNumber();
+        return prop == null ? 0 : prop.getPropertyValue();
+    }
+
+    /**
+     * Get the value of a simple escher property for this shape.
+     *
+     * @param propId    The id of the property. One of the constants defined in EscherOptRecord.
+     */
+   public int getEscherProperty(short propId, int defaultValue){
+        EscherOptRecord opt = (EscherOptRecord)getEscherChild(_escherContainer, EscherOptRecord.RECORD_ID);
+        EscherSimpleProperty prop = (EscherSimpleProperty)getEscherProperty(opt, propId);
+        return prop == null ? defaultValue : prop.getPropertyValue();
     }
 
     /**
@@ -314,7 +341,58 @@
      * @param sh - owning shape
      */
     protected void afterInsert(Sheet sh){
+        PPDrawing ppdrawing = sh.getPPDrawing();
+
+        EscherContainerRecord dgContainer = (EscherContainerRecord) ppdrawing.getEscherRecords()[0];
+
+        EscherDgRecord dg = (EscherDgRecord) Shape.getEscherChild(dgContainer, EscherDgRecord.RECORD_ID);
+
+        int id = allocateShapeId(dg);
+        setShapeId(id);
+    }
+
+    /**
+     * Allocates new shape id for the new drawing group id.
+     *
+     * @param dg  EscherDgRecord of the sheet that owns the shape being created
+     *
+     * @return a new shape id.
+     */
+    protected int allocateShapeId(EscherDgRecord dg)
+    {
+        EscherDggRecord dgg = _sheet.getSlideShow().getDocumentRecord().getPPDrawingGroup().getEscherDggRecord();
+        if(dgg == null){
+            logger.log(POILogger.ERROR, "EscherDggRecord not found");
+            return 0;
+        }
+
+        dgg.setNumShapesSaved( dgg.getNumShapesSaved() + 1 );
+
+        // Add to existing cluster if space available
+        for (int i = 0; i < dgg.getFileIdClusters().length; i++)
+        {
+            EscherDggRecord.FileIdCluster c = dgg.getFileIdClusters()[i];
+            if (c.getDrawingGroupId() == dg.getDrawingGroupId() && c.getNumShapeIdsUsed() != 1024)
+            {
+                int result = c.getNumShapeIdsUsed() + (1024 * (i+1));
+                c.incrementShapeId();
+                dg.setNumShapes( dg.getNumShapes() + 1 );
+                dg.setLastMSOSPID( result );
+                if (result >= dgg.getShapeIdMax())
+                    dgg.setShapeIdMax( result + 1 );
+                return result;
+            }
+        }
 
+        // Create new cluster
+        dgg.addCluster( dg.getDrawingGroupId(), 0 );
+        dgg.getFileIdClusters()[dgg.getFileIdClusters().length-1].incrementShapeId();
+        dg.setNumShapes( dg.getNumShapes() + 1 );
+        int result = (1024 * dgg.getFileIdClusters().length);
+        dg.setLastMSOSPID( result );
+        if (result >= dgg.getShapeIdMax())
+            dgg.setShapeIdMax( result + 1 );
+        return result;
     }
 
     /**
@@ -333,14 +411,32 @@
         _sheet = sheet;
     }
 
-    protected Color getColor(int rgb){
+    protected Color getColor(int rgb, int alpha){
         if (rgb >= 0x8000000) {
             int idx = rgb - 0x8000000;
             ColorSchemeAtom ca = getSheet().getColorScheme();
             if(idx >= 0 && idx <= 7) rgb = ca.getColor(idx);
         }
         Color tmp = new Color(rgb, true);
-        return new Color(tmp.getBlue(), tmp.getGreen(), tmp.getRed());
+        return new Color(tmp.getBlue(), tmp.getGreen(), tmp.getRed(), alpha);
+    }
+
+    /**
+     * @return id for the shape.
+     */
+    public int getShapeId(){
+        EscherSpRecord spRecord = _escherContainer.getChildById(EscherSpRecord.RECORD_ID);
+        return spRecord == null ? 0 : spRecord.getShapeId();
+    }
+
+    /**
+     * Sets shape ID
+     *
+     * @param id of the shape
+     */
+    public void setShapeId(int id){
+        EscherSpRecord spRecord = _escherContainer.getChildById(EscherSpRecord.RECORD_ID);
+        if(spRecord != null) spRecord.setShapeId(id);
     }
 
     /**
@@ -364,4 +460,16 @@
         return Hyperlink.find(this);
     }
 
+    public void draw(Graphics2D graphics){
+        logger.log(POILogger.INFO, "Rendering " + getShapeName());
+    }
+
+    /**
+     * Return shape outline as a java.awt.Shape object
+     *
+     * @return the shape outline
+     */
+    public java.awt.Shape getOutline(){
+        return getLogicalAnchor2D();
+    }
 }

Modified: poi/branches/ooxml/src/scratchpad/src/org/apache/poi/hslf/model/ShapeFactory.java
URL: http://svn.apache.org/viewvc/poi/branches/ooxml/src/scratchpad/src/org/apache/poi/hslf/model/ShapeFactory.java?rev=650938&r1=650937&r2=650938&view=diff
==============================================================================
--- poi/branches/ooxml/src/scratchpad/src/org/apache/poi/hslf/model/ShapeFactory.java (original)
+++ poi/branches/ooxml/src/scratchpad/src/org/apache/poi/hslf/model/ShapeFactory.java Wed Apr 23 09:49:18 2008
@@ -76,13 +76,19 @@
             case ShapeTypes.TextBox:
                 shape = new TextBox(spContainer, parent);
                 break;
-            case ShapeTypes.PictureFrame:
-                shape = new Picture(spContainer, parent);
+            case ShapeTypes.PictureFrame: {
+                EscherOptRecord opt = (EscherOptRecord)Shape.getEscherChild(spContainer, EscherOptRecord.RECORD_ID);
+                EscherProperty prop = Shape.getEscherProperty(opt, EscherProperties.BLIP__PICTUREID);
+                if(prop != null)
+                    shape = new OLEShape(spContainer, parent); //presence of BLIP__PICTUREID indicates it is an embedded object 
+                else
+                    shape = new Picture(spContainer, parent);
                 break;
+            }
             case ShapeTypes.Line:
                 shape = new Line(spContainer, parent);
                 break;
-            case ShapeTypes.NotPrimitive:
+            case ShapeTypes.NotPrimitive: {
                 EscherOptRecord opt = (EscherOptRecord)Shape.getEscherChild(spContainer, EscherOptRecord.RECORD_ID);
                 EscherProperty prop = Shape.getEscherProperty(opt, EscherProperties.GEOMETRY__VERTICES);
                 if(prop != null)
@@ -93,6 +99,7 @@
                     shape = new AutoShape(spContainer, parent);
                 }
                 break;
+            }
             default:
                 shape = new AutoShape(spContainer, parent);
                 break;

Modified: poi/branches/ooxml/src/scratchpad/src/org/apache/poi/hslf/model/ShapeGroup.java
URL: http://svn.apache.org/viewvc/poi/branches/ooxml/src/scratchpad/src/org/apache/poi/hslf/model/ShapeGroup.java?rev=650938&r1=650937&r2=650938&view=diff
==============================================================================
--- poi/branches/ooxml/src/scratchpad/src/org/apache/poi/hslf/model/ShapeGroup.java (original)
+++ poi/branches/ooxml/src/scratchpad/src/org/apache/poi/hslf/model/ShapeGroup.java Wed Apr 23 09:49:18 2008
@@ -24,6 +24,8 @@
 import java.util.ArrayList;
 import java.util.List;
 import java.awt.geom.Rectangle2D;
+import java.awt.geom.AffineTransform;
+import java.awt.*;
 
 /**
  *  Represents a group of shapes.
@@ -114,6 +116,47 @@
     }
 
     /**
+     * Sets the coordinate space of this group.  All children are constrained
+     * to these coordinates.
+     *
+     * @param anchor the coordinate space of this group
+     */
+    public void setCoordinates(Rectangle2D anchor){
+        EscherContainerRecord spContainer = (EscherContainerRecord)_escherContainer.getChildRecords().get(0);
+        EscherSpgrRecord spgr = (EscherSpgrRecord)getEscherChild(spContainer, EscherSpgrRecord.RECORD_ID);
+
+        int x1 = (int)Math.round(anchor.getX()*MASTER_DPI/POINT_DPI);
+        int y1 = (int)Math.round(anchor.getY()*MASTER_DPI/POINT_DPI);
+        int x2 = (int)Math.round((anchor.getX() + anchor.getWidth())*MASTER_DPI/POINT_DPI);
+        int y2 = (int)Math.round((anchor.getY() + anchor.getHeight())*MASTER_DPI/POINT_DPI);
+
+        spgr.setRectX1(x1);
+        spgr.setRectY1(y1);
+        spgr.setRectX2(x2);
+        spgr.setRectY2(y2);
+
+    }
+
+    /**
+     * Gets the coordinate space of this group.  All children are constrained
+     * to these coordinates.
+     *
+     * @return the coordinate space of this group
+     */
+    public Rectangle2D getCoordinates(){
+        EscherContainerRecord spContainer = (EscherContainerRecord)_escherContainer.getChildRecords().get(0);
+        EscherSpgrRecord spgr = (EscherSpgrRecord)getEscherChild(spContainer, EscherSpgrRecord.RECORD_ID);
+
+        Rectangle2D.Float anchor = new Rectangle2D.Float();
+        anchor.x = (float)spgr.getRectX1()*POINT_DPI/MASTER_DPI;
+        anchor.y = (float)spgr.getRectY1()*POINT_DPI/MASTER_DPI;
+        anchor.width = (float)(spgr.getRectX2() - spgr.getRectX1())*POINT_DPI/MASTER_DPI;
+        anchor.height = (float)(spgr.getRectY2() - spgr.getRectY1())*POINT_DPI/MASTER_DPI;
+
+        return anchor;
+    }
+
+    /**
      * Create a new ShapeGroup and create an instance of <code>EscherSpgrContainer</code> which represents a group of shapes
      */
     protected EscherContainerRecord createSpContainer(boolean isChild) {
@@ -190,14 +233,24 @@
      * @return the anchor of this shape group
      */
     public Rectangle2D getAnchor2D(){
-        EscherContainerRecord groupInfoContainer = (EscherContainerRecord)_escherContainer.getChild(0);
-        EscherSpgrRecord spgr = (EscherSpgrRecord)getEscherChild(groupInfoContainer, EscherSpgrRecord.RECORD_ID);
-        Rectangle2D anchor = new Rectangle2D.Float(
-            (float)spgr.getRectX1()*POINT_DPI/MASTER_DPI,
-            (float)spgr.getRectY1()*POINT_DPI/MASTER_DPI,
-            (float)(spgr.getRectX2() - spgr.getRectX1())*POINT_DPI/MASTER_DPI,
-            (float)(spgr.getRectY2() - spgr.getRectY1())*POINT_DPI/MASTER_DPI
-        );
+        EscherContainerRecord spContainer = (EscherContainerRecord)_escherContainer.getChildRecords().get(0);
+        EscherClientAnchorRecord clientAnchor = (EscherClientAnchorRecord)getEscherChild(spContainer, EscherClientAnchorRecord.RECORD_ID);
+        Rectangle2D.Float anchor = new Rectangle2D.Float();
+        if(clientAnchor == null){
+            logger.log(POILogger.INFO, "EscherClientAnchorRecord was not found for shape group. Searching for EscherChildAnchorRecord.");
+            EscherChildAnchorRecord rec = (EscherChildAnchorRecord)getEscherChild(spContainer, EscherChildAnchorRecord.RECORD_ID);
+            anchor = new Rectangle2D.Float(
+                (float)rec.getDx1()*POINT_DPI/MASTER_DPI,
+                (float)rec.getDy1()*POINT_DPI/MASTER_DPI,
+                (float)(rec.getDx2()-rec.getDx1())*POINT_DPI/MASTER_DPI,
+                (float)(rec.getDy2()-rec.getDy1())*POINT_DPI/MASTER_DPI
+            );
+        } else {
+            anchor.x = (float)clientAnchor.getCol1()*POINT_DPI/MASTER_DPI;
+            anchor.y = (float)clientAnchor.getFlag()*POINT_DPI/MASTER_DPI;
+            anchor.width = (float)(clientAnchor.getDx1() - clientAnchor.getCol1())*POINT_DPI/MASTER_DPI ;
+            anchor.height = (float)(clientAnchor.getRow1() - clientAnchor.getFlag())*POINT_DPI/MASTER_DPI;
+        }
 
         return anchor;
     }
@@ -222,5 +275,27 @@
      public Hyperlink getHyperlink(){
         return null;
     }
-    
+
+    public void draw(Graphics2D graphics){
+        Rectangle2D anchor = getAnchor2D();
+        Rectangle2D coords = getCoordinates();
+
+        //transform coordinates
+        AffineTransform at = graphics.getTransform();
+        /*
+        if(!anchor.equals(coords)){
+            graphics.scale(anchor.getWidth()/coords.getWidth(), anchor.getHeight()/coords.getHeight());
+
+            graphics.translate(
+                    anchor.getX()*coords.getWidth()/anchor.getWidth() - coords.getX(),
+                    anchor.getY()*coords.getHeight()/anchor.getHeight() - coords.getY());
+        }
+        */
+        Shape[] sh = getShapes();
+        for (int i = 0; i < sh.length; i++) {
+            sh[i].draw(graphics);
+        }
+
+        graphics.setTransform(at);
+    }
 }

Modified: poi/branches/ooxml/src/scratchpad/src/org/apache/poi/hslf/model/Sheet.java
URL: http://svn.apache.org/viewvc/poi/branches/ooxml/src/scratchpad/src/org/apache/poi/hslf/model/Sheet.java?rev=650938&r1=650937&r2=650938&view=diff
==============================================================================
--- poi/branches/ooxml/src/scratchpad/src/org/apache/poi/hslf/model/Sheet.java (original)
+++ poi/branches/ooxml/src/scratchpad/src/org/apache/poi/hslf/model/Sheet.java Wed Apr 23 09:49:18 2008
@@ -29,6 +29,7 @@
 import java.util.Iterator;
 import java.util.List;
 import java.util.Vector;
+import java.awt.*;
 
 /**
  * This class defines the common format of "Sheets" in a powerpoint
@@ -246,14 +247,6 @@
         EscherContainerRecord spgr = (EscherContainerRecord) Shape.getEscherChild(dgContainer, EscherContainerRecord.SPGR_CONTAINER);
         spgr.addChildRecord(shape.getSpContainer());
 
-        EscherDgRecord dg = (EscherDgRecord) Shape.getEscherChild(dgContainer, EscherDgRecord.RECORD_ID);
-        dg.setNumShapes(dg.getNumShapes() + 1);
-
-        int shapeId = dg.getLastMSOSPID()+1;
-        dg.setLastMSOSPID(shapeId);
-
-        EscherSpRecord sp = shape.getSpContainer().getChildById(EscherSpRecord.RECORD_ID);
-        if(sp != null) sp.setShapeId(shapeId);
         shape.setSheet(this);
         shape.afterInsert(this);
 
@@ -329,4 +322,7 @@
         return _background;
     }
 
+    public void draw(Graphics2D graphics){
+
+    }
 }

Modified: poi/branches/ooxml/src/scratchpad/src/org/apache/poi/hslf/model/SimpleShape.java
URL: http://svn.apache.org/viewvc/poi/branches/ooxml/src/scratchpad/src/org/apache/poi/hslf/model/SimpleShape.java?rev=650938&r1=650937&r2=650938&view=diff
==============================================================================
--- poi/branches/ooxml/src/scratchpad/src/org/apache/poi/hslf/model/SimpleShape.java (original)
+++ poi/branches/ooxml/src/scratchpad/src/org/apache/poi/hslf/model/SimpleShape.java Wed Apr 23 09:49:18 2008
@@ -22,6 +22,8 @@
 import org.apache.poi.hslf.record.ColorSchemeAtom;
 
 import java.awt.*;
+import java.awt.geom.AffineTransform;
+import java.awt.geom.Rectangle2D;
 
 /**
  *  An abstract simple (non-group) shape.
@@ -199,4 +201,87 @@
         getFill().setForegroundColor(color);
     }
 
+    /**
+     * Whether the shape is horizontally flipped
+     *
+     * @return whether the shape is horizontally flipped
+     */
+     public boolean getFlipHorizontal(){
+        EscherSpRecord spRecord = _escherContainer.getChildById(EscherSpRecord.RECORD_ID);
+        return (spRecord.getFlags()& EscherSpRecord.FLAG_FLIPHORIZ) != 0;
+    }
+
+    /**
+     * Whether the shape is vertically flipped
+     *
+     * @return whether the shape is vertically flipped
+     */
+    public boolean getFlipVertical(){
+        EscherSpRecord spRecord = _escherContainer.getChildById(EscherSpRecord.RECORD_ID);
+        return (spRecord.getFlags()& EscherSpRecord.FLAG_FLIPVERT) != 0;
+    }
+
+    /**
+     * Rotation angle in degrees
+     *
+     * @return rotation angle in degrees
+     */
+    public int getRotation(){
+        int rot = getEscherProperty(EscherProperties.TRANSFORM__ROTATION);
+        int angle = (rot >> 16) % 360;
+
+        return angle;
+    }
+
+    public Rectangle2D getLogicalAnchor2D(){
+        Rectangle2D anchor = getAnchor2D();
+
+        //if it is a groupped shape see if we need to transform the coordinates
+        if (_parent != null){
+            Shape top = _parent;
+            while(top.getParent() != null) top = top.getParent();
+
+            Rectangle2D clientAnchor = top.getAnchor2D();
+            Rectangle2D spgrAnchor = ((ShapeGroup)top).getCoordinates();
+
+            double scalex = (double)spgrAnchor.getWidth()/clientAnchor.getWidth();
+            double scaley = (double)spgrAnchor.getHeight()/clientAnchor.getHeight();
+
+            double x = clientAnchor.getX() + (anchor.getX() - spgrAnchor.getX())/scalex;
+            double y = clientAnchor.getY() + (anchor.getY() - spgrAnchor.getY())/scaley;
+            double width = anchor.getWidth()/scalex;
+            double height = anchor.getHeight()/scaley;
+
+            anchor = new Rectangle2D.Double(x, y, width, height);
+
+        }
+
+        int angle = getRotation();
+        if(angle != 0){
+            double centerX = anchor.getX() + anchor.getWidth()/2;
+            double centerY = anchor.getY() + anchor.getHeight()/2;
+
+            AffineTransform trans = new AffineTransform();
+            trans.translate(centerX, centerY);
+            trans.rotate(Math.toRadians(angle));
+            trans.translate(-centerX, -centerY);
+
+            Rectangle2D rect = trans.createTransformedShape(anchor).getBounds2D();
+            if((anchor.getWidth() < anchor.getHeight() && rect.getWidth() > rect.getHeight()) ||
+                (anchor.getWidth() > anchor.getHeight() && rect.getWidth() < rect.getHeight())    ){
+                trans = new AffineTransform();
+                trans.translate(centerX, centerY);
+                trans.rotate(Math.PI/2);
+                trans.translate(-centerX, -centerY);
+                anchor = trans.createTransformedShape(anchor).getBounds2D();
+            }
+        }
+        return anchor;
+    }
+
+    public void draw(Graphics2D graphics){
+        AffineTransform at = graphics.getTransform();
+        ShapePainter.paint(this, graphics);
+        graphics.setTransform(at);
+    }
 }

Modified: poi/branches/ooxml/src/scratchpad/src/org/apache/poi/hslf/model/Slide.java
URL: http://svn.apache.org/viewvc/poi/branches/ooxml/src/scratchpad/src/org/apache/poi/hslf/model/Slide.java?rev=650938&r1=650937&r2=650938&view=diff
==============================================================================
--- poi/branches/ooxml/src/scratchpad/src/org/apache/poi/hslf/model/Slide.java (original)
+++ poi/branches/ooxml/src/scratchpad/src/org/apache/poi/hslf/model/Slide.java Wed Apr 23 09:49:18 2008
@@ -21,17 +21,12 @@
 package org.apache.poi.hslf.model;
 
 import java.util.Vector;
-import java.util.List;
-import java.util.Iterator;
-import java.util.ArrayList;
+import java.awt.*;
 
-import org.apache.poi.hslf.record.PPDrawing;
 import org.apache.poi.hslf.record.SlideAtom;
 import org.apache.poi.hslf.record.TextHeaderAtom;
 import org.apache.poi.hslf.record.ColorSchemeAtom;
 import org.apache.poi.hslf.record.SlideListWithText.SlideAtomsSet;
-import org.apache.poi.ddf.EscherContainerRecord;
-import org.apache.poi.ddf.EscherRecord;
 
 /**
  * This class represents a slide in a PowerPoint Document. It allows 
@@ -263,10 +258,85 @@
         return sa.getFollowMasterBackground();
     }
 
-    public Background getBackground() {
+    /**
+     * Sets whether this slide draws master sheet objects
+     *
+     * @param flag  <code>true</code> if the slide draws master sheet objects,
+     * <code>false</code> otherwise
+     */
+    public void setFollowMasterObjects(boolean flag){
+        SlideAtom sa = getSlideRecord().getSlideAtom();
+        sa.setFollowMasterObjects(flag);
+    }
+
+    /**
+     * Whether this slide follows master color scheme
+     *
+     * @return <code>true</code> if the slide follows master color scheme,
+     * <code>false</code> otherwise
+     */
+    public boolean getFollowMasterScheme(){
+        SlideAtom sa = getSlideRecord().getSlideAtom();
+        return sa.getFollowMasterScheme();
+    }
+
+    /**
+     * Sets whether this slide draws master color scheme
+     *
+     * @param flag  <code>true</code> if the slide draws master color scheme,
+     * <code>false</code> otherwise
+     */
+    public void setFollowMasterScheme(boolean flag){
+        SlideAtom sa = getSlideRecord().getSlideAtom();
+        sa.setFollowMasterScheme(flag);
+    }
+
+    /**
+     * Whether this slide draws master sheet objects
+     *
+     * @return <code>true</code> if the slide draws master sheet objects,
+     * <code>false</code> otherwise
+     */
+    public boolean getFollowMasterObjects(){
+        SlideAtom sa = getSlideRecord().getSlideAtom();
+        return sa.getFollowMasterObjects();
+    }
+
+    /**
+     * Background for this slide.
+     */
+     public Background getBackground() {
         if(getFollowMasterBackground())
             return getMasterSheet().getBackground();
         else
             return super.getBackground();
     }
+
+    /**
+     * Color scheme for this slide.
+     */
+    public ColorSchemeAtom getColorScheme() {
+        if(getFollowMasterScheme()){
+            return getMasterSheet().getColorScheme();
+        }
+        return super.getColorScheme();
+    }
+
+    public void draw(Graphics2D graphics){
+        MasterSheet master = getMasterSheet();
+        if(getFollowMasterBackground()) master.getBackground().draw(graphics);
+        if(getFollowMasterObjects()){
+            Shape[] sh = master.getShapes();
+            for (int i = 0; i < sh.length; i++) {
+                if(MasterSheet.isPlaceholder(sh[i])) continue;
+
+                sh[i].draw(graphics);
+            }
+        }
+        Shape[] sh = getShapes();
+        for (int i = 0; i < sh.length; i++) {
+            sh[i].draw(graphics);
+        }
+    }
+
 }

Modified: poi/branches/ooxml/src/scratchpad/src/org/apache/poi/hslf/model/SlideMaster.java
URL: http://svn.apache.org/viewvc/poi/branches/ooxml/src/scratchpad/src/org/apache/poi/hslf/model/SlideMaster.java?rev=650938&r1=650937&r2=650938&view=diff
==============================================================================
--- poi/branches/ooxml/src/scratchpad/src/org/apache/poi/hslf/model/SlideMaster.java (original)
+++ poi/branches/ooxml/src/scratchpad/src/org/apache/poi/hslf/model/SlideMaster.java Wed Apr 23 09:49:18 2008
@@ -21,12 +21,6 @@
 import org.apache.poi.hslf.model.textproperties.TextPropCollection;
 import org.apache.poi.hslf.record.*;
 import org.apache.poi.hslf.usermodel.SlideShow;
-import org.apache.poi.hslf.record.StyleTextPropAtom.*;
-import org.apache.poi.ddf.EscherContainerRecord;
-import org.apache.poi.ddf.EscherRecord;
-
-import java.util.List;
-import java.util.Iterator;
 
 /**
  * SlideMaster determines the graphics, layout, and formatting for all the slides in a given presentation.
@@ -82,17 +76,31 @@
             if (prop != null) break;
         }
         if (prop == null) {
-            switch (txtype) {
-                case TextHeaderAtom.CENTRE_BODY_TYPE:
-                case TextHeaderAtom.HALF_BODY_TYPE:
-                case TextHeaderAtom.QUARTER_BODY_TYPE:
-                    txtype = TextHeaderAtom.BODY_TYPE;
-                    break;
-                case TextHeaderAtom.CENTER_TITLE_TYPE:
-                    txtype = TextHeaderAtom.TITLE_TYPE;
-                    break;
-                default:
-                    return null;
+            if(isCharacter) {
+                switch (txtype) {
+                    case TextHeaderAtom.CENTRE_BODY_TYPE:
+                    case TextHeaderAtom.HALF_BODY_TYPE:
+                    case TextHeaderAtom.QUARTER_BODY_TYPE:
+                        txtype = TextHeaderAtom.BODY_TYPE;
+                        break;
+                    case TextHeaderAtom.CENTER_TITLE_TYPE:
+                        txtype = TextHeaderAtom.TITLE_TYPE;
+                        break;
+                    default:
+                        return null;
+                }
+            } else {
+                switch (txtype) {
+                    case TextHeaderAtom.CENTRE_BODY_TYPE:
+                    case TextHeaderAtom.QUARTER_BODY_TYPE:
+                        txtype = TextHeaderAtom.BODY_TYPE;
+                        break;
+                    case TextHeaderAtom.CENTER_TITLE_TYPE:
+                        txtype = TextHeaderAtom.TITLE_TYPE;
+                        break;
+                    default:
+                        return null;
+                }
             }
             prop = getStyleAttribute(txtype, level, name, isCharacter);
         }
@@ -118,5 +126,35 @@
                 _txmaster[txrec[i].getTextType()] = txrec[i];
             }
         }
+    }
+
+    /**
+     * Checks if the shape is a placeholder.
+     * (placeholders aren't normal shapes, they are visible only in the Edit Master mode)
+     *
+     *
+     * @return true if the shape is a placeholder
+     */
+    public static boolean isPlaceholder(Shape shape){
+        if(!(shape instanceof TextShape)) return false;
+
+        TextShape tx = (TextShape)shape;
+        TextRun run = tx.getTextRun();
+        if(run == null) return false;
+
+        Record[] records = run._records;
+        for (int i = 0; i < records.length; i++) {
+            int type = (int)records[i].getRecordType();
+            if (type == RecordTypes.OEPlaceholderAtom.typeID ||
+                    type == RecordTypes.SlideNumberMCAtom.typeID ||
+                    type == RecordTypes.DateTimeMCAtom.typeID ||
+                    type == RecordTypes.GenericDateMCAtom.typeID ||
+                    type == RecordTypes.FooterMCAtom.typeID ){
+                return true;
+
+            }
+
+        }
+        return false;
     }
 }

Modified: poi/branches/ooxml/src/scratchpad/src/org/apache/poi/hslf/model/Table.java
URL: http://svn.apache.org/viewvc/poi/branches/ooxml/src/scratchpad/src/org/apache/poi/hslf/model/Table.java?rev=650938&r1=650937&r2=650938&view=diff
==============================================================================
--- poi/branches/ooxml/src/scratchpad/src/org/apache/poi/hslf/model/Table.java (original)
+++ poi/branches/ooxml/src/scratchpad/src/org/apache/poi/hslf/model/Table.java Wed Apr 23 09:49:18 2008
@@ -23,7 +23,6 @@
 import java.util.*;
 import java.util.List;
 import java.awt.*;
-import java.awt.geom.Rectangle2D;
 
 /**
  * Represents a table in a PowerPoint presentation
@@ -113,6 +112,8 @@
     }
 
     protected void afterInsert(Sheet sh){
+        super.afterInsert(sh);
+
         EscherContainerRecord spCont = (EscherContainerRecord) getSpContainer().getChild(0);
         List lst = spCont.getChildRecords();
         EscherOptRecord opt = (EscherOptRecord)lst.get(lst.size()-2);

Modified: poi/branches/ooxml/src/scratchpad/src/org/apache/poi/hslf/model/TableCell.java
URL: http://svn.apache.org/viewvc/poi/branches/ooxml/src/scratchpad/src/org/apache/poi/hslf/model/TableCell.java?rev=650938&r1=650937&r2=650938&view=diff
==============================================================================
--- poi/branches/ooxml/src/scratchpad/src/org/apache/poi/hslf/model/TableCell.java (original)
+++ poi/branches/ooxml/src/scratchpad/src/org/apache/poi/hslf/model/TableCell.java Wed Apr 23 09:49:18 2008
@@ -18,9 +18,7 @@
 package org.apache.poi.hslf.model;
 
 import org.apache.poi.ddf.*;
-import org.apache.poi.hslf.record.EscherTextboxWrapper;
 import org.apache.poi.hslf.record.TextHeaderAtom;
-import org.apache.poi.hslf.usermodel.RichTextRun;
 
 import java.awt.*;
 

Modified: poi/branches/ooxml/src/scratchpad/src/org/apache/poi/hslf/model/TextBox.java
URL: http://svn.apache.org/viewvc/poi/branches/ooxml/src/scratchpad/src/org/apache/poi/hslf/model/TextBox.java?rev=650938&r1=650937&r2=650938&view=diff
==============================================================================
--- poi/branches/ooxml/src/scratchpad/src/org/apache/poi/hslf/model/TextBox.java (original)
+++ poi/branches/ooxml/src/scratchpad/src/org/apache/poi/hslf/model/TextBox.java Wed Apr 23 09:49:18 2008
@@ -19,15 +19,6 @@
 package org.apache.poi.hslf.model;
 
 import org.apache.poi.ddf.*;
-import org.apache.poi.hslf.record.*;
-import org.apache.poi.hslf.usermodel.RichTextRun;
-import org.apache.poi.hslf.exceptions.HSLFException;
-import org.apache.poi.util.POILogger;
-
-import java.awt.*;
-import java.awt.font.FontRenderContext;
-import java.awt.font.TextLayout;
-import java.io.IOException;
 
 /**
  * Represents a TextFrame shape in PowerPoint.

Modified: poi/branches/ooxml/src/scratchpad/src/org/apache/poi/hslf/model/TextRun.java
URL: http://svn.apache.org/viewvc/poi/branches/ooxml/src/scratchpad/src/org/apache/poi/hslf/model/TextRun.java?rev=650938&r1=650937&r2=650938&view=diff
==============================================================================
--- poi/branches/ooxml/src/scratchpad/src/org/apache/poi/hslf/model/TextRun.java (original)
+++ poi/branches/ooxml/src/scratchpad/src/org/apache/poi/hslf/model/TextRun.java Wed Apr 23 09:49:18 2008
@@ -534,6 +534,10 @@
 		// The messes things up on everything but a Mac, so translate
 		//  them to \n
 		String text = rawText.replace('\r','\n');
+
+        //0xB acts like cariage return in page titles
+        text = text.replace((char) 0x0B, '\n');
+
 		return text;
 	}
 
@@ -635,4 +639,20 @@
     public Hyperlink[] getHyperlinks(){
         return Hyperlink.find(this);
     }
+
+    /**
+     * Fetch RichTextRun at a given position
+     *
+     * @param pos 0-based index in the text
+     * @return RichTextRun or null if not found
+     */
+    public RichTextRun getRichTextRunAt(int pos){
+        for (int i = 0; i < _rtRuns.length; i++) {
+            int start = _rtRuns[i].getStartIndex();
+            int end = _rtRuns[i].getEndIndex();
+            if(pos >= start && pos < end) return _rtRuns[i];
+        }
+        return null;
+    }
+
 }



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