Package org.docx4j.openpackaging.parts.DrawingML

Examples of org.docx4j.openpackaging.parts.DrawingML.DiagramLayoutPart


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


   
    GloxPackage gloxPackage = new GloxPackage();   
   
    // DiagramLayoutPart - from the exemplar docx or pptx 
    // .. just the first one we encounter
    DiagramLayoutPart source = null;
    for (Entry<PartName,Part> entry : opcPackage.getParts().getParts().entrySet() ) {
     
      if (entry.getValue().getContentType().equals(
          ContentTypes.DRAWINGML_DIAGRAM_LAYOUT )) {
        source = (DiagramLayoutPart)entry.getValue();
        break;
      }
    }
    if (source==null) {
      System.out.println("No SmartArt found in " + inputfilepath);
      return
    }

    // .. don't bother cloning, just attach it
    DiagramLayoutPart target = new DiagramLayoutPart(new PartName("/diagrams/layout1.xml"));
    target.setJaxbElement(
        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() );     
    }
   
    gloxPackage.addTargetPart(diagramLayoutHeaderPart);
   
View Full Code Here

TOP

Related Classes of org.docx4j.openpackaging.parts.DrawingML.DiagramLayoutPart

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.