You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@poi.apache.org by ye...@apache.org on 2012/11/07 09:33:35 UTC

svn commit: r1406496 - in /poi/trunk: src/examples/src/org/apache/poi/xslf/usermodel/ src/ooxml/testcases/org/apache/poi/xslf/usermodel/ test-data/slideshow/

Author: yegor
Date: Wed Nov  7 08:33:34 2012
New Revision: 1406496

URL: http://svn.apache.org/viewvc?rev=1406496&view=rev
Log:
example how to create pptx pie chart from template, more tests for poi-ooxml

Added:
    poi/trunk/src/examples/src/org/apache/poi/xslf/usermodel/PieChartDemo.java
    poi/trunk/src/examples/src/org/apache/poi/xslf/usermodel/pie-chart-data.txt   (with props)
    poi/trunk/src/examples/src/org/apache/poi/xslf/usermodel/pie-chart-template.pptx   (with props)
    poi/trunk/src/ooxml/testcases/org/apache/poi/xslf/usermodel/TestXSLFChart.java
      - copied, changed from r1403727, poi/trunk/src/ooxml/testcases/org/apache/poi/xslf/usermodel/TestXSLFConnectorShape.java
    poi/trunk/test-data/slideshow/pie-chart.pptx   (with props)
Modified:
    poi/trunk/src/ooxml/testcases/org/apache/poi/xslf/usermodel/TestXSLFConnectorShape.java

