Examples of TextDocument


Examples of org.odftoolkit.simple.TextDocument

  }
 
  @Test
  public void testAddParagraph() {
    try {
      TextDocument doc = TextDocument.loadDocument(ResourceUtilities.getTestResourceAsStream("Sections.odt"));
      Section theSec = doc.getSectionByName("ImageSection");
     
      Paragraph para = theSec.addParagraph("paragraph");
      String paracontent = para.getTextContent();
      Assert.assertEquals("paragraph", paracontent);
     
View Full Code Here

Examples of org.odftoolkit.simple.TextDocument

 
 
  @Test
  public void testGetParagraphIterator() {
    try {
      TextDocument doc = TextDocument.loadDocument(ResourceUtilities.getTestResourceAsStream("Sections.odt"));
      Section theSec = doc.getSectionByName("ImageSection");
     
      Paragraph para = theSec.addParagraph("paragraph");
      String paracontent = para.getTextContent();
      Assert.assertEquals("paragraph", paracontent);
     
View Full Code Here

Examples of org.odftoolkit.simple.TextDocument

 
 
  @Test
  public void testGetParagraphByIndex() {
    try {
      TextDocument doc = TextDocument.loadDocument(ResourceUtilities.getTestResourceAsStream("Sections.odt"));
      Section theSec = doc.getSectionByName("ImageSection");
     
      Paragraph para = theSec.addParagraph("paragraph");
      String paracontent = para.getTextContent();
      Assert.assertEquals("paragraph", paracontent);
     
View Full Code Here

Examples of org.odftoolkit.simple.TextDocument

 
 
  @Test
  public void testGetParagraphByReverseIndex() {
    try {
      TextDocument doc = TextDocument.loadDocument(ResourceUtilities.getTestResourceAsStream("Sections.odt"));
      Section theSec = doc.getSectionByName("ImageSection");
      Section theSec2 = doc.getSectionByName("ImageSection");
     
      Paragraph para = theSec.addParagraph("paragraph");
      String paracontent = para.getTextContent();
      Assert.assertEquals("paragraph", paracontent);
     
View Full Code Here

Examples of org.odftoolkit.simple.TextDocument

    cellRange.merge();
    Cell cell = cellRange.getCellByPosition(0, 0);
    saveodt("MergeTwoCell");
    Assert.assertEquals(cell.getDisplayText(), "cell1\rcell2");
    try {
      TextDocument saveddoc = (TextDocument) TextDocument.loadDocument(ResourceUtilities
          .getTestResourceAsStream(odtfilename + "MergeTwoCell.odt"));
      Table savedTable1 = saveddoc.getTableByName("Table1");
      // get the cell range which the first cell is the covered cell.
      // so the cell range will be enlarged
      CellRange savedCellRange = savedTable1.getCellRangeByPosition(1, 0, 2, 0);
      savedCellRange.merge();
      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() + "'");
    }

    try {
      TextDocument saveddoc = (TextDocument) TextDocument.loadDocument(ResourceUtilities
          .getTestResourceAsStream(odtfilename + "MergeTwoCell.odt"));
      Table savedTable1 = saveddoc.getTableByName("Table1");
      // get the cell range which the first cell is the covered cell.
      // so the cell range will be enlarged
      CellRange savedCellRange = savedTable1.getCellRangeByPosition(0, 0, 0, 1);
      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

Examples of org.odftoolkit.simple.TextDocument

    Cell cell = firstColumn.getCellByPosition(0, 2);
    Cell firstCell = firstColumn.getCellByPosition(0, 0);
    Assert.assertTrue(cell.getOwnerTableCell().equals(firstCell));
    saveodt("MergeFirstColumn");
    try {
      TextDocument saveddoc = (TextDocument) TextDocument.loadDocument(ResourceUtilities
          .getTestResourceAsStream(odtfilename + "MergeFirstColumn.odt"));
      Table savedTable = saveddoc.getTableByName("Table1");
      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

Examples of org.odftoolkit.simple.TextDocument

      Assert.assertTrue(table.getColumnCount() == 5);
      Assert.assertTrue(table.getRowCount() == 1);
      table = ods.getTableByName("Sheet2");
      Assert.assertTrue(table.getColumnCount() == 6);
      Assert.assertTrue(table.getRowCount() == 3);
      TextDocument odt = TextDocument.newTextDocument();
      Table swTable = Table.newTable(odt, 1, 5);
      CellRange swCellRange = swTable.getCellRangeByPosition("A1", "E2");
      Cell swCell = swTable.getCellByPosition("E2");
      swCell.setStringValue("Merge A1:E2");
      swCellRange.merge();
      odt.save(ResourceUtilities.newTestOutputFile(odtfilename + "MergeTextExpandCell.odt"));
      swTable = odt.getTableList().get(0);
      Assert.assertTrue(swTable.getColumnCount() == 1);
      Assert.assertTrue(swTable.getRowCount() == 1);
    } catch (Exception ex) {
      Logger.getLogger(TableCellRangeTest.class.getName()).log(Level.SEVERE, ex.getMessage(), ex);
      Assert.fail("Failed with " + ex.getClass().getName() + ": '" + ex.getMessage() + "'");
View Full Code Here

Examples of org.odftoolkit.simple.TextDocument

  String headerDocumentPath = "HeaderTableDocument.odt";

  @Test
  public void testAddTable() {
    try {
      TextDocument doc = TextDocument.newTextDocument();
      Header header = doc.getHeader();
      Assert.assertNotNull(header);

      Table table = header.addTable();
      table.setTableName("headerTable");
      int rowCount = table.getRowCount();
      int columnCount = table.getColumnCount();
      String expectedCellValue = "header table cell";
      table.getCellByPosition(1, 1).setStringValue(expectedCellValue);
      Cell cell = table.getCellByPosition(4, 0);
      cell.setImage(ResourceUtilities.getURI("image_list_item.png"));
      // first page
      header = doc.getHeader(true);
      Assert.assertNotNull(header);

      table = header.addTable();
      table.setTableName("headerHTable");
      doc.save(ResourceUtilities.newTestOutputFile(headerDocumentPath));
     
      // load the document again.
      doc = TextDocument.loadDocument(ResourceUtilities.getTestResourceAsStream(headerDocumentPath));
      header = doc.getHeader();
      table = header.getTableByName("headerTable");
      Assert.assertEquals(rowCount, table.getRowCount());
      Assert.assertEquals(columnCount, table.getColumnCount());
      Assert.assertEquals(expectedCellValue, table.getCellByPosition(1, 1).getStringValue());
      cell = table.getCellByPosition(4, 0);
      Assert.assertEquals(34, cell.getBufferedImage().getHeight(null));
      table.getColumnByIndex(4).setWidth(15);
     
      header = doc.getHeader(true);
      table = header.getTableByName("headerHTable");
      Assert.assertNotNull(table);
    } catch (Exception e) {
      Logger.getLogger(HeaderTest.class.getName()).log(Level.SEVERE, null, e);
      Assert.fail(e.getMessage());
View Full Code Here

Examples of org.odftoolkit.simple.TextDocument

  }

  @Test
  public void testHeaderHidden() {
    try {
      TextDocument doc = TextDocument.loadDocument(ResourceUtilities.getTestResourceAsStream("headerFooterHidden.odt"));
      Header header = doc.getHeader();
      Assert.assertEquals(true, header.isVisible());
      header.setVisible(false);
      Assert.assertEquals(false, header.isVisible());
      doc.save(ResourceUtilities.newTestOutputFile("headerHiddenOutput.odt"));
    } catch (Exception e) {
      Logger.getLogger(HeaderTest.class.getName()).log(Level.SEVERE, null, e);
      Assert.fail(e.getMessage());
    }
  }
View Full Code Here

Examples of org.odftoolkit.simple.TextDocument

  }
 
  @Test
  public void testGetOdfElement() {
    try {
      TextDocument doc = TextDocument.loadDocument(ResourceUtilities.getTestResourceAsStream("headerFooterHidden.odt"));
      Header header = doc.getHeader();
      StyleHeaderElement styleheader = header.getOdfElement();
      Assert.assertNotNull(styleheader);
      Assert.assertEquals("header", styleheader.getLocalName());

      //save
      doc.save(ResourceUtilities.newTestOutputFile("headerHiddenOutput.odt"));
    } catch (Exception e) {
      Logger.getLogger(HeaderTest.class.getName()).log(Level.SEVERE, null, e);
      Assert.fail(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.