Package org.docx4j.wml

Examples of org.docx4j.wml.SdtPr$Group


      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

//    }
   
    newContent.add(sdt);

    // Change the tag to od:resultRepeatZero
    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 stripRepeatArgPattern = Pattern
        .compile("(.*od:repeat=)([^&]*)(.*)");
    final Matcher stripPatternMatcher = stripRepeatArgPattern
        .matcher(tagVal);
    if (!stripPatternMatcher.matches()) {
      log.error("Cannot find repeat tag in sdtPr/tag while processing repeat; something is wrong with " + tagVal);
      return newContent;
    }
    final String emptyRepeatValue = BINDING_RESULT_RPTD_ZERO + "=" + stripPatternMatcher.group(2) + stripPatternMatcher.group(3);
    tag.setVal(emptyRepeatValue)
   
    // 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

  private List<Object> cloneRepeatSdt(Object sdt, String xpathBase,
      int numRepeats) {

    List<Object> newContent = new ArrayList<Object>();

    SdtPr sdtPr = getSdtPr(sdt);

    log.debug(XmlUtils.marshaltoString(sdtPr, true, true));

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

    emptyRepeatTagValue(sdtPr.getTag()); // 2012 07 15: do it to the first one

    for (int i = 0; i < numRepeats; i++) {

      // 2012 07 13: for "od:RptPosCon" processing to
      // work (conditional inclusion dependant on position
      // in repeat), we need each entry (ie including the
      // original) to have the same tag (which I've changed
      // to od:rptd).

      if (i > 0) {
        // Change ID
        sdtPr.setId();
      } // preserve ID on index 0, important for OpenDoPEReverter!
     
      // Clone
      newContent.add(XmlUtils.deepCopy(sdt));
    }
View Full Code Here

  }

  private void processDescendantBindings(Object sdt, String xpathBase,
      int index) {

    SdtPr sdtPr = getSdtPr(sdt);

    // log.debug(XmlUtils.marshaltoString(sdtPr, true, true));

    // Give it a unique ID (supersedes above?)
    sdtPr.setId();

    // log.debug(XmlUtils.marshaltoString(sdtPr, true, true));
    CTDataBinding binding = (CTDataBinding) XmlUtils.unwrap(sdtPr
        .getDataBinding());

    String thisXPath = null;

    // It'll have one of these three...
    String conditionId = null;
    String repeatId = null;
    String bindingId = null;

    org.opendope.xpaths.Xpaths.Xpath xpathObj = null;

    Tag tag = sdtPr.getTag();
    if (tag == null)
      return;
    HashMap<String, String> map = QueryString.parseQueryString(
        tag.getVal(), true);
View Full Code Here

TOP

Related Classes of org.docx4j.wml.SdtPr$Group

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.