Added: poi/trunk/src/examples/src/org/apache/poi/xslf/usermodel/PieChartDemo.java
URL: http://svn.apache.org/viewvc/poi/trunk/src/examples/src/org/apache/poi/xslf/usermodel/PieChartDemo.java?rev=1406496&view=auto
==============================================================================
--- poi/trunk/src/examples/src/org/apache/poi/xslf/usermodel/PieChartDemo.java (added)
+++ poi/trunk/src/examples/src/org/apache/poi/xslf/usermodel/PieChartDemo.java Wed Nov  7 08:33:34 2012
@@ -0,0 +1,152 @@
+/*
+ *  ====================================================================
+ *    Licensed to the Apache Software Foundation (ASF) under one or more
+ *    contributor license agreements.  See the NOTICE file distributed with
+ *    this work for additional information regarding copyright ownership.
+ *    The ASF licenses this file to You under the Apache License, Version 2.0
+ *    (the "License"); you may not use this file except in compliance with
+ *    the License.  You may obtain a copy of the License at
+ *
+ *        http://www.apache.org/licenses/LICENSE-2.0
+ *
+ *    Unless required by applicable law or agreed to in writing, software
+ *    distributed under the License is distributed on an "AS IS" BASIS,
+ *    WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ *    See the License for the specific language governing permissions and
+ *    limitations under the License.
+ * ====================================================================
+ */
+
+package org.apache.poi.xslf.usermodel;
+
+import org.apache.poi.POIXMLDocumentPart;
+import org.apache.poi.ss.util.CellRangeAddress;
+import org.apache.poi.ss.util.CellReference;
+import org.apache.poi.xssf.usermodel.XSSFRow;
+import org.apache.poi.xssf.usermodel.XSSFSheet;
+import org.apache.poi.xssf.usermodel.XSSFWorkbook;
+import org.openxmlformats.schemas.drawingml.x2006.chart.CTAxDataSource;
+import org.openxmlformats.schemas.drawingml.x2006.chart.CTChart;
+import org.openxmlformats.schemas.drawingml.x2006.chart.CTNumData;
+import org.openxmlformats.schemas.drawingml.x2006.chart.CTNumDataSource;
+import org.openxmlformats.schemas.drawingml.x2006.chart.CTNumVal;
+import org.openxmlformats.schemas.drawingml.x2006.chart.CTPieChart;
+import org.openxmlformats.schemas.drawingml.x2006.chart.CTPieSer;
+import org.openxmlformats.schemas.drawingml.x2006.chart.CTPlotArea;
+import org.openxmlformats.schemas.drawingml.x2006.chart.CTSerTx;
+import org.openxmlformats.schemas.drawingml.x2006.chart.CTStrData;
+import org.openxmlformats.schemas.drawingml.x2006.chart.CTStrVal;
+
+import java.io.BufferedReader;
+import java.io.FileInputStream;
+import java.io.FileOutputStream;
+import java.io.FileReader;
+import java.io.OutputStream;
+
+/**
+ * Build a pie chart from a template pptx
+ *
+ * @author Yegor Kozlov
+ */
+public class PieChartDemo {
+    private static void usage(){
+        System.out.println("Usage: PieChartDemo <pie-chart-template.pptx> <pie-chart-data.txt>");
+        System.out.println("    pie-chart-template.pptx     template with a pie chart");
+        System.out.println("    pie-chart-data.txt          the model to set. First line is chart title, " +
+                "then go pairs {axis-label value}");
+    }
+
+    public static void main(String[] args) throws Exception {
+        if(args.length < 2) {
+            usage();
+            return;
+        }
+
+        BufferedReader modelReader = new BufferedReader(new FileReader(args[1]));
+
+        String chartTitle = modelReader.readLine();  // first line is chart title
+
+        XMLSlideShow pptx = new XMLSlideShow(new FileInputStream(args[0]));
+        XSLFSlide slide = pptx.getSlides()[0];
+
+        // find chart in the slide
+        XSLFChart chart = null;
+        for(POIXMLDocumentPart part : slide.getRelations()){
+            if(part instanceof XSLFChart){
+                chart = (XSLFChart) part;
+                break;
+            }
+        }
+
+        if(chart == null) throw new IllegalStateException("chart not found in the template");
+
+        // embedded Excel workbook that holds the chart data
+        POIXMLDocumentPart xlsPart = chart.getRelations().get(0);
+        XSSFWorkbook wb = new XSSFWorkbook();
+        XSSFSheet sheet = wb.createSheet();
+
+        CTChart ctChart = chart.getCTChart();
+        CTPlotArea plotArea = ctChart.getPlotArea();
+
+        CTPieChart pieChart = plotArea.getPieChartArray(0);
+        //Pie Chart Series
+        CTPieSer ser = pieChart.getSerArray(0);
+
+        // Series Text
+        CTSerTx tx = ser.getTx();
+        tx.getStrRef().getStrCache().getPtArray(0).setV(chartTitle);
+        sheet.createRow(0).createCell(1).setCellValue(chartTitle);
+        String titleRef = new CellReference(sheet.getSheetName(), 0, 1, true, true).formatAsString();
+        tx.getStrRef().setF(titleRef);
+
+
+        // Category Axis Data
+        CTAxDataSource cat = ser.getCat();
+        CTStrData strData = cat.getStrRef().getStrCache();
+
+        // Values
+        CTNumDataSource val = ser.getVal();
+        CTNumData numData = val.getNumRef().getNumCache();
+
+        strData.setPtArray(null);  // unset old axis text
+        numData.setPtArray(null);  // unset old values
+
+
+        // set model
+        int idx = 0;
+        int rownum = 1;
+        String ln;
+        while((ln = modelReader.readLine()) != null){
+            String[] vals = ln.split("\\s+");
+            CTNumVal numVal = numData.addNewPt();
+            numVal.setIdx(idx);
+            numVal.setV(vals[1]);
+
+            CTStrVal sVal = strData.addNewPt();
+            sVal.setIdx(idx);
+            sVal.setV(vals[0]);
+
+            idx++;
+            XSSFRow row = sheet.createRow(rownum++);
+            row.createCell(0).setCellValue(vals[0]);
+            row.createCell(1).setCellValue(Double.valueOf(vals[1]));
+        }
+        numData.getPtCount().setVal(idx);
+        strData.getPtCount().setVal(idx);
+
+        String numDataRange = new CellRangeAddress(1, rownum-1, 1, 1).formatAsString(sheet.getSheetName(), true);
+        val.getNumRef().setF(numDataRange);
+        String axisDataRange = new CellRangeAddress(1, rownum-1, 0, 0).formatAsString(sheet.getSheetName(), true);
+        cat.getStrRef().setF(axisDataRange);
+
+        // updated the embedded workbook with the data
+        OutputStream xlsOut = xlsPart.getPackagePart().getOutputStream();
+        wb.write(xlsOut);
+        xlsOut.close();
+
+        // save the result
+        FileOutputStream out = new FileOutputStream("pie-chart-demo-output.pptx");
+        pptx.write(out);
+        out.close();
+    }
+}

Added: poi/trunk/src/examples/src/org/apache/poi/xslf/usermodel/pie-chart-data.txt
URL: http://svn.apache.org/viewvc/poi/trunk/src/examples/src/org/apache/poi/xslf/usermodel/pie-chart-data.txt?rev=1406496&view=auto
==============================================================================
--- poi/trunk/src/examples/src/org/apache/poi/xslf/usermodel/pie-chart-data.txt (added)
+++ poi/trunk/src/examples/src/org/apache/poi/xslf/usermodel/pie-chart-data.txt Wed Nov  7 08:33:34 2012
@@ -0,0 +1,4 @@
+My Chart
+First 1.0
+Second 3.0
+Third 4.0
\ No newline at end of file

