Package org.docx4j.wml

Examples of org.docx4j.wml.SdtElement


     
      // If the SDT was made to contain a w:hyperlink, we had to remove:
      //   <w:dataBinding w:storeItemID="{5448916C-134B-45E6-B8FE-88CC1FFC17C3}" w:xpath="/myxml[1]/element2[1]" w:prefixMappings=""/>
      //   <w:text w:multiLine="true"/>
      // Now we need to add those back in
      SdtElement sdt = (SdtElement)entry;
      SdtPr sdtPr = sdt.getSdtPr();
     
      if (sdtPr.getDataBinding()==null ) {
       
        // Identify xpathId
        Tag tag = sdtPr.getTag();
        HashMap<String, String> map = QueryString.parseQueryString(tag.getVal(), true);
        String xpathId= map.get(OpenDoPEHandler.BINDING_ROLE_XPATH);
       
        // Look up - throws InputIntegrityException if not found
        Xpath xp = xPathsPart.getXPathById(xpathId);
         
          // Create object for dataBinding
          CTDataBinding databinding = Context.getWmlObjectFactory().createCTDataBinding();
          sdtPr.setDataBinding(databinding);
              databinding.setXpath( xp.getDataBinding().getXpath());
              databinding.setPrefixMappings( xp.getDataBinding().getPrefixMappings());
              databinding.setStoreItemID( xp.getDataBinding().getStoreItemID() );   
             
          // Create object for text (wrapped in JAXBElement)
          CTSdtText sdttext = Context.getWmlObjectFactory().createCTSdtText();
          sdttext.setMultiLine(true);
          JAXBElement<org.docx4j.wml.CTSdtText> sdttextWrapped = Context.getWmlObjectFactory().createSdtPrText(sdttext);
          sdtPr.getRPrOrAliasOrLock().add( sdttextWrapped);
     
          // Empty the content
          sdt.getSdtContent().getContent().clear();
            // TODO resolve the binding sans hyperlink?
            // TODO eventuallyEmptyList stuff
      }

    }
View Full Code Here


      return null;
    }
   
    private void handleSdt(Object o) {
     
      SdtElement sdt = (SdtElement)o;
      SdtPr sdtPr = sdt.getSdtPr();
     
      Tag tag = sdtPr.getTag();     
      HashMap<String, String> map = null;
      if (tag!=null) {
        map = QueryString.parseQueryString(
          tag.getVal(), true);
      }     
     
      SdtPr.Picture pic = getPicture(sdtPr);
      if (sdtPr.getDataBinding()!=null && pic!=null) {
       
        Object sdtParent = ((Child)o).getParent();
               
        sdt.getSdtContent().getContent().clear();       
        sdt.getSdtContent().getContent().add(
            this.xpathInjectImage(
                (WordprocessingMLPackage)pkg, part,
                sdtPr.getDataBinding(), sdt,
                sdtParent));
       
        // TODO v3 XSLT approach
        // .. if the sdt contains a template picture,
        // find its a:blip, and just replace that.
       
      } else if (map!=null && map.containsKey(OpenDoPEHandler.BINDING_CONTENTTYPE)
            && map.get(OpenDoPEHandler.BINDING_CONTENTTYPE).equals("application/xhtml+xml")) {
          // Convert XHTML.
        log.error("TODO: add HTML import support");
       
      } else if (map!=null && map.containsKey(OpenDoPEHandler.BINDING_ROLE_CONDITIONAL) ) {
        // Do nothing
      } else if (map!=null && map.containsKey(OpenDoPEHandler.BINDING_RESULT_RPTD) ) {
        // Do nothing
       
      } else if (map!=null && map.containsKey(OpenDoPEHandler.BINDING_ROLE_RPT_POS_CON) ) {
        // This may be tricky to do here ..
       
      } else if (map!=null && map.containsKey(OpenDoPEHandler.BINDING_ROLE_XPATH) ) {
       
        boolean isMultiline = isMultiline(sdtPr);
       
        sdt.getSdtContent().getContent().clear();
       
        sdt.getSdtContent().getContent().addAll(
            this.xpathGenerateRuns(
              (WordprocessingMLPackage)pkg, part,
              sdtPr,
              sdtPr.getDataBinding(),
              //sdtParent, contentChild,
              null, isMultiline));
       
      } else if (sdtPr.getDataBinding()!=null && !isRichText(sdtPr) ) {
        // TODO and not(w:sdtPr/w:docPartGallery)
        // .. but which is that?
            //@XmlElementRef(name = "docPartList", namespace = "http://schemas.openxmlformats.org/wordprocessingml/2006/main", type = JAXBElement.class),
            //@XmlElementRef(name = "docPartObj", namespace = "http://schemas.openxmlformats.org/wordprocessingml/2006/main", type = JAXBElement.class),
       
        sdt.getSdtContent().getContent().clear();
       
        sdt.getSdtContent().getContent().addAll(
            this.xpathGenerateRuns(
              (WordprocessingMLPackage)pkg, part,
              sdtPr,
              sdtPr.getDataBinding(),
              //sdtParent, contentChild,
View Full Code Here

      } else if (o instanceof SdtElement) {
       
        newContent.add(o);

        // process the contents of the sdt
        SdtElement sdt = (SdtElement)o;
        List<Object> recursiveL = process(sdt.getSdtContent().getContent());
        sdt.getSdtContent().getContent().clear();
        sdt.getSdtContent().getContent().addAll(recursiveL);
       
      } else {
       
        newContent.add(o);
      }
View Full Code Here

        if(mergeType == null) {
            unmatchedInputs.add(id);
            return;
        }

        SdtElement docxElement = FirstMatch.matching(docXBody, Docx.withTagVal(id));
        if(docxElement == null) {
            unmatchedInputs.add(id);
            return;
        }
       
View Full Code Here

        return new Predicate<Object>(){
            public boolean apply(Object object) {
                if(!(object instanceof SdtElement)) {
                    return false;
                }
                SdtElement sdtBlock = (SdtElement) object;
                Tag tag = sdtBlock.getSdtPr().getTag();
                return tag != null;
            }
        };
    }
View Full Code Here

        return new Predicate<Object>(){
            public boolean apply(Object object) {
                if(!(object instanceof SdtElement)) {
                    return false;
                }
                SdtElement sdtBlock = (SdtElement) object;
                Tag tag = sdtBlock.getSdtPr().getTag();
                return tag != null && Objects.equal(tagVal, tag.getVal());
            }
           
        };
    }
View Full Code Here

        if(mergeType == null) {
            unmatchedInputs.add(id);
            return;
        }

        SdtElement docxElement = FirstMatch.matching(docXBody, Docx.withTagVal(id));
        if(docxElement == null) {
            unmatchedInputs.add(id);
            return;
        }
       
View Full Code Here

        return new Predicate<Object>(){
            public boolean apply(Object object) {
                if(!(object instanceof SdtElement)) {
                    return false;
                }
                SdtElement sdtBlock = (SdtElement) object;
                Tag tag = sdtBlock.getSdtPr().getTag();
                return tag != null;
            }
        };
    }
View Full Code Here

        return new Predicate<Object>(){
            public boolean apply(Object object) {
                if(!(object instanceof SdtElement)) {
                    return false;
                }
                SdtElement sdtBlock = (SdtElement) object;
                Tag tag = sdtBlock.getSdtPr().getTag();
                return tag != null && Objects.equal(tagVal, tag.getVal());
            }
           
        };
    }
View Full Code Here

TOP

Related Classes of org.docx4j.wml.SdtElement

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.