Package org.docx4j.wml

Examples of org.docx4j.wml.SdtPr


        // but since a tc can contain w:p or nested table,
        // we still need to recurse
       
      } else if (o instanceof SdtElement ) {
       
        SdtPr sdtPr = ((SdtElement)o).getSdtPr();
        if (sdtPr!=null) {
          Object o2 = sdtPr.getByClass(RPr.class);
          if (o2!=null) {
            RPr rPr = (RPr)o2;
            RStyle rStyle = rPr.getRStyle();
            if (rStyle!=null) {
              // Add it
View Full Code Here


            }
          }
        }
       
      } else if ( o instanceof SdtElement) {
        SdtPr sdtPr = ((SdtElement)o).getSdtPr();
        if (sdtPr!=null) {
          if (contains(sdtPr.getRPrOrAliasOrLock(), "http://schemas.microsoft.com/office/word/2010/wordml", w14SdtPrNames)) {
            needW14 = true;
          }
          if (contains(sdtPr.getRPrOrAliasOrLock(), "http://schemas.microsoft.com/office/word/2012/wordml", w15SdtPrNames)) {
            needW15 = true;
          }
        }
      } else if ( o instanceof Tr) {  // TODO does this need to be unwrapped?
        if ( ((Tr)o).getParaId()!=null) {
View Full Code Here

      // 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

      if (o instanceof org.docx4j.wml.SdtBlock
          || o instanceof org.docx4j.wml.SdtRun
          || o instanceof org.docx4j.wml.CTSdtRow
          || o instanceof org.docx4j.wml.CTSdtCell ) {
       
        SdtPr sdtPr = OpenDoPEHandler.getSdtPr(o);
        if (sdtPr!=null) {
         
          log.debug("Processing " + OpenDoPEHandler.getSdtPr(o).getId().getVal());
          Tag tag = sdtPr.getTag();

          log.debug(tag.getVal());

          HashMap<String, String> map = QueryString.parseQueryString(tag.getVal(), true);

          String conditionId = map.get(OpenDoPEHandler.BINDING_ROLE_CONDITIONAL);
          String repeatId = map.get(OpenDoPEHandler.BINDING_ROLE_REPEAT);

          if (conditionId != null) {

            conditionSdtsByID.put(sdtPr.getId().getVal(), o);

          } else if (repeatId != null) {

            repeatSdtsByID.put(sdtPr.getId().getVal(), o);
           
          } else if (instanceCountOnly) {
           
            String resultConditionId = map.get(OpenDoPEHandler.BINDING_RESULT_CONDITION_FALSE);
            String resultRepeatId = map.get(OpenDoPEHandler.BINDING_RESULT_RPTD);
            String resultRptdZeroId = map.get(OpenDoPEHandler.BINDING_RESULT_RPTD_ZERO);
           
            if (resultConditionId != null) {

              conditionSdtsByID.put(sdtPr.getId().getVal(), o);
             
            } else if (resultRptdZeroId != null) {

              repeatSdtsByID.put(sdtPr.getId().getVal(), o);
             
            } else if (resultRepeatId != null) {

              repeatSdtsByID.put(sdtPr.getId().getVal(), o);
            }            
          }
          // not bothering to count plain binds
        }
      }     
View Full Code Here

      if (o instanceof org.docx4j.wml.SdtBlock
          || o instanceof org.docx4j.wml.SdtRun
          || o instanceof org.docx4j.wml.CTSdtRow
          || o instanceof org.docx4j.wml.CTSdtCell ) {
       
        SdtPr sdtPr = OpenDoPEHandler.getSdtPr(o);
        if (sdtPr!=null) {
         
          log.debug("Processing " + OpenDoPEHandler.getSdtPr(o).getId().getVal());
          Tag tag = sdtPr.getTag();

          if (tag!=null) {
           
            log.debug(tag.getVal());
 
View Full Code Here

   
    // create the content control
    SdtRun sdtRun = Context.getWmlObjectFactory().createSdtRun();
    replacementContent.add(sdtRun);

    SdtPr sdtPr = Context.getWmlObjectFactory().createSdtPr();
    sdtRun.setSdtPr(sdtPr);
    /* <w:sdtPr>
        <w:alias w:val="Title of document"/>
        <w:tag w:val="od:xpath=cktpD"/>
        <w:id w:val="289095091"/>
        <w:dataBinding w:prefixMappings="xmlns:oda='http://opendope.org/answers'"
        w:xpath="/oda:answers/oda:answer[@id='Title_of_document_nM']"
        w:storeItemID="{183E9AF4-65AB-46DF-8044-944891825721}"/>
        <w:text w:multiLine="1"/>
      </w:sdtPr>
      */
   
    Alias alias = Context.getWmlObjectFactory().createSdtPrAlias();
    alias.setVal(key);
    Tag tag = Context.getWmlObjectFactory().createTag();
    tag.setVal("od:xpath=" + key);
    sdtPr.setTag(tag);
    sdtPr.setId();
    CTDataBinding ctDataBinding = Context.getWmlObjectFactory().createCTDataBinding();
    JAXBElement<CTDataBinding> jaxbDB =
        Context.getWmlObjectFactory().createSdtPrDataBinding(ctDataBinding);
    sdtPr.setDataBinding(ctDataBinding);
    ctDataBinding.setXpath("/oda:answers/oda:answer[@id='" + key +"']");
    ctDataBinding.setPrefixMappings("xmlns:oda='http://opendope.org/answers'");
    ctDataBinding.setStoreItemID(storeItemID);
         
    CTSdtContentRun sdtContent = Context.getWmlObjectFactory().createCTSdtContentRun();     
View Full Code Here

      NodeIterator sdtPrNodeIt,
      String sdtParent,
      String contentChild,       
      boolean multiLine) {
   
    SdtPr sdtPr = null;
    Node sdtPrNode = sdtPrNodeIt.nextNode();
    try {
      sdtPr = (SdtPr)XmlUtils.unmarshal(sdtPrNode);
    } catch (JAXBException e) {
      log.error(e.getMessage(), e);
    }
    String odTag = sdtPr.getTag().getVal();
   
    QueryString qs = new QueryString();
    HashMap<String, String> map = qs.parseQueryString(odTag, true);
   
    String xpathId = map.get(OpenDoPEHandler.BINDING_ROLE_XPATH);
View Full Code Here

      NodeIterator sdtPrNodeIt,      
      String sdtParent,
      String contentChild,       
      boolean multiLine) {

    SdtPr sdtPr = null;
    Node sdtPrNode = sdtPrNodeIt.nextNode();
    try {
      sdtPr = (SdtPr)XmlUtils.unmarshal(sdtPrNode);
    } catch (JAXBException e) {
      log.error(e.getMessage(), e);
View Full Code Here

     *
     * What more could you want? Well, the raw w:sdtContent/*
     * but that is not passed in.
     */
   
    SdtPr sdtPr;
    try {
        Node n = sdtPrNodeIt.nextNode();
        sdtPr = (SdtPr)XmlUtils.unmarshal(n, Context.jc, SdtPr.class);
    } catch (JAXBException e1) {
      throw new TransformerException("Missing or broken w:sdtPr", e1);
    }
   
    log.debug("in sdt");
    if (sdtPr.getTag()==null) {
      log.debug(".. no w:tag");
     
      if (handlers.get("*")!=null) {
        // handler '*' only gets applied if no other one has been       
        log.debug("'*' handler");
        handler = handlers.get("*");     
        result = handler.toNode(context.getWmlPackage(), null, null, childResults);
      } else {
        // Just return the contents!
        log.debug("identity handler");
        result = identity.toNode(context.getWmlPackage(), null, null, childResults);
      }
      return debug(result);
    }
   
   
    HashMap<String, String> map
      = QueryString.parseQueryString(sdtPr.getTag().getVal(), true);
   
   
    /*
     * This is intended to handle more than one matching key
     * in the tag, though each is likely to result in an
View Full Code Here

//  }
   
    newContent.add(sdt);

    // Change the tag to od:resultConditionFalse
    SdtPr sdtPr = getSdtPr(sdt);

    CTDataBinding binding = sdtPr.getDataBinding();
    if (binding != null) {  // Shouldn't be a binding anyway
      sdtPr.getRPrOrAliasOrLock().remove(binding);
    }

    Tag tag = sdtPr.getTag();

    final String tagVal = tag.getVal();
    final Pattern stripConditionArgPattern = Pattern
        .compile("(.*od:condition=)([^&]*)(.*)");
    final Matcher stripPatternMatcher = stripConditionArgPattern
        .matcher(tagVal);
    if (!stripPatternMatcher.matches()) {
      log.error("Cannot find condition tag in sdtPr/tag while setting conditionFalse; something is wrong with " + tagVal);
      return newContent;
    }
    final String emptyConditionValue = BINDING_RESULT_CONDITION_FALSE + "=" + stripPatternMatcher.group(2) + stripPatternMatcher.group(3);
    tag.setVal(emptyConditionValue)
   
    // Lock it
        CTLock lock = Context.getWmlObjectFactory().createCTLock();
        lock.setVal(org.docx4j.wml.STLock.SDT_CONTENT_LOCKED);   
        JAXBElement<org.docx4j.wml.CTLock> lockWrapped = Context.getWmlObjectFactory().createSdtPrLock(lock);
        sdtPr.getRPrOrAliasOrLock().add( lockWrapped); // assumes no lock is there already

    // Empty the content
        // .. OpenDoPEIntegrity fixes this where it is not OK, but
        // where it needs to insert a tc, it has no way of adding original tcPr, so
        // we handle this here
View Full Code Here

TOP

Related Classes of org.docx4j.wml.SdtPr

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.