Propchange: poi/trunk/src/examples/src/org/apache/poi/xslf/usermodel/pie-chart-data.txt
------------------------------------------------------------------------------
    svn:executable = *

Added: poi/trunk/src/examples/src/org/apache/poi/xslf/usermodel/pie-chart-template.pptx
URL: http://svn.apache.org/viewvc/poi/trunk/src/examples/src/org/apache/poi/xslf/usermodel/pie-chart-template.pptx?rev=1406496&view=auto
==============================================================================
Binary file - no diff available.

Propchange: poi/trunk/src/examples/src/org/apache/poi/xslf/usermodel/pie-chart-template.pptx
------------------------------------------------------------------------------
    svn:executable = *

Propchange: poi/trunk/src/examples/src/org/apache/poi/xslf/usermodel/pie-chart-template.pptx
------------------------------------------------------------------------------
    svn:mime-type = application/vnd.ms-powerpoint

Copied: poi/trunk/src/ooxml/testcases/org/apache/poi/xslf/usermodel/TestXSLFChart.java (from r1403727, poi/trunk/src/ooxml/testcases/org/apache/poi/xslf/usermodel/TestXSLFConnectorShape.java)
URL: http://svn.apache.org/viewvc/poi/trunk/src/ooxml/testcases/org/apache/poi/xslf/usermodel/TestXSLFChart.java?p2=poi/trunk/src/ooxml/testcases/org/apache/poi/xslf/usermodel/TestXSLFChart.java&p1=poi/trunk/src/ooxml/testcases/org/apache/poi/xslf/usermodel/TestXSLFConnectorShape.java&r1=1403727&r2=1406496&rev=1406496&view=diff
==============================================================================
--- poi/trunk/src/ooxml/testcases/org/apache/poi/xslf/usermodel/TestXSLFConnectorShape.java (original)
+++ poi/trunk/src/ooxml/testcases/org/apache/poi/xslf/usermodel/TestXSLFChart.java Wed Nov  7 08:33:34 2012
@@ -1,108 +1,133 @@
-/* ====================================================================
-   Licensed to the Apache Software Foundation (ASF) under one or more
-   contributor license agreements.  See the NOTICE file distributed with
-   this work for additional information regarding copyright ownership.
-   The ASF licenses this file to You under the Apache License, Version 2.0
-   (the "License"); you may not use this file except in compliance with
-   the License.  You may obtain a copy of the License at
-
-       http://www.apache.org/licenses/LICENSE-2.0
-
-   Unless required by applicable law or agreed to in writing, software
-   distributed under the License is distributed on an "AS IS" BASIS,
-   WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
-   See the License for the specific language governing permissions and
-   limitations under the License.
-==================================================================== */
+/*
+ *  ====================================================================
+ *    Licensed to the Apache Software Foundation (ASF) under one or more
+ *    contributor license agreements.  See the NOTICE file distributed with
+ *    this work for additional information regarding copyright ownership.
+ *    The ASF licenses this file to You under the Apache License, Version 2.0
+ *    (the "License"); you may not use this file except in compliance with
+ *    the License.  You may obtain a copy of the License at
+ *
+ *        http://www.apache.org/licenses/LICENSE-2.0
+ *
+ *    Unless required by applicable law or agreed to in writing, software
+ *    distributed under the License is distributed on an "AS IS" BASIS,
+ *    WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ *    See the License for the specific language governing permissions and
+ *    limitations under the License.
+ * ====================================================================
+ */
 package org.apache.poi.xslf.usermodel;
 
 import junit.framework.TestCase;
-import org.openxmlformats.schemas.drawingml.x2006.main.STLineEndLength;
-import org.openxmlformats.schemas.drawingml.x2006.main.STLineEndType;
-import org.openxmlformats.schemas.drawingml.x2006.main.STLineEndWidth;
+import org.apache.poi.POIXMLDocumentPart;
+import org.apache.poi.ss.util.CellRangeAddress;
+import org.apache.poi.ss.util.CellReference;
+import org.apache.poi.xslf.XSLFTestDataSamples;
+import org.apache.poi.xssf.usermodel.XSSFRow;
+import org.apache.poi.xssf.usermodel.XSSFSheet;
+import org.apache.poi.xssf.usermodel.XSSFWorkbook;
+import org.openxmlformats.schemas.drawingml.x2006.chart.*;
+import org.openxmlformats.schemas.drawingml.x2006.main.*;
+import org.openxmlformats.schemas.presentationml.x2006.main.CTConnector;
+
+import java.awt.*;
+import java.io.*;
+import java.util.LinkedHashMap;
+import java.util.Map;
 
 /**
  * @author Yegor Kozlov
  */
