Package org.docx4j

Examples of org.docx4j.TraversalUtil


    static void trimContent(WordprocessingMLPackage hfPkg)   {
     
      // Find the sectPrs
      SectPrFinder sf = new SectPrFinder(hfPkg.getMainDocumentPart());
    try {
      new TraversalUtil(hfPkg.getMainDocumentPart().getContents(), sf);
    } catch (Docx4JException e) {
      // TODO Auto-generated catch block
      log.error(e.getMessage(), e);
   
   
View Full Code Here


   
   
  @Deprecated
  public void setFriendlyIds(final HashMap<String, String> map) {

    new TraversalUtil(getJaxbElement(),

      new Callback() {

        @Override
        public List<Object> apply(Object o) {
View Full Code Here

   
    DocumentFragment childResults = null;
    if (unmarshalledNode instanceof ContentAccessor) {
      childResults = document.createDocumentFragment();
      AbstractVisitorExporterGenerator<CC> generator = getFactory().createInstance(conversionContext, document, childResults);
      new TraversalUtil(((ContentAccessor)unmarshalledNode).getContent(), generator);
     
    } else if (unmarshalledNode instanceof org.docx4j.wml.Pict) {
      // if it contains a textbox..
     
      // repeating this...
      org.docx4j.vml.CTTextbox textBox = getTextBox((org.docx4j.wml.Pict)unmarshalledNode);
     
      if (textBox!=null) {
       
        childResults = document.createDocumentFragment();
        AbstractVisitorExporterGenerator<CC> generator = getFactory().createInstance(conversionContext, document, childResults);
        new TraversalUtil(textBox.getTxbxContent().getContent(), generator);
      }
     
    }
   
    Node resultNode =
View Full Code Here

 
  static HashMap<String, String> map;
  static int index = 0;
  protected static void generateIdMap(Object jaxbElement) {
   
    new TraversalUtil(jaxbElement,

        new Callback() {
     
          // Unfortunately, the schema says
          // a model id must be an int or a GUID.
View Full Code Here

    return val;
  }
 
  protected static void ReplaceIds(Object jaxbElement) {
   
    new TraversalUtil(jaxbElement,

        new Callback() {

          @Override
          public List<Object> apply(Object o) {
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

  }

  private  void replaceBookmarkContents(List<Object> paragraphs,  Map<DataFieldName, String> data) throws Exception {

    RangeFinder rt = new RangeFinder("CTBookmark", "CTMarkupRange");
    new TraversalUtil(paragraphs, rt);
   
    for (CTBookmark bm : rt.getStarts()) {
     
      // do we have data for this one?
      if (bm.getName()==null) continue;
View Full Code Here

    JaxbXmlPartAltChunkHost clonedPart = (JaxbXmlPartAltChunkHost)clonePkg.getParts().get(partName);
       
    List<Object> contentList = ((ContentAccessor)clonedPart).getContent();
   
      AltChunkFinder bf = new AltChunkFinder();
    new TraversalUtil(contentList, bf);

    CTAltChunk altChunk;
    boolean encounteredDocxAltChunk = false;
    for (LocatedChunk locatedChunk : bf.getAltChunks()) {
     
View Full Code Here

  private static void listFieldsInPart(String partName, List<Object> contentList, StringBuilder sb) throws Docx4JException {

    // find fields
    ComplexFieldLocator fl = new ComplexFieldLocator();
    new TraversalUtil(contentList, fl);
   
    if (fl.getStarts().size()==0) {
      sb.append("\n\n" + partName + ": no fields detected.");
      return;
    }
View Full Code Here

  private static void fixRange(List<Object> paragraphs, String startElement,
      String endElement) throws Exception {

    RangeFinder rt = new RangeFinder(startElement, endElement);
    new TraversalUtil(paragraphs, rt);
   
    for (CTBookmark bm : rt.getStarts()) {
      try {
        // Can't just remove the object from the parent,
        // since in the parent, it may be wrapped in a JAXBElement
View Full Code Here

TOP

Related Classes of org.docx4j.TraversalUtil

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.