Package org.docx4j.openpackaging.parts.PresentationML

Examples of org.docx4j.openpackaging.parts.PresentationML.SlidePart


        new PartName("/ppt/presentation.xml"));   
    SlideLayoutPart layoutPart = (SlideLayoutPart)pMLPackage.getParts().getParts().get(
        new PartName("/ppt/slideLayouts/slideLayout1.xml"));
   
    // OK, now we can create a slide
    SlidePart slidePart = pMLPackage.createSlidePart(pp, layoutPart,
        new PartName("/ppt/slides/slide1.xml"));
               
    // Layout part
    DiagramLayoutPart layout = new DiagramLayoutPart(new PartName("/ppt/diagrams.layout1.xml"));
    layout.setJaxbElement(diagramLayoutObj);

    DiagramColorsPart colors = new DiagramColorsPart(new PartName("/ppt/diagrams.colors1.xml"));
    colors.unmarshal("colorsDef-accent1_2.xml");
    //colors.CreateMinimalContent("mycolors");
   
    DiagramStylePart style = new DiagramStylePart(new PartName("/ppt/diagrams.quickStyle1.xml"));
    style.unmarshal("quickStyle-simple1.xml");
    //style.CreateMinimalContent("mystyle");
   
    // DiagramDataPart
    DiagramDataPart data = new DiagramDataPart(new PartName("/ppt/diagrams.data1.xml"));
    data.setPackage(pMLPackage); // otherwise we need to pass pkg around
    data.setJaxbElement( createDiagramData(data, xml) );
   
    String layoutRelId = slidePart.addTargetPart(layout).getId();
    String dataRelId = slidePart.addTargetPart(data).getId();
    String colorsRelId = slidePart.addTargetPart(colors).getId();
    String styleRelId = slidePart.addTargetPart(style).getId();
   
    // Create and add graphicFrame for SmartArt
    Presentation.SldSz tmpSldSz = pMLPackage.getMainPresentationPart().getJaxbElement().getSldSz();
   
    CTGraphicalObjectFrame graphicFrame = createSmartArt( layoutRelId,  dataRelId, colorsRelId,  styleRelId,
        ""+(tmpSldSz.getCx()-200000), ""+(tmpSldSz.getCy()-1000000) );
        // A bit smaller, so we can have a margin around the edge

    slidePart.getJaxbElement().getCSld().getSpTree().getSpOrGrpSpOrGraphicFrame().add(
        graphicFrame);
           
    return pMLPackage;
  }
View Full Code Here


        new PartName("/ppt/presentation.xml"));   
    SlideLayoutPart layoutPart = (SlideLayoutPart)presentationMLPackage.getParts().getParts().get(
        new PartName("/ppt/slideLayouts/slideLayout1.xml"));
   
    // OK, now we can create a slide
    SlidePart slidePart = presentationMLPackage.createSlidePart(pp, layoutPart,
        new PartName("/ppt/slides/slide1.xml"));
       
    // Method 1 - programmatic
    slidePart.getJaxbElement().getCSld().getSpTree().getSpOrGrpSpOrGraphicFrame().add( getTable() );
   
    // Method 2 - from string - on slide 2
    SlidePart slide2 = presentationMLPackage.createSlidePart(pp, layoutPart,
        new PartName("/ppt/slides/slide2.xml"));
    slide2.getJaxbElement().getCSld().getSpTree().getSpOrGrpSpOrGraphicFrame().add( createGraphicFrameFromString() );
   
    // All done: save it
    presentationMLPackage.save(new java.io.File(outputfilepath));

    System.out.println("\n\n done .. saved " + outputfilepath);
View Full Code Here

    int i = 1
    for (STShapeType st : STShapeType.values() ) {
   
      System.out.println("Adding slide for shape: " + st.value() );
     
      SlidePart slidePart = createSlidePart(pp, layoutPart, i);
     
      // Create and add shapes
      Shape title = ((Shape)XmlUtils.unmarshalString(
          getSlideTitle(st.value()), Context.jcPML) );
      slidePart.getJaxbElement().getCSld().getSpTree().getSpOrGrpSpOrGraphicFrame().add(title);
     
     
      Shape sample = ((Shape)XmlUtils.unmarshalString(
          getPresetShape(st.value(), noLine), Context.jcPML) );
      slidePart.getJaxbElement().getCSld().getSpTree().getSpOrGrpSpOrGraphicFrame().add(sample);
     
      i++;
    }
    // All done: save it
    presentationMLPackage.save(new java.io.File(outputfilepath));
