Package org.docx4j.openpackaging.parts

Examples of org.docx4j.openpackaging.parts.PartName


    super(partName);
    init();
  }

  public ViewPropertiesPart() throws InvalidFormatException {
    super(new PartName("/ppt/viewProps.xml"));
    init();
  }
View Full Code Here


    super(partName);
    init();
  }

  public CommentsPart() throws InvalidFormatException {
    super(new PartName("/ppt/comments/comment1.xml"));
    init();
  }
View Full Code Here

      if (a.getPart().getContentType().equals(ContentTypes.RELATIONSHIPS_PART)) {
        parentPart.setRelationships(null);
      } else {
        removedParts.addAll(
            parentPart.getRelationshipsPart().removePart(
                new PartName(xmlpart.getName())) );
      }
     
    }
   
   
    // -- Modifications
    for (Alteration a : alterations.getPartsModified() ) {
     
      log.info("Applying modifications to part: " + a.getPart().getName() );
     
      if (a.getPart().getContentType().equals(ContentTypes.RELATIONSHIPS_PART)) {
       
       
        RelationshipsPart newRP = null; //FlatOpcXmlImporter.createRelationshipsPart(a.getPart());
       
        if (a.getSourcePartName().equals("/")) {
          newRP = otherPackage.getRelationshipsPart(true);
//          otherPackage.setRelationships(newRP);
//          newRP.setSourceP(otherPackage);         
        } else {
          Part parentPart = otherPackage.getParts().get(a.getSourcePartName());
          newRP = parentPart.getRelationshipsPart(true);
//          parentPart.setRelationships(newRP);
//          newRP.setSourceP(parentPart);         
        }
        FlatOpcXmlImporter.populateRelationshipsPart(newRP,  a.getPart().getXmlData().getAny());
       
      } else {

        Part targetPart = otherPackage.getParts().get(
            new PartName(a.getPart().getName()));
       
        if (targetPart==null) {
          log.error("Couldn't find " +  a.getPart().getName() + " @ " + a.getSourcePartName().getName() );
          continue;
        }
       
        Part tmpPart = FlatOpcXmlImporter.getRawPart(otherPackage.getContentTypeManager(),
            a.getPart(), null);
       
        if (targetPart instanceof JaxbXmlPart) {
          ((JaxbXmlPart)targetPart).setJaxbElement(
              ((JaxbXmlPart)tmpPart).getJaxbElement() );
         
        } else if (targetPart instanceof XmlPart) {
         
          ((XmlPart)targetPart).setDocument(
              ((XmlPart)tmpPart).getDocument() );
       
        } else if (targetPart instanceof CustomXmlDataStoragePart) {
         
          ((CustomXmlDataStoragePart)targetPart).setData(
              ((CustomXmlDataStoragePart)tmpPart).getData() );
            // TODO: check that
         
        } else if (targetPart instanceof BinaryPart) {

          ((BinaryPart)targetPart).setBinaryData(
              ((BinaryPart)tmpPart).getBuffer() );
         
        } else {
          log.error("TODO: handle " + targetPart.getClass().getName() );
        }
      }
    }
   
    // -- Additions
    for (Alteration a : alterations.getPartsAdded() ) {
     
      log.info("Adding part: " + a.getPart().getName() );
     
      if (a.getPart().getContentType().equals(ContentTypes.RELATIONSHIPS_PART)) {
       
        RelationshipsPart newRP = null; //FlatOpcXmlImporter.createRelationshipsPart(a.getPart());
       
        if (a.getSourcePartName().equals("/")) {
          newRP = otherPackage.getRelationshipsPart(true);
//          otherPackage.setRelationships(newRP);
//          newRP.setSourceP(otherPackage);
        } else {
          Part parentPart = otherPackage.getParts().get(a.getSourcePartName());
          newRP = parentPart.getRelationshipsPart(true);
//          parentPart.setRelationships(newRP);
//          newRP.setSourceP(parentPart);
        }
        FlatOpcXmlImporter.populateRelationshipsPart(newRP,  a.getPart().getXmlData().getAny());
       
       
      } else {

        Part parentPart = otherPackage.getParts().get(a.getSourcePartName());
        Part newPart = FlatOpcXmlImporter.getRawPart(otherPackage.getContentTypeManager(),
            a.getPart(), null);
       
        // There will already be a rel for the new part,
        // since we will already have modified or added the rels part
        // so don't do AddTargetPart (which will probably create a new rel id,
        // which will cause problems)
       
        newPart.setOwningRelationshipPart(parentPart.getRelationshipsPart());
        newPart.getSourceRelationships().add(
            parentPart.getRelationshipsPart().getRel(new PartName(a.getPart().getName())));
        otherPackage.getParts().put(newPart);
        newPart.setPackage( otherPackage );

        // TODO: add content type if necessary
      }     
View Full Code Here

    super(partName);
    init();
  }

  public TableStylesPart() throws InvalidFormatException {
    super(new PartName("/ppt/tableStyles.xml"));
    init();
  }