-public class TestXSLFConnectorShape extends TestCase {
+public class TestXSLFChart extends TestCase {
 
-    public void testLineDecorations() {
-        XMLSlideShow ppt = new XMLSlideShow();
-        XSLFSlide slide = ppt.createSlide();
-
-        XSLFConnectorShape shape = slide.createConnector();
-        assertEquals(1, slide.getShapes().length);
-
-        assertFalse(shape.getSpPr().getLn().isSetHeadEnd());
-        assertFalse(shape.getSpPr().getLn().isSetTailEnd());
-
-        // line decorations
-        assertEquals(LineDecoration.NONE, shape.getLineHeadDecoration());
-        assertEquals(LineDecoration.NONE, shape.getLineTailDecoration());
-        shape.setLineHeadDecoration(null);
-        shape.setLineTailDecoration(null);
-        assertEquals(LineDecoration.NONE, shape.getLineHeadDecoration());
-        assertEquals(LineDecoration.NONE, shape.getLineTailDecoration());
-        assertFalse(shape.getSpPr().getLn().getHeadEnd().isSetType());
-        assertFalse(shape.getSpPr().getLn().getTailEnd().isSetType());
-
-        shape.setLineHeadDecoration(LineDecoration.ARROW);
-        shape.setLineTailDecoration(LineDecoration.DIAMOND);
-        assertEquals(LineDecoration.ARROW, shape.getLineHeadDecoration());
-        assertEquals(LineDecoration.DIAMOND, shape.getLineTailDecoration());
-        assertEquals(STLineEndType.ARROW, shape.getSpPr().getLn().getHeadEnd().getType());
-        assertEquals(STLineEndType.DIAMOND, shape.getSpPr().getLn().getTailEnd().getType());
-
-        shape.setLineHeadDecoration(LineDecoration.DIAMOND);
-        shape.setLineTailDecoration(LineDecoration.ARROW);
-        assertEquals(LineDecoration.DIAMOND, shape.getLineHeadDecoration());
-        assertEquals(LineDecoration.ARROW, shape.getLineTailDecoration());
-        assertEquals(STLineEndType.DIAMOND, shape.getSpPr().getLn().getHeadEnd().getType());
-        assertEquals(STLineEndType.ARROW, shape.getSpPr().getLn().getTailEnd().getType());
-
-        // line end width
-        assertEquals(LineEndWidth.MEDIUM, shape.getLineHeadWidth());
-        assertEquals(LineEndWidth.MEDIUM, shape.getLineTailWidth());
-        shape.setLineHeadWidth(null);
-        shape.setLineHeadWidth(null);
-        assertEquals(LineEndWidth.MEDIUM, shape.getLineHeadWidth());
-        assertEquals(LineEndWidth.MEDIUM, shape.getLineTailWidth());
-        assertFalse(shape.getSpPr().getLn().getHeadEnd().isSetW());
-        assertFalse(shape.getSpPr().getLn().getTailEnd().isSetW());
-        shape.setLineHeadWidth(LineEndWidth.LARGE);
-        shape.setLineTailWidth(LineEndWidth.MEDIUM);
-        assertEquals(LineEndWidth.LARGE, shape.getLineHeadWidth());
-        assertEquals(LineEndWidth.MEDIUM, shape.getLineTailWidth());
-        assertEquals(STLineEndWidth.LG, shape.getSpPr().getLn().getHeadEnd().getW());
-        assertEquals(STLineEndWidth.MED, shape.getSpPr().getLn().getTailEnd().getW());
-        shape.setLineHeadWidth(LineEndWidth.MEDIUM);
-        shape.setLineTailWidth(LineEndWidth.LARGE);
-        assertEquals(LineEndWidth.MEDIUM, shape.getLineHeadWidth());
-        assertEquals(LineEndWidth.LARGE, shape.getLineTailWidth());
-        assertEquals(STLineEndWidth.MED, shape.getSpPr().getLn().getHeadEnd().getW());
-        assertEquals(STLineEndWidth.LG, shape.getSpPr().getLn().getTailEnd().getW());
-
-        // line end length
-        assertEquals(LineEndLength.MEDIUM, shape.getLineHeadLength());
-        assertEquals(LineEndLength.MEDIUM, shape.getLineTailLength());
-        shape.setLineHeadLength(null);
-        shape.setLineTailLength(null);
-        assertEquals(LineEndLength.MEDIUM, shape.getLineHeadLength());
-        assertEquals(LineEndLength.MEDIUM, shape.getLineTailLength());
-        assertFalse(shape.getSpPr().getLn().getHeadEnd().isSetLen());
-        assertFalse(shape.getSpPr().getLn().getTailEnd().isSetLen());
-        shape.setLineHeadLength(LineEndLength.LARGE);
-        shape.setLineTailLength(LineEndLength.MEDIUM);
-        assertEquals(LineEndLength.LARGE, shape.getLineHeadLength());
-        assertEquals(LineEndLength.MEDIUM, shape.getLineTailLength());
-        assertEquals(STLineEndLength.LG, shape.getSpPr().getLn().getHeadEnd().getLen());
-        assertEquals(STLineEndLength.MED, shape.getSpPr().getLn().getTailEnd().getLen());
-        shape.setLineHeadLength(LineEndLength.MEDIUM);
-        shape.setLineTailLength(LineEndLength.LARGE);
-        assertEquals(LineEndLength.MEDIUM, shape.getLineHeadLength());
-        assertEquals(LineEndLength.LARGE, shape.getLineTailLength());
-        assertEquals(STLineEndLength.MED, shape.getSpPr().getLn().getHeadEnd().getLen());
-        assertEquals(STLineEndLength.LG, shape.getSpPr().getLn().getTailEnd().getLen());
+    /**
+     * a modified version from POI-examples
+     */
+    public void testFillChartTemplate() throws Exception {
+
+        String chartTitle = "Apache POI";  // first line is chart title
+
+        XMLSlideShow pptx = XSLFTestDataSamples.openSampleDocument("pie-chart.pptx");
+        XSLFSlide slide = pptx.getSlides()[0];
+
+        // find chart in the slide
+        XSLFChart chart = null;
+        for(POIXMLDocumentPart part : slide.getRelations()){
+            if(part instanceof XSLFChart){
+                chart = (XSLFChart) part;
+                break;
+            }
+        }
+
+        if(chart == null) throw new IllegalStateException("chart not found in the template");
+
+        // embedded Excel workbook that holds the chart data
+        POIXMLDocumentPart xlsPart = chart.getRelations().get(0);
+        XSSFWorkbook wb = new XSSFWorkbook();
+        XSSFSheet sheet = wb.createSheet();
+
+        CTChart ctChart = chart.getCTChart();
+        CTPlotArea plotArea = ctChart.getPlotArea();
+
+        CTPieChart pieChart = plotArea.getPieChartArray(0);
+        //Pie Chart Series
+        CTPieSer ser = pieChart.getSerArray(0);
+
+        // Series Text
+        CTSerTx tx = ser.getTx();
+        tx.getStrRef().getStrCache().getPtArray(0).setV(chartTitle);
+        sheet.createRow(0).createCell(1).setCellValue(chartTitle);
+        String titleRef = new CellReference(sheet.getSheetName(), 0, 1, true, true).formatAsString();
+        tx.getStrRef().setF(titleRef);
+
+
+        // Category Axis Data
+        CTAxDataSource cat = ser.getCat();
+        CTStrData strData = cat.getStrRef().getStrCache();
+
+        // Values
+        CTNumDataSource valSrc = ser.getVal();
+        CTNumData numData = valSrc.getNumRef().getNumCache();
+
+        strData.setPtArray(null);  // unset old axis text
+        numData.setPtArray(null);  // unset old values
+
+        Map<String, Double> pieModel = new LinkedHashMap<String, Double>();
+        pieModel.put("First", 1.0);
+        pieModel.put("Second", 3.0);
+        pieModel.put("Third", 4.0);
+
+        // set model
+        int idx = 0;
+        int rownum = 1;
+        for(String key : pieModel.keySet()){
+            double val = pieModel.get(key);
+
+            CTNumVal numVal = numData.addNewPt();
+            numVal.setIdx(idx);
+            numVal.setV("" + val);
+
+            CTStrVal sVal = strData.addNewPt();
+            sVal.setIdx(idx);
+            sVal.setV(key);
+
+            idx++;
+            XSSFRow row = sheet.createRow(rownum++);
+            row.createCell(0).setCellValue(key);
+            row.createCell(1).setCellValue(val);
+        }
+        numData.getPtCount().setVal(idx);
+        strData.getPtCount().setVal(idx);
+
+        String numDataRange = new CellRangeAddress(1, rownum-1, 1, 1).formatAsString(sheet.getSheetName(), true);
+        valSrc.getNumRef().setF(numDataRange);
+        String axisDataRange = new CellRangeAddress(1, rownum-1, 0, 0).formatAsString(sheet.getSheetName(), true);
+        cat.getStrRef().setF(axisDataRange);
+
+        // updated the embedded workbook with the data
+        OutputStream xlsOut = xlsPart.getPackagePart().getOutputStream();
+        wb.write(xlsOut);
+        xlsOut.close();
 
     }
 

Modified: poi/trunk/src/ooxml/testcases/org/apache/poi/xslf/usermodel/TestXSLFConnectorShape.java
URL: http://svn.apache.org/viewvc/poi/trunk/src/ooxml/testcases/org/apache/poi/xslf/usermodel/TestXSLFConnectorShape.java?rev=1406496&r1=1406495&r2=1406496&view=diff
==============================================================================
--- poi/trunk/src/ooxml/testcases/org/apache/poi/xslf/usermodel/TestXSLFConnectorShape.java (original)
+++ poi/trunk/src/ooxml/testcases/org/apache/poi/xslf/usermodel/TestXSLFConnectorShape.java Wed Nov  7 08:33:34 2012
@@ -17,9 +17,10 @@
 package org.apache.poi.xslf.usermodel;
 
 import junit.framework.TestCase;
-import org.openxmlformats.schemas.drawingml.x2006.main.STLineEndLength;
-import org.openxmlformats.schemas.drawingml.x2006.main.STLineEndType;
-import org.openxmlformats.schemas.drawingml.x2006.main.STLineEndWidth;
+import org.openxmlformats.schemas.drawingml.x2006.main.*;
+import org.openxmlformats.schemas.presentationml.x2006.main.CTConnector;
+
+import java.awt.*;
 
 /**
  * @author Yegor Kozlov
@@ -106,4 +107,37 @@ public class TestXSLFConnectorShape exte
 
     }
 
+    public void testAddConnector(){
+        XMLSlideShow pptx = new XMLSlideShow();
+        XSLFSlide slide = pptx.createSlide();
+
+        XSLFAutoShape rect1 = slide.createAutoShape();
+        rect1.setShapeType(XSLFShapeType.RECT);
+        rect1.setAnchor(new Rectangle(100, 100, 100, 100));
+        rect1.setFillColor(Color.blue);
+
+        XSLFAutoShape rect2 = slide.createAutoShape();
+        rect2.setShapeType(XSLFShapeType.RECT);
+        rect2.setAnchor(new Rectangle(300, 300, 100, 100));
+        rect2.setFillColor(Color.red);
+
+
+        XSLFConnectorShape connector1 = slide.createConnector();
+        connector1.setAnchor(new Rectangle(200, 150, 100, 200));
+
+        CTConnector ctConnector = (CTConnector)connector1.getXmlObject();
+        ctConnector.getSpPr().getPrstGeom().setPrst(STShapeType.BENT_CONNECTOR_3);
+        CTNonVisualConnectorProperties cx = ctConnector.getNvCxnSpPr().getCNvCxnSpPr();
+        // connection start
+        CTConnection stCxn = cx.addNewStCxn();
+        stCxn.setId(rect1.getShapeId());
+        // side of the rectangle to attach the connector: left=1, bottom=2,right=3, top=4
+        stCxn.setIdx(2);
+
+        CTConnection end = cx.addNewEndCxn();
+        end.setId(rect2.getShapeId());
+        // side of the rectangle to attach the connector: left=1, bottom=2,right=3, top=4
+        end.setIdx(3);
+    }
+
 }
\ No newline at end of file

Added: poi/trunk/test-data/slideshow/pie-chart.pptx
URL: http://svn.apache.org/viewvc/poi/trunk/test-data/slideshow/pie-chart.pptx?rev=1406496&view=auto
==============================================================================
Binary file - no diff available.

Propchange: poi/trunk/test-data/slideshow/pie-chart.pptx
------------------------------------------------------------------------------
    svn:mime-type = application/vnd.ms-powerpoint



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