Examples of TextPElement


Examples of org.odftoolkit.odfdom.dom.element.text.TextPElement

      //// W3C XPath initialization ''(JDK5 functionality)''  - XPath is the path within the XML file
      //// (Find XPath examples here: http://www.w3.org/TR/xpath#path-abbrev)
      XPath xpath2 = odfContent.getXPath();

      // receiving the first paragraph "//text:p[1]" ''(JDK5 functionality)''
      TextPElement para = (TextPElement) xpath2.evaluate("//text:p[1]", odfContent, XPathConstants.NODE);

      // adding an image - expecting the user to know that
      // an image consists always of a 'draw:image' and a 'draw:frame' parent

      // FUTURE USAGE: para.createDrawFrame().createDrawImage("/myweb.org/images/myHoliday.png", "/Pictures/myHoliday.png");
      //             Child access methods are still not part of the v0.6.x releases
      // CURRENT USAGE:
      OdfDrawFrame odfFrame = (OdfDrawFrame) OdfXMLFactory.newOdfElement(odfContent, DrawFrameElement.ELEMENT_NAME);
      para.appendChild(odfFrame);
      OdfDrawImage odfImage = (OdfDrawImage) OdfXMLFactory.newOdfElement(odfContent, OdfDrawImage.ELEMENT_NAME);
      odfFrame.appendChild(odfImage);
      odfImage.newImage(ResourceUtilities.getURI(TEST_PIC));

      OdfDrawImage odfImage2 = (OdfDrawImage) OdfXMLFactory.newOdfElement(odfContent, OdfDrawImage.ELEMENT_NAME);
View Full Code Here

Examples of org.odftoolkit.odfdom.dom.element.text.TextPElement

      XPath xpath = contentDom.getXPath();
      // Make sure the embedded document is being loaded


      // Add text element
      TextPElement para = (TextPElement) xpath.evaluate("//text:p[1]", contentDom, XPathConstants.NODE);
      LOG.log(Level.INFO, "First para: {0}", para.getTextContent());
      OdfTextSpan spanElem = new OdfTextSpan(contentDom);
      spanElem.setTextContent(TEST_SPAN_TEXT);
      para.appendChild(spanElem);

      // Add frame and image element
      TextPElement paraLast = (TextPElement) xpath.evaluate("//text:p[last()]", contentDom, XPathConstants.NODE);
      addImageToDocument(contentDom, paraLast);

      // Access/Update automatic styles
      OdfOfficeAutomaticStyles autoStyles = embDoc.getContentDom().getAutomaticStyles();
      OdfStyle autoStyle = autoStyles.getStyle("P1", OdfStyleFamily.Paragraph);
View Full Code Here

Examples of org.odftoolkit.odfdom.dom.element.text.TextPElement

      Assert.assertNotNull(fileEntry);

      // get "Object 1/content.xml"
      OdfContentDom contentDom = embDoc.getContentDom();
      XPath xpath = contentDom.getXPath();
      TextPElement lastPara = (TextPElement) xpath.evaluate("//text:p[last()]", contentDom, XPathConstants.NODE);
      addFrameForEmbeddedDoc(contentDom, lastPara, "Object in Object1");
      Map<String, OdfDocument> emb_embDocs = embDoc.loadSubDocuments();
      Assert.assertEquals(embDocsNumber + 1, emb_embDocs.size());
     
      OdfDocument emb_embDoc = rootDocument.loadSubDocument(embDoc.getDocumentPath()+ pathOfSecondInnerDoc);
      contentDom = emb_embDoc.getContentDom();
      TextPElement para = (TextPElement) xpath.evaluate("//text:p[1]", contentDom, XPathConstants.NODE);
      OdfTextSpan spanElem = new OdfTextSpan(contentDom);
      spanElem.setTextContent(TEST_SPAN_TEXT);
      para.appendChild(spanElem);

      // embDoc.save(ResourceUtilities.newTestOutputFile("222debug.odt"));
      rootDocument.save(TEST_FILE_EMBEDDED_EMBEDDED);

      OdfDocument docWithdoubleEmbeddedDoc = OdfDocument.loadDocument(TEST_FILE_EMBEDDED_EMBEDDED);
View Full Code Here

