// Layout part
DiagramLayoutPart layout = new DiagramLayoutPart();
layout.setJaxbElement(gloxPackage.getDiagramLayoutPart().getJaxbElement());
gloxPackage.getDiagramLayoutPart().getJaxbElement().setUniqueId("mylayout");
DiagramColorsPart colors = new DiagramColorsPart();
colors.unmarshal("colorsDef-accent1_2.xml");
//colors.CreateMinimalContent("mycolors");
DiagramStylePart style = new DiagramStylePart();
style.unmarshal("quickStyle-simple1.xml");
//style.CreateMinimalContent("mystyle");
// DiagramDataPart
DiagramDataPart data = new DiagramDataPart();
// Get the sample data from dgm:sampData
if (gloxPackage.getDiagramLayoutPart().getJaxbElement().getSampData()==null) {
log.error("Sample data missing!");
return;
}
CTDataModel sampleDataModel = gloxPackage.getDiagramLayoutPart().getJaxbElement().getSampData().getDataModel();
// If there is none, this sample won't work
if (sampleDataModel==null
|| sampleDataModel.getPtLst()==null
|| sampleDataModel.getPtLst().getPt().size()==0) {
System.out.println("No sample data in this glox, so can't create demo docx");
return;
// TODO: in this case, try generating our own sample data?
}
CTDataModel clonedDataModel = XmlUtils.deepCopy((CTDataModel)sampleDataModel);
data.setJaxbElement( clonedDataModel );
/* <dgm:pt modelId="1" type="doc">
<dgm:prSet
loTypeId="mylayout"
qsTypeId="mystyle"
csTypeId="mycolors" />
</dgm:pt> */
CTElemPropSet prSet = factory.createCTElemPropSet();
prSet.setLoTypeId("mylayout");
prSet.setQsTypeId(style.getJaxbElement().getUniqueId());
prSet.setCsTypeId(colors.getJaxbElement().getUniqueId());
clonedDataModel.getPtLst().getPt().get(0).setPrSet(prSet);
String layoutRelId = wordMLPackage.getMainDocumentPart().addTargetPart(layout).getId();
String dataRelId = wordMLPackage.getMainDocumentPart().addTargetPart(data).getId();