Package org.odftoolkit.odfdom.dom.element.office

Examples of org.odftoolkit.odfdom.dom.element.office.OfficeAnnotationElement


   * @since 0.6.5
   */
  public void addComment(String content, String creator) {
    // create annotation element.
    OdfFileDom dom = (OdfFileDom) getOdfElement().getOwnerDocument();
    OfficeAnnotationElement annotationElement = (OfficeAnnotationElement) OdfXMLFactory.newOdfElement(dom, OdfName
        .newName(OdfDocumentNamespace.OFFICE, "annotation"));
    getOdfElement().insertBefore(annotationElement, getOdfElement().getFirstChild());
    // set creator
    DcCreatorElement dcCreatorElement = annotationElement.newDcCreatorElement();
    if (creator == null) {
      creator = System.getProperty("user.name");
    }
    dcCreatorElement.setTextContent(creator);
    // set date
    String dcDate = new SimpleDateFormat("yyyy-MM-dd'T'HH:mm:ss").format(new Date());
    DcDateElement dcDateElement = annotationElement.newDcDateElement();
    dcDateElement.setTextContent(dcDate);
    TextPElement notePElement = annotationElement.newTextPElement();
    TextSpanElement noteSpanElement = notePElement.newTextSpanElement();
    // set comment style
    OdfOfficeAutomaticStyles styles = null;
    if (dom instanceof OdfContentDom) {
      styles = ((OdfContentDom) dom).getAutomaticStyles();
View Full Code Here


   * Create child element {@odf.element office:annotation}.
   *
   * @return the element {@odf.element office:annotation}
   */
  public OfficeAnnotationElement newOfficeAnnotationElement() {
    OfficeAnnotationElement officeAnnotation = ((OdfFileDom) this.ownerDocument).newOdfElement(OfficeAnnotationElement.class);
    this.appendChild(officeAnnotation);
    return officeAnnotation;
  }
View Full Code Here

   *
   * @return the note text of this cell.
   */
  public String getNoteText() {
    String noteString = null;
    OfficeAnnotationElement annotation = OdfElement.findFirstChildNode(OfficeAnnotationElement.class, mCellElement);
    if (annotation != null) {
      noteString = "";
      Node n = annotation.getFirstChild();
      while (n != null) {
        Node m = n.getNextSibling();
        if (n instanceof TextPElement || n instanceof TextListElement) {
          noteString += TextExtractor.getText((OdfElement) n);
        }
View Full Code Here

   * @param note
   *            note content.
   */
  public void setNoteText(String note) {
    splitRepeatedCells();
    OfficeAnnotationElement annotation = OdfElement.findFirstChildNode(OfficeAnnotationElement.class, mCellElement);
    if (annotation == null) {
      OdfFileDom dom = (OdfFileDom) mCellElement.getOwnerDocument();
      annotation = (OfficeAnnotationElement) OdfXMLFactory.newOdfElement(dom, OdfName.newName(
          OdfDocumentNamespace.OFFICE, "annotation"));
    }
    TextPElement noteElement = OdfElement.findFirstChildNode(TextPElement.class, annotation);
    if (noteElement == null) {
      noteElement = annotation.newTextPElement();
    }
    noteElement.setTextContent(note);
    DcCreatorElement dcCreatorElement = OdfElement.findFirstChildNode(DcCreatorElement.class, annotation);
    if (dcCreatorElement == null) {
      dcCreatorElement = annotation.newDcCreatorElement();
    }
    dcCreatorElement.setTextContent(System.getProperty("user.name"));
    String dcDate = new SimpleDateFormat("yyyy-MM-dd'T'HH:mm:ss").format(new Date());
    DcDateElement dcDateElement = OdfElement.findFirstChildNode(DcDateElement.class, annotation);
    if (dcDateElement == null) {
      dcDateElement = annotation.newDcDateElement();
    }
    dcDateElement.setTextContent(dcDate);
    mCellElement.appendChild(annotation);
  }
View Full Code Here

   * @since 0.6.5
   */
  public void addComment(String content, String creator) {
    // create annotation element.
    OdfFileDom dom = (OdfFileDom) getOdfElement().getOwnerDocument();
    OfficeAnnotationElement annotationElement = (OfficeAnnotationElement) OdfXMLFactory.newOdfElement(dom, OdfName
        .newName(OdfDocumentNamespace.OFFICE, "annotation"));
    getOdfElement().insertBefore(annotationElement, getOdfElement().getFirstChild());
    // set creator
    DcCreatorElement dcCreatorElement = annotationElement.newDcCreatorElement();
    if (creator == null) {
      creator = System.getProperty("user.name");
    }
    dcCreatorElement.setTextContent(creator);
    // set date
    String dcDate = new SimpleDateFormat("yyyy-MM-dd'T'HH:mm:ss").format(new Date());
    DcDateElement dcDateElement = annotationElement.newDcDateElement();
    dcDateElement.setTextContent(dcDate);
    TextPElement notePElement = annotationElement.newTextPElement();
    TextSpanElement noteSpanElement = notePElement.newTextSpanElement();
    // set comment style
    OdfOfficeAutomaticStyles styles = null;
    if (dom instanceof OdfContentDom) {
      styles = ((OdfContentDom) dom).getAutomaticStyles();
View Full Code Here

   *
   * @return the note text of this cell.
   */
  public String getNoteText() {
    String noteString = null;
    OfficeAnnotationElement annotation = OdfElement.findFirstChildNode(OfficeAnnotationElement.class, mCellElement);
    if (annotation != null) {
      noteString = "";
      Node n = annotation.getFirstChild();
      while (n != null) {
        Node m = n.getNextSibling();
        if (n instanceof TextPElement || n instanceof TextListElement) {
          noteString += TextExtractor.getText((OdfElement) n);
        }
View Full Code Here

   * @param note
   *            note content.
   */
  public void setNoteText(String note) {
    splitRepeatedCells();
    OfficeAnnotationElement annotation = OdfElement.findFirstChildNode(OfficeAnnotationElement.class, mCellElement);
    if (annotation == null) {
      OdfFileDom dom = (OdfFileDom) mCellElement.getOwnerDocument();
      annotation = (OfficeAnnotationElement) OdfXMLFactory.newOdfElement(dom, OdfName.newName(
          OdfDocumentNamespace.OFFICE, "annotation"));
    }
    TextPElement noteElement = OdfElement.findFirstChildNode(TextPElement.class, annotation);
    if (noteElement == null) {
      noteElement = annotation.newTextPElement();
    }
    noteElement.setTextContent(note);
    DcCreatorElement dcCreatorElement = OdfElement.findFirstChildNode(DcCreatorElement.class, annotation);
    if (dcCreatorElement == null) {
      dcCreatorElement = annotation.newDcCreatorElement();
    }
    dcCreatorElement.setTextContent(System.getProperty("user.name"));
    String dcDate = new SimpleDateFormat("yyyy-MM-dd'T'HH:mm:ss").format(new Date());
    DcDateElement dcDateElement = OdfElement.findFirstChildNode(DcDateElement.class, annotation);
    if (dcDateElement == null) {
      dcDateElement = annotation.newDcDateElement();
    }
    dcDateElement.setTextContent(dcDate);
    mCellElement.appendChild(annotation);
  }
View Full Code Here

   * Create child element {@odf.element office:annotation}.
   *
   * @return the element {@odf.element office:annotation}
   */
  public OfficeAnnotationElement newOfficeAnnotationElement() {
    OfficeAnnotationElement officeAnnotation = ((OdfFileDom) this.ownerDocument).newOdfElement(OfficeAnnotationElement.class);
    this.appendChild(officeAnnotation);
    return officeAnnotation;
  }
View Full Code Here

   * Create child element {@odf.element office:annotation}.
   *
   * @return the element {@odf.element office:annotation}
   */
  public OfficeAnnotationElement newOfficeAnnotationElement() {
    OfficeAnnotationElement officeAnnotation = ((OdfFileDom) this.ownerDocument).newOdfElement(OfficeAnnotationElement.class);
    this.appendChild(officeAnnotation);
    return officeAnnotation;
  }
View Full Code Here

     
      Paragraph paragraph = newDoc.addParagraph("Paragraph1");
      paragraph.addComment("This is a comment for Paragraph1", "Simple ODF");
      Node firstChildNode = paragraph.getOdfElement().getFirstChild();
      Assert.assertTrue(firstChildNode instanceof OfficeAnnotationElement);
      OfficeAnnotationElement comment = (OfficeAnnotationElement) firstChildNode;
      Assert.assertEquals("Simple ODF", comment.getFirstChild().getTextContent());
      Assert.assertEquals("This is a comment for Paragraph1", comment.getLastChild().getTextContent());
      Assert.assertTrue(firstChildNode instanceof OfficeAnnotationElement);
     
      paragraph = newDoc.addParagraph("Paragraph2");
      paragraph.addComment("This is a comment for Paragraph2", null);
      firstChildNode = paragraph.getOdfElement().getFirstChild();
      Assert.assertTrue(firstChildNode instanceof OfficeAnnotationElement);
      comment = (OfficeAnnotationElement) firstChildNode;
      Assert.assertEquals(System.getProperty("user.name"), comment.getFirstChild().getTextContent());
      Assert.assertEquals("This is a comment for Paragraph2", comment.getLastChild().getTextContent());
     
      newDoc.save(ResourceUtilities.newTestOutputFile("AddCommentOutput.odt"));
    } catch (Exception e) {
      Logger.getLogger(TextDocumentTest.class.getName()).log(Level.SEVERE, null, e);
      Assert.fail();
View Full Code Here

TOP

Related Classes of org.odftoolkit.odfdom.dom.element.office.OfficeAnnotationElement

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.