Examples of OdfElement


Examples of org.odftoolkit.odfdom.pkg.OdfElement

     
      Paragraph para = theSec.addParagraph("paragraph");
      String paracontent = para.getTextContent();
      Assert.assertEquals("paragraph", paracontent);
     
      OdfElement odfEle = theSec.getParagraphContainerElement();
      Assert.assertEquals("paragraph", odfEle.getLastChild().getTextContent());
     
      boolean flag = theSec.removeParagraph(para);
      if(flag){
        OdfElement odfEle1 = theSec.getParagraphContainerElement();
        Assert.assertTrue(odfEle1.getLastChild().getTextContent() != "paragraph");
      }
     
    } catch (Exception e) {
      e.printStackTrace();
      Assert.fail();
View Full Code Here

Examples of org.odftoolkit.odfdom.pkg.OdfElement

  public void testGetVariableContainerElement() {
    try {
      TextDocument doc = TextDocument.newTextDocument();
      Header header = doc.getHeader();
     
      OdfElement odfEle = header.getVariableContainerElement();
     
      TableBuilder tb = header.getTableBuilder();
      Table tab = tb.newTable();
     
      Assert.assertNotNull(tab);
      Assert.assertTrue(2 == tab.getRowCount());
      Assert.assertTrue(5 == tab.getColumnCount());
     
      Node nod = odfEle.getFirstChild();
      Assert.assertEquals("table:table", nod.getNodeName());

      //save
      doc.save(ResourceUtilities.newTestOutputFile("headerTableOutput.odt"));
    } catch (Exception e) {
View Full Code Here

Examples of org.odftoolkit.odfdom.pkg.OdfElement

      if(refParagraph == null){
        pEle = getContentRoot().newTextPElement();
      } else {
        OfficeTextElement contentRoot = getContentRoot();
        pEle = contentRoot.newTextPElement();
        OdfElement refEle = refParagraph.getOdfElement();
        contentRoot.insertBefore(pEle, refEle.getNextSibling());
      }
      pEle.setStyleName(style.getStyleNameAttribute());
    } catch (Exception e) {
      Logger.getLogger(TextDocument.class.getName()).log(Level.SEVERE, null, e);
      throw new RuntimeException(breakAttribute + "Break appends failed.", e);
View Full Code Here

Examples of org.odftoolkit.odfdom.pkg.OdfElement

  public void testGetVariableContainerElement() {
    try {
      //TextDocument doc = TextDocument.loadDocument(ResourceUtilities.getTestResourceAsStream("headerFooterHidden.odt"));
      TextDocument doc = TextDocument.newTextDocument();
      Footer footer = doc.getFooter();
      OdfElement odfEle = footer.getVariableContainerElement();
     
      TableBuilder tb = footer.getTableBuilder();
      Table tab = tb.newTable();
     
      Assert.assertNotNull(tab);
      Assert.assertTrue(2 == tab.getRowCount());
      Assert.assertTrue(5 == tab.getColumnCount());
     
      Node nod = odfEle.getFirstChild();
      Assert.assertEquals("table:table", nod.getNodeName());
     
      //save
      doc.save(ResourceUtilities.newTestOutputFile("footerOutput.odt"));
    } catch (Exception e) {
View Full Code Here

Examples of org.odftoolkit.odfdom.pkg.OdfElement

  }

  private class ListContainerImpl extends AbstractListContainer {

    public OdfElement getListContainerElement() {
      OdfElement containerElement = null;
      try {
        containerElement = getContentRoot();
      } catch (Exception e) {
        Logger.getLogger(TextDocument.class.getName()).log(Level.SEVERE, null, e);
      }
View Full Code Here

Examples of org.odftoolkit.odfdom.pkg.OdfElement

    return masterPageEle;
  }

  private class ParagraphContainerImpl extends AbstractParagraphContainer {
    public OdfElement getParagraphContainerElement() {
      OdfElement containerElement = null;
      try {
        containerElement = getContentRoot();
      } catch (Exception e) {
        Logger.getLogger(TextDocument.class.getName()).log(Level.SEVERE, null, e);
      }
View Full Code Here

Examples of org.odftoolkit.odfdom.pkg.OdfElement

    Node node = ele.getFirstChild();
    while (node != null) {
      if (node.getNodeType() == Node.TEXT_NODE) {
        mTextBuilder.append(node.getNodeValue());
      } else if (node.getNodeType() == Node.ELEMENT_NODE) {
        OdfElement element = (OdfElement) node;
        element.accept(this);
      }
      node = node.getNextSibling();
    }
  }
View Full Code Here

Examples of org.odftoolkit.odfdom.pkg.OdfElement

   */
  public static Image newImage(FrameContainer container, URI uri) {
    Image mImage;

    try {
      OdfElement parent = container.getFrameContainerElement();
      OdfFileDom ownerDom = (OdfFileDom) parent.getOwnerDocument();
      DrawFrameElement fElement = ownerDom.newOdfElement(DrawFrameElement.class);
      parent.appendChild(fElement);
      DrawImageElement imageElement = fElement.newDrawImageElement();
      // set uri and copy resource
      String packagePath = insertImageResourceIntoPackage((OdfSchemaDocument) ownerDom.getDocument(), uri);
      packagePath = packagePath.replaceFirst(ownerDom.getDocument().getDocumentPath(), "");
      URI newURI = configureInsertedImage((OdfSchemaDocument) ownerDom.getDocument(), imageElement, packagePath,
View Full Code Here

Examples of org.odftoolkit.odfdom.pkg.OdfElement

   *
   * @return true if the image object is successfully removed; false if
   *         otherwise.
   */
  public boolean remove() {
    OdfElement containerElement = (OdfElement) mElement.getParentNode();
    try {
      mElement.removeChild(getOdfElement());
      if (mElement.hasChildNodes() == false)
        containerElement.removeChild(mElement);
      mOwnerDocument.removeElementLinkedResource(getOdfElement());
    } catch (DOMException exception) {
      Logger.getLogger(AbstractParagraphContainer.class.getName()).log(Level.WARNING, exception.getMessage());
      return false;
    }
View Full Code Here

Examples of org.odftoolkit.odfdom.pkg.OdfElement

     *
     * @param item
     *            the <code>Selection</code> item
     */
    public static void registerItem(Selection item) {
      OdfElement element = item.getElement();
      if (repository.containsKey(element)) {
        Vector<Selection> selections = repository.get(element);
        int i = 0;
        while (i < selections.size()) {
          if (selections.get(i).getIndex() > item.getIndex()) {
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.