Package org.odftoolkit.odfdom.dom.element.text

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


      OdfDocument docA = odtDoc1.loadSubDocument("DOCA");
      docA.newImage(ResourceUtilities.getURI(TEST_PIC));
      docA.insertDocument(OdfSpreadsheetDocument.newSpreadsheetDocument(), "DOCB/");
      OdfFileDom contentA = docA.getContentDom();
      XPath xpath = contentA.getXPath();
      TextPElement lastPara = (TextPElement) xpath.evaluate("//text:p[last()]", contentA, XPathConstants.NODE);
      addFrameForEmbeddedDoc(contentA, lastPara, "./DOCB");
      OdfDocument docB = odtDoc1.loadSubDocument("DOCA/DOCB/");
      docB.newImage(ResourceUtilities.getURI(TEST_PIC_ANOTHER));
      OdfTable table1 = docB.getTableList().get(0);
      table1.setTableName("NewTable");
View Full Code Here


        TableTableCellElement lastCell = (TableTableCellElement) xpath.evaluate("//table:table-cell[last()]", contentDom, XPathConstants.NODE);
        lastCell.appendChild(drawFrame);
        drawFrame.removeAttribute("text:anchor-type");

      } else if (this instanceof OdfTextDocument) {
        TextPElement lastPara = (TextPElement) xpath.evaluate("//text:p[last()]", contentDom, XPathConstants.NODE);
        if (lastPara == null) {
          lastPara = ((OdfTextDocument) this).newParagraph();
        }
        lastPara.appendChild(drawFrame);
        drawFrame.setTextAnchorTypeAttribute(TextAnchorTypeAttribute.Value.PARAGRAPH.toString());
      } else if (this instanceof OdfPresentationDocument) {
        DrawPageElement lastPage = (DrawPageElement) xpath.evaluate("//draw:page[last()]", contentDom, XPathConstants.NODE);
        lastPage.appendChild(drawFrame);
      }
View Full Code Here

   * Child element is new in Odf 1.2
   *
   * @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

   * 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

   * Child element is new in Odf 1.2
   *
   * @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

   * 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

   * 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

      //// 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

      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

      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

TOP

Related Classes of org.odftoolkit.odfdom.dom.element.text.TextPElement

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.