Package org.glox4j.openpackaging.packages

Examples of org.glox4j.openpackaging.packages.GloxPackage


    // Need the source doc as a DOM for later, and also
    // as XSLT input
    Document doc = XmlUtils.getNewDocumentBuilder().parse(
        new File(System.getProperty("user.dir")+ "/sample-docs/glox/extracted/data-sample.xml"  ) );   
           
    GloxPackage gloxPackage = (GloxPackage)OpcPackage.load(
        new File(System.getProperty("user.dir")+ "/sample-docs/glox/extracted/CirclePictureHierarchy.glox"  ) );
 
    CTDiagramDefinition diagramLayoutObj = gloxPackage.getDiagramLayoutPart().getJaxbElement();
 
    Templates layoutTreeCreatorXslt =
        DiagramLayoutPart.generateLayoutTreeXSLT(
            diagramLayoutObj);
 
View Full Code Here


   
    Document doc = XmlUtils.getNewDocumentBuilder().parse(
        new File(System.getProperty("user.dir")+ "/sample-docs/glox/extracted/data-sample.xml"  ) );   
       
   
    GloxPackage gloxPackage = (GloxPackage)OpcPackage.load(
        new File(System.getProperty("user.dir")+ "/sample-docs/glox/extracted/CirclePictureHierarchy.glox"  ) );
 
    CTDiagramDefinition diagramLayoutObj = gloxPackage.getDiagramLayoutPart().getJaxbElement();
 
    Templates layoutTreeCreatorXslt =
        DiagramLayoutPart.generateLayoutTreeXSLT(
            diagramLayoutObj);
 
View Full Code Here

    wordMLPackage.getMainDocumentPart()
      .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) {
View Full Code Here

    } catch (IllegalArgumentException e) {
//      inputfilepath = System.getProperty("user.dir") + "/sample-docs/glox/Hier2Level.glox";
      inputfilepath = System.getProperty("user.dir") + "/sample-docs/glox/Picture Organization Chart.glox";
    }
   
    GloxPackage gloxPackage = GloxPackage.load(new java.io.File(inputfilepath));
   
    String title0 = gloxPackage.getDiagramLayoutHeaderPart().getJaxbElement().getTitle().get(0).getVal();
    System.out.println("Title: " + title0);
   
    String desc0 = gloxPackage.getDiagramLayoutHeaderPart().getJaxbElement().getDesc().get(0).getVal();
    System.out.println("Description: " + desc0);
   
    String layoutXml = XmlUtils.marshaltoString(gloxPackage.getDiagramLayoutPart().getJaxbElement() , true, true);
    System.out.println(layoutXml);
   

  }
View Full Code Here

    String outputdir = inputfilepath.substring(0, inputfilepath.lastIndexOf("/")+1);
    String outputfilename = inputfilepath.substring(inputfilepath.lastIndexOf("/"))+ ".glox";
   
    OpcPackage opcPackage = OpcPackage.load(new java.io.File(inputfilepath));   
   
    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);
   

    // All done..
    String outfile = outputdir + outputfilename;
    System.out.println("Writing " + outfile);
    gloxPackage.save(new java.io.File(outfile ));
   
    System.out.println("Done!");
   
  }
View Full Code Here

      log.info("Detected SpreadhseetMLPackage package ");
      p = new SpreadsheetMLPackage(this);
      return p;     
    } else if (pkgContentType.equals(ContentTypes.DRAWINGML_DIAGRAM_LAYOUT) ) {
      log.info("Detected Glox file ");
      p = new GloxPackage(this);
      return p;           
    }
       
    // Nothing in overrides or defaults
    throw new InvalidFormatException("Couldn't identify package from " + pkgContentType);
View Full Code Here

TOP

Related Classes of org.glox4j.openpackaging.packages.GloxPackage

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.