View Full Code Here

    // Need references to these parts to create a slide
    // Please note that these parts *already exist* - they are
    // created by createPackage() above.  See that method
    // for instruction on how to create and add a part.
    MainPresentationPart pp = (MainPresentationPart)presentationMLPackage.getParts().getParts().get(
        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));

View Full Code Here

    /*
     * Get the Chart object and update the values. Afterwards, we'll update
     * the associated spreadsheet so that the data is synchronized.
     */
    Chart chart = (Chart) ppt.getParts().get(new PartName(chartPartName));
   
    List<Object> objects = chart.getJaxbElement().getChart().getPlotArea()
        .getAreaChartOrArea3DChartOrLineChart();
   
    for (Object object : objects) {
     
      if (object instanceof CTBarChart) {

        List<CTBarSer> ctBarSers = ((CTBarChart) object).getSer();
       
        for (CTBarSer ctBarSer : ctBarSers)
        {
          List<CTNumVal> ctNumVals = ctBarSer.getVal().getNumRef().getNumCache().getPt();
          for (CTNumVal ctNumVal : ctNumVals)
          {
            System.out.println("ctNumVal Val BEFORE: " + ctNumVal.getV());
            if (ctNumVal.getIdx() == 0) {
              ctNumVal.setV(firstValue);
            }
            else if (ctNumVal.getIdx() == 1) {
              ctNumVal.setV(secondValue)
            }
            System.out.println("ctNumVal Val AFTER: " + ctNumVal.getV());
          }
        }
      }
    }
       
    /*
     * Get the spreadsheet and find the cell values that need to be updated
     */
   
    EmbeddedPackagePart epp  = (EmbeddedPackagePart) ppt
      .getParts().get(new PartName(xlsPartName));
   
    if (epp==null) {
      throw new Docx4JException("Could find EmbeddedPackagePart: " + xlsPartName);
    }
   
View Full Code Here

      InputStream is = getInputStreamFromJCRPart( nodeMapper, contentNode);
     

      //return new RelationshipsPart(p, new PartName("/" + partName), is );
     
      RelationshipsPart rp = new RelationshipsPart(new PartName("/" + partName) );
      rp.setSourceP(p);
      rp.unmarshal(is);
      return rp;
     
     
View Full Code Here

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

//      Property jcrData = contentNode.getProperty("jcr:data");
      Property jcrData = nodeMapper.getJcrData(contentNode);     
      in = jcrData.getStream();

      part = new BinaryPart(new PartName("/" + resolvedPartUri));

      ((BinaryPart) part).setBinaryData(in);
      log.info("Stored as BinaryData");

    } catch (Exception ex) {
View Full Code Here

   
    // Create skeletal package
    PresentationMLPackage presentationMLPackage = PresentationMLPackage.createPackage();
   
    MainPresentationPart pp = (MainPresentationPart)presentationMLPackage.getParts().getParts().get(
        new PartName("/ppt/presentation.xml"));
   
    SlideLayoutPart layoutPart = (SlideLayoutPart)presentationMLPackage.getParts().getParts().get(
        new PartName("/ppt/slideLayouts/slideLayout1.xml"));
   
    boolean noLine = false;
   
    /* ST_ShapeType has 203 values
     *
 
View Full Code Here

TOP

Related Classes of org.docx4j.openpackaging.parts.PartName

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.