Package org.odftoolkit.simple

Examples of org.odftoolkit.simple.TextDocument.save()


        item.addComment("simpleODF should be replaced by Simple ODF.", "devin-"+i);
        i++;
      }
      // there are 7 simpleODF in this test document.
      Assert.assertEquals(7, i);
      textDoc.save(ResourceUtilities.newTestOutputFile(SAVE_FILE_COMMENT));
    } catch (Exception e) {
      Logger.getLogger(TextSelectionTest.class.getName()).log(Level.SEVERE, e.getMessage(), e);
      Assert.fail("Failed with " + e.getClass().getName() + ": '" + e.getMessage() + "'");
    }
  }
View Full Code Here


      TextDocument doc = TextDocument.newTextDocument();
      Table table = Table.newTable(doc, 2, 2);
      table.setTableName("ImageTable");
      Cell cell = table.getCellByPosition(0, 0);
      cell.setImage(ResourceUtilities.getURI("image_list_item.png"));
      doc.save(ResourceUtilities.newTestOutputFile("ImageCellTable.odt"));

      // load the document again.
      doc = TextDocument.loadDocument(ResourceUtilities.getTestResourceAsStream("ImageCellTable.odt"));
      table = doc.getTableByName("ImageTable");
      cell = table.getCellByPosition(0, 0);
View Full Code Here

      Assert.assertEquals(t1, paragraph2);
      t1 = cell.getParagraphByReverseIndex(2, false);
      Assert.assertEquals(t1, paragraph1);
      t1 = cell.getParagraphByReverseIndex(1, true);
      Assert.assertEquals(t1, paragraph1);
      doc.save(ResourceUtilities.newTestOutputFile("testCellParagraph.odt"));
    } catch (Exception e) {
      Logger.getLogger(TableCellTest.class.getName()).log(Level.SEVERE, null, e);
      Assert.fail(e.getMessage());
    }
  }
View Full Code Here

 
  @Test
  public void testReadDocumentMeta() throws Exception {
    // create a new empty document
    TextDocument textDoc = TextDocument.newTextDocument();
    textDoc.save(ResourceUtilities.newTestOutputFile("DocForMetaTest.odt"));
    textDoc.close();
    // read empty document meta
    textDoc = (TextDocument) TextDocument.loadDocument(ResourceUtilities.getTestResourceAsStream("DocForMetaTest.odt"));
    Meta meta = textDoc.getOfficeMetadata();
    Assert.assertNotNull(meta.getGenerator());
View Full Code Here

  public void testCopyPasteResource() {
    try {
      TextDocument doc = TextDocument.loadDocument(ResourceUtilities.getTestResourceAsStream("Sections.odt"));
      Section theSec = doc.getSectionByName("ImageSection");
      String newName = doc.appendSection(theSec, false).getName();
      doc.save(ResourceUtilities.newTestOutputFile("NewSection.odt"));

      TextDocument newDoc = TextDocument
          .loadDocument(ResourceUtilities.getTestResourceAsStream("NewSection.odt"));
      theSec = newDoc.getSectionByName("ImageSection");
      Section newSec = newDoc.getSectionByName(newName);
View Full Code Here

        doc.newParagraph("----End of " + aSection.getName() + "---------");
        doc.newParagraph();
        doc.newParagraph();
        doc.newParagraph();
      }
      doc.save(ResourceUtilities.newTestOutputFile("NewSections.odt"));

      doc = TextDocument.loadDocument(ResourceUtilities.getTestResourceAsStream("NewSections.odt"));
      sections = doc.getSectionIterator();
      int i = 0;
      while (sections.hasNext()) {
View Full Code Here

  public void testSetGetName() {
    try {
      TextDocument doc = TextDocument.loadDocument(ResourceUtilities.getTestResourceAsStream("Sections.odt"));
      Section theSec = doc.getSectionByName("ImageSection");
      theSec.setName("ImageSection_NewName");
      doc.save(ResourceUtilities.newTestOutputFile("NewSection.odt"));

      TextDocument newDoc = TextDocument
          .loadDocument(ResourceUtilities.getTestResourceAsStream("NewSection.odt"));
      theSec = newDoc.getSectionByName("ImageSection");
      Assert.assertNull(theSec);
View Full Code Here

      Assert.assertTrue(savedCellRange.getColumnNumber() == 3);
      Cell savedCell = savedCellRange.getCellByPosition(0, 0);
      NodeList paraList = savedCell.getOdfElement().getChildNodes();
      Assert.assertTrue(paraList.item(2) instanceof OdfTextParagraph);
      Assert.assertEquals(TextExtractor.getText((OdfTextParagraph) paraList.item(2)), "0.00");
      saveddoc.save(ResourceUtilities.newTestOutputFile(odtfilename + "MergeCoveredCell.odt"));
    } catch (Exception e) {
      Logger.getLogger(TableCellRangeTest.class.getName()).log(Level.SEVERE, e.getMessage(), e);
      Assert.fail("Failed with " + e.getClass().getName() + ": '" + e.getMessage() + "'");
    }
View Full Code Here

      savedCellRange.merge();
      Assert.assertTrue(savedCellRange.getColumnNumber() == 2);
      Assert.assertTrue(savedCellRange.getRowNumber() == 2);
      Cell savedCell = savedCellRange.getCellByPosition(0, 1);
      Assert.assertTrue(savedCell.getOdfElement() instanceof TableCoveredTableCellElement);
      saveddoc.save(ResourceUtilities.newTestOutputFile(odtfilename + "MergeCoveredCell2.odt"));
    } catch (Exception e) {
      Logger.getLogger(TableCellRangeTest.class.getName()).log(Level.SEVERE, e.getMessage(), e);
      Assert.fail("Failed with " + e.getClass().getName() + ": '" + e.getMessage() + "'");
    }
  }
View Full Code Here

      CellRange firstTwoColumn = savedTable.getCellRangeByPosition(0, 0, 1, savedTable.getRowCount() - 1);
      firstTwoColumn.merge();
      Cell cell1 = firstTwoColumn.getCellByPosition(0, 2);
      Cell firstCell1 = firstTwoColumn.getCellByPosition(0, 0);
      Assert.assertTrue(cell1.getOwnerTableCell().equals(firstCell1));
      saveddoc.save(ResourceUtilities.newTestOutputFile(odtfilename + "MergeFirstTwoColumn.odt"));
    } catch (Exception e) {
      Logger.getLogger(TableCellRangeTest.class.getName()).log(Level.SEVERE, e.getMessage(), e);
      Assert.fail("Failed with " + e.getClass().getName() + ": '" + e.getMessage() + "'");
    }
  }
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.