View Full Code Here

   */
  private static SlidePart createSlidePart(MainPresentationPart pp, SlideLayoutPart layoutPart, int i)
    throws InvalidFormatException, JAXBException {
   
    // Slide part
    SlidePart slidePart = new SlidePart(new PartName("/ppt/slides/slide" + i +".xml") );
    pp.addSlideIdListEntry(slidePart);

    slidePart.setJaxbElement( SlidePart.createSld() );
   
    // Slide layout part
    slidePart.addTargetPart(layoutPart);
   
    return slidePart;
  }
View Full Code Here

    }

    PresentationMLPackage pMLPackage =
      (PresentationMLPackage)OpcPackage.load(new java.io.File(inputfilepath));

    SlidePart slide = (SlidePart)pMLPackage.getParts().get(new PartName("/ppt/slides/slide1.xml") );
   
    new TraversalUtil(slide.getJaxbElement().getCSld().getSpTree().getSpOrGrpSpOrGraphicFrame(),

    new Callback() {

      String indent = "";
View Full Code Here

        new PartName("/ppt/presentation.xml"));   
    SlideLayoutPart layoutPart = (SlideLayoutPart)presentationMLPackage.getParts().getParts().get(
        new PartName("/ppt/slideLayouts/slideLayout1.xml"));
   
    // OK, now we can create a slide
    SlidePart slidePart = new SlidePart(new PartName("/ppt/slides/slide1.xml"));
    slidePart.setContents( SlidePart.createSld() );   
    pp.addSlide(0, slidePart);
   
    // Slide layout part
    slidePart.addTargetPart(layoutPart);
   
       
    // Create and add shape
    Shape sample = ((Shape)XmlUtils.unmarshalString(SAMPLE_SHAPE, Context.jcPML) );
    slidePart.getContents().getCSld().getSpTree().getSpOrGrpSpOrGraphicFrame().add(sample);
   
    // All done: save it
    presentationMLPackage.save(new java.io.File(outputfilepath));

    System.out.println("\n\n done .. saved " + outputfilepath);
View Full Code Here

  @Deprecated
  public static SlidePart createSlidePart(MainPresentationPart pp, SlideLayoutPart layoutPart, PartName partName)
    throws InvalidFormatException, JAXBException {
   
    // Slide part
    SlidePart slidePart = new SlidePart(partName);
    pp.addSlideIdListEntry(slidePart);

    slidePart.setJaxbElement( SlidePart.createSld() );
   
    // Slide layout part
    slidePart.addTargetPart(layoutPart);
   
    return slidePart;
  }
View Full Code Here

        new PartName("/ppt/presentation.xml"));   
    SlideLayoutPart layoutPart = (SlideLayoutPart)presentationMLPackage.getParts().getParts().get(
        new PartName("/ppt/slideLayouts/slideLayout1.xml"));
   
    // OK, now we can create a slide
    SlidePart slidePart = new SlidePart(new PartName("/ppt/slides/slide1.xml"));
    slidePart.setContents( SlidePart.createSld() );   
    pp.addSlide(0, slidePart);
   
    // Slide layout part
    slidePart.addTargetPart(layoutPart);
       
    // Create and add shape
    Shape sample = ((Shape)XmlUtils.unmarshalString(SAMPLE_SHAPE, Context.jcPML) );
    slidePart.getJaxbElement().getCSld().getSpTree().getSpOrGrpSpOrGraphicFrame().add(sample);
   
    // Now add notes slide.
    // 1. Notes master
    NotesMasterPart nmp = new NotesMasterPart();
    NotesMaster notesmaster = (NotesMaster)XmlUtils.unmarshalString(notesMasterXml, Context.jcPML);
    nmp.setJaxbElement(notesmaster);
    // .. connect it to /ppt/presentation.xml
    Relationship ppRelNmp = pp.addTargetPart(nmp);
    /*
     *  <p:notesMasterIdLst>
                <p:notesMasterId r:id="rId3"/>
            </p:notesMasterIdLst>
     */
    pp.getJaxbElement().setNotesMasterIdLst(createNotesMasterIdListPlusEntry(ppRelNmp.getId()));
   
    // .. NotesMasterPart typically has a rel to a theme
    // .. can we get away without it?
    // Nope .. read this in from a file
    ThemePart themePart = new ThemePart(new PartName("/ppt/theme/theme2.xml"));
      // TODO: read it from a string instead
    themePart.unmarshal(
        FileUtils.openInputStream(new File(System.getProperty("user.dir") + "/theme2.xml"))
      );   
    nmp.addTargetPart(themePart);
   
    // 2. Notes slide
    NotesSlidePart nsp = new NotesSlidePart();
    Notes notes = (Notes)XmlUtils.unmarshalString(notesXML, Context.jcPML);
    nsp.setJaxbElement(notes);
    // .. connect it to the slide
    slidePart.addTargetPart(nsp);
    // .. it also has a rel to the slide
    nsp.addTargetPart(slidePart);
    // .. and the slide master
    nsp.addTargetPart(nmp);
   
