Package org.odftoolkit.simple.table

Examples of org.odftoolkit.simple.table.Table


    updateTableToNone(table);
    return table;
  }

  public Table addTable(int numRows, int numCols) {
    Table table = getTableContainerImpl().addTable(numRows, numCols);
    updateTableToNone(table);
    return table;
  }
View Full Code Here


      textEle.setStyleName(newStyle.getStyleNameAttribute());
    }
  }
 
  public Table addTable() {
    Table table = getTableContainerImpl().addTable();
    updateTableToNone(table);
    return table;
  }
View Full Code Here

    updateTableToNone(table);
    return table;
  }

  public Table addTable(int numRows, int numCols) {
    Table table = getTableContainerImpl().addTable(numRows, numCols);
    updateTableToNone(table);
    return table;
  }
View Full Code Here

  }
 

  private void replace(ReplacementAction replacementAction) throws Exception {
    TextDocument docToReplaceIn = TextDocument.newTextDocument();
    Table newTable = docToReplaceIn.getTableBuilder().newTable(2, 2);
    Cell cell = newTable.getCellByPosition(0, 0);
    cell.addParagraph("<<ONE>>");
    cell.addParagraph("<<TWO>>");

    Map<String, String> replacements = new TreeMap<String, String>();
    replacements.put("<<ONE>>", "1");
View Full Code Here

    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) {
View Full Code Here

  @Test
  public void testGetTableList() {
    try {
      TextDocument doc = TextDocument.newTextDocument();
      Header header = doc.getHeader();
      Table tab = header.addTable();
     
      //validate
      List<Table> listTab = header.getTableList();
      Table tab1 = listTab.get(0);
      Assert.assertNotNull(tab1);
      Assert.assertEquals(tab, tab1);

      //save
      doc.save(ResourceUtilities.newTestOutputFile("headerTableOutput.odt"));
View Full Code Here

    try {
      TextDocument doc = TextDocument.newTextDocument();
      Header header = doc.getHeader();
     
      TableBuilder tabBuilder = header.getTableBuilder();
      Table tab = tabBuilder.newTable();
      Assert.assertNotNull(tab);
      Assert.assertTrue(2 == tab.getRowCount());
      Assert.assertTrue(5 == tab.getColumnCount());
     
      //validate
      List<Table> listTab = header.getTableList();
      Table tab1 = listTab.get(0);
      Assert.assertNotNull(tab1);
      Assert.assertEquals(tab, tab1);

      //save
      doc.save(ResourceUtilities.newTestOutputFile("headerTableOutput.odt"));
View Full Code Here

      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
View Full Code Here

    try {
      TextDocument doc = TextDocument.newTextDocument();
      Footer footer = doc.getFooter();
      Assert.assertNotNull(footer);

      Table table = footer.addTable(1, 1);
      table.setTableName("footerTable");
      int rowCount = table.getRowCount();
      int columnCount = table.getColumnCount();
      String expectedCellValue = "footer table cell";
      Cell cellByPosition = table.getCellByPosition(0, 0);
      cellByPosition.setStringValue(expectedCellValue);
      cellByPosition.setHorizontalAlignment(HorizontalAlignmentType.CENTER);
      cellByPosition.setCellBackgroundColor(Color.GREEN);
     
      //first page
      footer = doc.getFooter(true);
      Assert.assertNotNull(footer);
      table = footer.addTable(1, 2);
      table.setTableName("footerFTable");
      doc.save(ResourceUtilities.newTestOutputFile(footerDocumentPath));

      // load the document again.
      doc = TextDocument.loadDocument(ResourceUtilities.getTestResourceAsStream(footerDocumentPath));
      footer = doc.getFooter();
      table = footer.getTableByName("footerTable");
      Assert.assertEquals(rowCount, table.getRowCount());
      Assert.assertEquals(columnCount, table.getColumnCount());
      Assert.assertEquals(expectedCellValue, cellByPosition.getStringValue());

      footer = doc.getFooter(true);
      table = footer.getTableByName("footerFTable");
      Assert.assertNotNull(table);
View Full Code Here

  public void testAddtable() {
    try {
      //TextDocument doc = TextDocument.loadDocument(ResourceUtilities.getTestResourceAsStream("headerFooterHidden.odt"));
      TextDocument doc = TextDocument.newTextDocument();
      Footer footer = doc.getFooter();
      Table tab = footer.addTable();
      Assert.assertNotNull(tab);
      Assert.assertTrue(2 == tab.getRowCount());
      Assert.assertTrue(5 == tab.getColumnCount());
     
      TableTableElement tabEle = tab.getOdfElement();
      System.out.println(tabEle);
     
      //save
      //doc.save(ResourceUtilities.newTestOutputFile("footerOutput.odt"));
    } catch (Exception e) {
View Full Code Here

TOP

Related Classes of org.odftoolkit.simple.table.Table

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.