Beispiel #1
0
  private void initChildren(org.docx4j.wml.P para) {
    this.children = null;

    if (para == null) {
      return;
    }

    List<Object> pKids = para.getParagraphContent();
    if (!pKids.isEmpty()) {
      this.children = new ArrayList<ElementML>(pKids.size());

      ElementML ml = null;
      for (Object o : pKids) {
        Object value = JAXBIntrospector.getValue(o);

        if (value instanceof org.docx4j.wml.RunIns) {
          ml = new RunInsML(value, this.isDummy);
          ml.setParent(ParagraphML.this);
          this.children.add(ml);
        } else if (value instanceof org.docx4j.wml.RunDel) {
          ml = new RunDelML(value, this.isDummy);
          ml.setParent(ParagraphML.this);
          this.children.add(ml);
        } else if (value instanceof org.docx4j.wml.P.Hyperlink) {
          ml = new HyperlinkML(value, this.isDummy);
          ml.setParent(ParagraphML.this);
          this.children.add(ml);

        } else if (value instanceof org.docx4j.wml.CTSmartTagRun) {
          InlineTransparentML transparent = new InlineTransparentML(value, this.isDummy);
          // Current implementation is using InlineTransparentML
          // as surrogate container.
          if (transparent.getChildrenCount() > 0) {
            List<ElementML> list = new ArrayList<ElementML>(transparent.getChildren());
            for (ElementML elem : list) {
              elem.delete();
              elem.setParent(ParagraphML.this);
              this.children.add(elem);
            }
          }
        } else if (value instanceof org.docx4j.wml.CTMarkupRange) {
          // suppress <w:bookmarkStart> and <w:bookmarkEnd>
          JAXBIntrospector inspector = Context.jc.createJAXBIntrospector();
          QName name = inspector.getElementName(o);
          if (name != null
              && (name.getLocalPart() == "bookmarkStart" || name.getLocalPart() == "bookmarkEnd")) {
            // suppress
          } else {
            ml = new RunML(o, this.isDummy);
            ml.setParent(ParagraphML.this);
            this.children.add(ml);
          }
        } else {
          ml = new RunML(o, this.isDummy);
          ml.setParent(ParagraphML.this);
          this.children.add(ml);
        }
      }
    }
  } // initChildren()