Examples of org.odftoolkit.odfdom.dom.element.text.TextPElement

      for(String eDocPath : embDocs.keySet()){
        OdfDocument doc1 = embDocs.get(eDocPath);
        Assert.assertNotNull(doc1);
        OdfContentDom contentDom = doc1.getContentDom();
        XPath xpath = contentDom.getXPath();
        TextPElement para = (TextPElement) xpath.evaluate("//text:p[1]", contentDom, XPathConstants.NODE);
        OdfTextSpan spanElem = new OdfTextSpan(contentDom);
        spanElem.setTextContent(TEST_SPAN_TEXT);
        para.appendChild(spanElem);
        //save the embed document to a stand alone document
        doc1.save(TEST_FILE_SAVE_EMBEDDED_OUT);
        // Load test
        OdfDocument loadedDoc = OdfDocument.loadDocument(TEST_FILE_SAVE_EMBEDDED_OUT);
        OdfContentDom contentDom2 = loadedDoc.getContentDom();
        OdfTextSpan span = (OdfTextSpan) xpath.evaluate("//text:span[last()]", contentDom2, XPathConstants.NODE);
        Assert.assertEquals(span.getTextContent(), TEST_SPAN_TEXT);
        Map<String, OdfDocument> embDocs3 = docWithEmbeddedObjects.loadSubDocuments(OdfDocument.OdfMediaType.TEXT);
        for(String eDocPath3 : embDocs3.keySet()){
          // Writer Doc
          OdfDocument doc3 = embDocs3.get(eDocPath3);
          Assert.assertNotNull(doc3);
          OdfContentDom contentDom3 = doc3.getContentDom();
          TextPElement para2 = (TextPElement) xpath.evaluate("//text:p[1]", contentDom3, XPathConstants.NODE);
          addImageToDocument(contentDom3, para2);
          TextPElement para3 = (TextPElement) xpath.evaluate("//text:p[last()]", contentDom3, XPathConstants.NODE);
          addFrameForEmbeddedDoc(contentDom3, para3, "NewEmbedded");
          doc3.insertDocument(OdfTextDocument.newTextDocument(), "/NewEmbedded/");
          OdfDocument doc4 = doc3.loadSubDocument("NewEmbedded");
          Assert.assertNotNull(doc4);
          OdfContentDom contentDom4 = doc4.getContentDom();
View Full Code Here

Examples of org.odftoolkit.odfdom.dom.element.text.TextPElement

   * Create child element {@odf.element text:p}.
   *
   * @return the element {@odf.element text:p}
   */
  public TextPElement newTextPElement() {
    TextPElement textP = ((OdfFileDom) this.ownerDocument).newOdfElement(TextPElement.class);
    this.appendChild(textP);
    return textP;
  }
View Full Code Here

Examples of org.odftoolkit.odfdom.dom.element.text.TextPElement

   * Create child element {@odf.element text:p}.
   *
   * @return the element {@odf.element text:p}
   */
  public TextPElement newTextPElement() {
    TextPElement textP = ((OdfFileDom) this.ownerDocument).newOdfElement(TextPElement.class);
    this.appendChild(textP);
    return textP;
  }
View Full Code Here

Examples of org.odftoolkit.odfdom.dom.element.text.TextPElement

    } else {
      headerEle.setStyleDisplayAttribute(false);
    }
    NodeList nodeList = headerEle.getElementsByTagName(TextPElement.ELEMENT_NAME.getQName());
    for (int i = 0; i < nodeList.getLength(); i++) {
      TextPElement textEle = (TextPElement) nodeList.item(i);
      String stylename = textEle.getStyleName();
      OdfFileDom dom = (OdfFileDom) headerEle.getOwnerDocument();
      OdfOfficeAutomaticStyles styles = null;
      if (dom instanceof OdfContentDom) {
        styles = ((OdfContentDom) dom).getAutomaticStyles();
      } else if (dom instanceof OdfStylesDom) {
        styles = ((OdfStylesDom) dom).getAutomaticStyles();
      }

      OdfStyle newStyle = styles.newStyle(OdfStyleFamily.Paragraph);
      OdfStyle style = styles.getStyle(stylename, OdfStyleFamily.Paragraph);
      if (style != null) {
        String styleName = newStyle.getStyleNameAttribute();
        styles.removeChild(newStyle);
        newStyle = (OdfStyle) style.cloneNode(true);
        newStyle.setStyleNameAttribute(styleName);
        styles.appendChild(newStyle);
      }
      if (isVisible) {
        if (newStyle.hasProperty(StyleTextPropertiesElement.Display)) {
          newStyle.removeProperty(StyleTextPropertiesElement.Display);
        }
      } else {
        newStyle.setProperty(StyleTextPropertiesElement.Display, "none");
      }
      textEle.setStyleName(newStyle.getStyleNameAttribute());
    }
  }
View Full Code Here

Examples of org.odftoolkit.odfdom.dom.element.text.TextPElement

    } else {
      footerEle.setStyleDisplayAttribute(false);
    }
    NodeList nodeList = footerEle.getElementsByTagName(TextPElement.ELEMENT_NAME.getQName());
    for (int i = 0; i < nodeList.getLength(); i++) {
      TextPElement textEle = (TextPElement) nodeList.item(i);
      String stylename = textEle.getStyleName();
      OdfFileDom dom = (OdfFileDom) footerEle.getOwnerDocument();
      OdfOfficeAutomaticStyles styles = null;
      if (dom instanceof OdfContentDom) {
        styles = ((OdfContentDom) dom).getAutomaticStyles();
      } else if (dom instanceof OdfStylesDom) {
        styles = ((OdfStylesDom) dom).getAutomaticStyles();
      }
     
      OdfStyle newStyle = styles.newStyle(OdfStyleFamily.Paragraph);
      OdfStyle style = styles.getStyle(stylename, OdfStyleFamily.Paragraph);
      if (style != null) {
        String styleName = newStyle.getStyleNameAttribute();
        styles.removeChild(newStyle);
        newStyle = (OdfStyle) style.cloneNode(true);
        newStyle.setStyleNameAttribute(styleName);
        styles.appendChild(newStyle);
      }
      if (isVisible) {
        if (newStyle.hasProperty(StyleTextPropertiesElement.Display)) {
          newStyle.removeProperty(StyleTextPropertiesElement.Display);
        }
      } else {
        newStyle.setProperty(StyleTextPropertiesElement.Display, "none");
      }
      textEle.setStyleName(newStyle.getStyleNameAttribute());
    }
  }
View Full Code Here

Examples of org.odftoolkit.odfdom.dom.element.text.TextPElement

   */
  public static Paragraph newParagraph(ParagraphContainer container) {
    Paragraph para = null;
    OdfElement parent = container.getParagraphContainerElement();
    OdfFileDom ownerDom = (OdfFileDom) parent.getOwnerDocument();
    TextPElement pEle = ownerDom.newOdfElement(TextPElement.class);
    parent.appendChild(pEle);
    para = new Paragraph(pEle);
    Component.registerComponent(para, pEle);

    return para;
View Full Code Here

Examples of org.odftoolkit.odfdom.dom.element.text.TextPElement

    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();
    } else if (dom instanceof OdfStylesDom) {
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.