Page 1 of 1

create box in smartart with CTDataModel

PostPosted: Wed Apr 25, 2012 10:01 am
by oscar.novillo
hello,

does anyone have an example of creating a smartart directly adding CTPt's to CTDataModel?

I dont know how many points are needed to add a box or a connection, I only know its needed to add points and conections.

Its easy to use ogm xml type, but i need dgm type, pptx native way, in order to control text size, background color, hyperlinks, etc.

Any help will be appreciate, I only have two weeks to achieve this.

thanks.

Re: create box in smartart with CTDataModel

PostPosted: Wed Apr 25, 2012 10:29 am
by jason
If you haven't already, have a read of http://www.docx4java.org/svn/docx4j/tru ... ocx4j.docx

Hope this helps .. Jason

Re: create box in smartart with CTDataModel

PostPosted: Wed Apr 25, 2012 8:13 pm
by oscar.novillo
I've read it ten times, and i didnt find anything for my problem.

thanks.

Re: create box in smartart with CTDataModel

PostPosted: Thu Apr 26, 2012 5:36 am
by jason
Which SmartArt are you trying to use? Post a pptx with a single slide containing an example, and more explanation of the problem you trying to solve.

Re: create box in smartart with CTDataModel

PostPosted: Thu Apr 26, 2012 10:39 am
by oscar.novillo
at the end it was easy,

i thought i have to add a lot of points, like in a pptx, but its only needed to add nodes, and conections.

I post the solution code test is a CTDataModel

test.getPtLst().getPt().add(createPoint("1","1",STPtType.NODE));
test.getPtLst().getPt().add(createPoint("2","2",STPtType.NODE));
test.getCxnLst().getCxn().add(createConexion("7", "1", "2",0));

public CTPt createPoint (String ModelId, String text,STPtType stp)
{
CTPt point = new CTPt();
point.setModelId(ModelId);
point.setType(stp);
point.setPrSet(new CTElemPropSet());
point.setSpPr(new CTShapeProperties());
point.setT(new CTTextBody());

point.getT().setBodyPr(new CTTextBodyProperties());
point.getT().setLstStyle(new CTTextListStyle());


CTTextParagraph p = new CTTextParagraph();
p.setEndParaRPr(new CTTextCharacterProperties());
p.getEndParaRPr().setDirty(Boolean.FALSE);


CTRegularTextRun rText = new CTRegularTextRun();
rText.setT(text);
rText.setRPr(new CTTextCharacterProperties());
rText.getRPr().setDirty(Boolean.FALSE);
rText.getRPr().setSmtClean(Boolean.FALSE);
rText.getRPr().setHlinkClick(new CTHyperlink());
rText.getRPr().getHlinkClick().setAction("ppaction://hlinkshowjump?jump=firstslide");

p.getEGTextRun().add(rText);

point.getT().getP().add(p);

return point;
}

public CTCxn createConexion(String ModelId, String sourceId, String destId, long sourceOrd )
{

CTCxn cxn = new CTCxn();
cxn.setModelId(ModelId);
cxn.setSrcId(sourceId);
cxn.setDestId(destId);
//cxn.setSrcOrd(sourceOrd);

return cxn;
}


thanks for your time.