Examples of CTPerm


Examples of org.docx4j.wml.CTPerm

                  mr.setId(BigInteger.valueOf(newId));
                  JAXBElement<CTMarkupRange> bmEnd = Context.getWmlObjectFactory().createBodyBookmarkEnd(mr);       
          paragraphs.add(bmEnd);
        } else
          if (endElement.equals("CTPerm")) {
            CTPerm mr = Context.getWmlObjectFactory().createCTPerm();
                    mr.setId((String)id);
                    JAXBElement<CTPerm> rEnd = Context.getWmlObjectFactory().createBodyPermEnd(mr);       
            paragraphs.add(rEnd);
        } else {
          paragraphs.add(createObject(endElement, id));
        }
       
        if (refElement != null) {
          // In practice this is always CommentReference,
          // so rely on that
          // if (p instanceof P) {
          // R.CommentReference cr =
          // Context.getWmlObjectFactory().createRCommentReference();
          // cr.setId(id);
          // ((P)p).getParagraphContent().add(cr);
          // // that should be put in a w:r
          // // <w:r><w:rPr><w:rStyle
          // w:val="CommentReference"/></w:rPr><w:commentReference
          // w:id="0"/></w:r>
          // } else {
          // System.out.println(" add a close tag in " +
          // p.getClass().getName() );
          // }

          // <w:r><w:rPr><w:rStyle
          // w:val="CommentReference"/></w:rPr><w:commentReference
          // w:id="0"/></w:r>
          P p = Context.getWmlObjectFactory().createP();
          R r = Context.getWmlObjectFactory().createR();
          p.getParagraphContent().add(r);

          R.CommentReference cr = Context.getWmlObjectFactory()
              .createRCommentReference();
          cr.setId( (BigInteger)id);
          r.getRunContent().add(cr);

          paragraphs.add(p);
        }

      }
    }

    for (Object o : rt.ends) {
      counter++;
      long newId = getBookmarkId().getAndIncrement();
        // only renumber here for ends without starts

      if (endIdMethod == null)
        endIdMethod = findGetIdMethod(o);
      Object id = null;
      boolean matched = false;
      try {
        // BigInteger
        id = getId(endIdMethod, o);

        // find the opening point tag
        BigInteger tmpId;
        for (Object start : rt.starts) {

          if (startIdMethod == null)
            startIdMethod = findGetIdMethod(start);
          tmpId = getId(startIdMethod, start);

          if (tmpId!=null
              && tmpId.equals(id)) {
            // found it
            matched = true;
            break;
          }
        }
      } catch (ClassCastException cce) {

        // String
        id = getIdString(endIdMethod, o);

        // find the opening point tag
        String tmpId;
        for (Object start : rt.starts) {

          if (startIdMethod == null)
            startIdMethod = findGetIdMethod(start);
          tmpId = getIdString(startIdMethod, start);

          if (tmpId!=null
              && tmpId.equals(id)) {
            // found it
            matched = true;
            break;
          }
        }
      }

      if (!matched) {

        if (endElement.equals("CTMarkupRange")) {
          // missing start, so renumber
          Method setIdMethod = findSetIdMethod(o);
          if (id instanceof BigInteger) {
            setIdMethod.invoke(o, BigInteger.valueOf(newId));
          }            
        }

        /* I'm presuming the open tags can be block level as well. */
        if (endElement.equals("CTPerm")) {
          RangePermissionStart mr = Context.getWmlObjectFactory().createRangePermissionStart();
                  mr.setId((String)id);
                  JAXBElement<RangePermissionStart> rs =
                    Context.getWmlObjectFactory().createBodyPermStart(mr);       
          paragraphs.add(rs);
        } else if (startElement.equals("CTBookmark")) {
          log.debug("Add w:bookmarkStart");
View Full Code Here
TOP
Copyright © 2018 www.massapi.com. 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.