You are viewing a plain text version of this content. The canonical link for it is here.
Posted to user@poi.apache.org by LarryN <cr...@gmail.com> on 2012/09/11 00:06:37 UTC

Re: XSLFConnectorShape creates a link between to random shapes

Hello All,

Has anyone made any progress on this?

My project team are using XSLF, but the inability to connect shapes is an
unexpected brick wall for us.

We will have lost a lot of time if we can not move forward.

Any suggestions would be invaluable at the point.



--
View this message in context: http://apache-poi.1045710.n5.nabble.com/XSLFConnectorShape-creates-a-link-between-to-random-shapes-tp5710474p5710902.html
Sent from the POI - User mailing list archive at Nabble.com.

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


Re: XSLFConnectorShape creates a link between to random shapes

Posted by Jithesh Chandra <ji...@gmail.com>.
Hi ,

I am also trying to work on connector shapes and its become more of a dead
block can you forward me that attachment .



--
View this message in context: http://apache-poi.1045710.n5.nabble.com/XSLFConnectorShape-creates-a-link-between-to-random-shapes-tp5710474p5715263.html
Sent from the POI - User mailing list archive at Nabble.com.

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


Re: XSLFConnectorShape creates a link between to random shapes

Posted by Yegor Kozlov <ye...@dinom.ru>.
You can figure out how to set connectors from reverse engineering:
create a pptx file with two shapes and a connector. Unzip the file and
have a look at slide.xml. The connector shape has two properties which
tell PowerPoint what and how to connect.

Below if the fragment that sets this information, notice a:stCxn
(connection start) and a:endCxn (connection end).
The id attribute specifies the id of the shape to make the connection to.
The idx attribute is the side to attach the connector. For rectangle
it can be one of left=1, bottom=2, right=3 or top=4.

<p:cxnSp>
<p:nvCxnSpPr>
<p:cNvPr id="6" name="Elbow Connector 5"/>
<p:cNvCxnSpPr>
<a:stCxn id="2" idx="3"/>
<a:endCxn id="3" idx="1"/>
</p:cNvCxnSpPr>
<p:nvPr/>
</p:nvCxnSpPr>


The code below creates a slide with two rectangles connected by a bent
connector.

        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);

        FileOutputStream out = new FileOutputStream("xslf-connector.pptx");
        pptx.write(out);
        out.close();


Hope it  helps.

Yegor

On Tue, Sep 11, 2012 at 2:06 AM, LarryN <cr...@gmail.com> wrote:
> Hello All,
>
> Has anyone made any progress on this?
>
> My project team are using XSLF, but the inability to connect shapes is an
> unexpected brick wall for us.
>
> We will have lost a lot of time if we can not move forward.
>
> Any suggestions would be invaluable at the point.
>
>
>
> --
> View this message in context: http://apache-poi.1045710.n5.nabble.com/XSLFConnectorShape-creates-a-link-between-to-random-shapes-tp5710474p5710902.html
> Sent from the POI - User mailing list archive at Nabble.com.
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: user-unsubscribe@poi.apache.org
> For additional commands, e-mail: user-help@poi.apache.org
>

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