View Full Code Here

        new PartName("/ppt/presentation.xml"));   
    SlideLayoutPart layoutPart = (SlideLayoutPart)presentationMLPackage.getParts().getParts().get(
        new PartName("/ppt/slideLayouts/slideLayout1.xml"));
   
    // OK, now we can create a slide
    SlidePart slidePart = presentationMLPackage.createSlidePart(pp, layoutPart,
        new PartName("/ppt/slides/slide1.xml"));
       
    // Add image part
    File file = new File(System.getProperty("user.dir") + "/src/test/resources/images/greentick.png" );
        BinaryPartAbstractImage imagePart
          = BinaryPartAbstractImage.createImagePart(presentationMLPackage, slidePart, file);
   
           
        // Add p:pic to slide
    slidePart.getJaxbElement().getCSld().getSpTree().getSpOrGrpSpOrGraphicFrame().add(
        createPicture(imagePart.getSourceRelationship().getId()));
   

    // Do it again on another slide
    SlidePart slidePart2 = presentationMLPackage.createSlidePart(pp, layoutPart,
        new PartName("/ppt/slides/slide2.xml"));
    Relationship rel = slidePart2.addTargetPart(imagePart);
   
    slidePart2.getJaxbElement().getCSld().getSpTree().getSpOrGrpSpOrGraphicFrame().add(
        createPicture(rel.getId()));
   
    // All done: save it
    presentationMLPackage.save(new java.io.File(outputfilepath));
View Full Code Here

        new PartName("/ppt/presentation.xml"));   
    SlideLayoutPart layoutPart = (SlideLayoutPart)presentationMLPackage.getParts().getParts().get(
        new PartName("/ppt/slideLayouts/slideLayout1.xml"));
   
    // OK, now we can create a slide
    SlidePart slidePart = presentationMLPackage.createSlidePart(pp, layoutPart,
        new PartName("/ppt/slides/slide1.xml"));
       
    // Method 1 - programmatic
    slidePart.getJaxbElement().getCSld().getSpTree().getSpOrGrpSpOrGraphicFrame().add( getTable() );
   
    // Method 2 - from string - on slide 2
    SlidePart slide2 = presentationMLPackage.createSlidePart(pp, layoutPart,
        new PartName("/ppt/slides/slide2.xml"));
    slide2.getJaxbElement().getCSld().getSpTree().getSpOrGrpSpOrGraphicFrame().add( createGraphicFrameFromString() );
   
    // All done: save it
    presentationMLPackage.save(new java.io.File(outputfilepath));

    System.out.println("\n\n done .. saved " + outputfilepath);
View Full Code Here

TOP

Related Classes of org.docx4j.openpackaging.parts.PresentationML.SlidePart

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.