Package org.docx4j.dml.diagram

Examples of org.docx4j.dml.diagram.ObjectFactory


      return unmarshal( is );    // side-effect is to set jaxbElement  
    }
   
    public void CreateMinimalContent(String uniqueId) {

    ObjectFactory factory = new ObjectFactory();
   
    CTColorTransform colorsDef = factory.createCTColorTransform();
    colorsDef.setUniqueId(uniqueId);
   
    this.setJaxbElement(colorsDef);     
    }
View Full Code Here


        XmlUtils.deepCopy(source.getJaxbElement()) );
    gloxPackage.addTargetPart(target);
   
    // DiagramLayoutHeaderPart
    DiagramLayoutHeaderPart diagramLayoutHeaderPart = new DiagramLayoutHeaderPart();
    ObjectFactory factory = new ObjectFactory();
    CTDiagramDefinitionHeader header = factory.createCTDiagramDefinitionHeader();
    diagramLayoutHeaderPart.setJaxbElement(header);
   
    String uniqueId = target.getJaxbElement().getUniqueId();
    if (uniqueId!=null) {
      header.setUniqueId( uniqueId );
      System.out.println("Creating glox for " + uniqueId);
     
      // Can we make a filename out of this?
      if (uniqueId.indexOf("/")>0
          && uniqueId.lastIndexOf("/")!= uniqueId.length()-1 ) {
        outputfilename = uniqueId.substring(uniqueId.lastIndexOf("/")+1) + ".glox";
      }
    }
   
    if (target.getJaxbElement().getTitle()==null
        || target.getJaxbElement().getTitle().isEmpty()
        || (target.getJaxbElement().getTitle().size()==1
            && target.getJaxbElement().getTitle().get(0).getVal().isEmpty())) {
      CTName title = factory.createCTName();
      title.setVal("some title");
      header.getTitle().add(title);
    } else {
      header.getTitle().addAll(target.getJaxbElement().getTitle() );     
    }

    if (target.getJaxbElement().getDesc()==null
        || target.getJaxbElement().getDesc().isEmpty()
        || (target.getJaxbElement().getDesc().size()==1
            && target.getJaxbElement().getDesc().get(0).getVal().isEmpty())) {
      CTDescription desc = factory.createCTDescription();
      desc.setVal("some desc");
      header.getDesc().add(desc);
    } else {
      header.getDesc().addAll(target.getJaxbElement().getDesc() );     
    }
View Full Code Here

        return unmarshal( is );    // side-effect is to set jaxbElement  
      }

      public void CreateMinimalContent(String uniqueId) {

      ObjectFactory factory = new ObjectFactory();
     
      CTStyleDefinition styleDef = factory.createCTStyleDefinition();
      styleDef.setUniqueId(uniqueId);
     
      CTStyleLabel styleLabel = factory.createCTStyleLabel();
      styleLabel.setName("node0");
     
      styleDef.getStyleLbl().add(styleLabel);
     
      this.setJaxbElement(styleDef);     
View Full Code Here

      .addStyledParagraphOfText("Title", "Hello world");
    wordMLPackage.getMainDocumentPart().addParagraphOfText("from docx4j!");

    // Now add the SmartArt parts from the glox
    GloxPackage gloxPackage = GloxPackage.load(new java.io.File(inputfilepath));
    ObjectFactory factory = new ObjectFactory();


    // 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);
View Full Code Here

TOP

Related Classes of org.docx4j.dml.diagram.ObjectFactory

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.