Package org.odftoolkit.simple.table

Examples of org.odftoolkit.simple.table.Cell$ListContainerImpl


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


      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);
    } catch (Exception e) {
View Full Code Here

      } else {
        Assert.fail("list iterate fail.");
      }
      // list in cell
      Table table = Table.newTable(odtdoc);
      Cell cell = table.getCellByPosition(0, 0);
      List cellList = cell.addList();
      Assert.assertTrue(cellList.getLevel() == 1);
    } catch (Exception e) {
      Logger.getLogger(ListTest.class.getName()).log(Level.SEVERE, null, e);
      Assert.fail(e.getMessage());
    }
View Full Code Here

    Font font4Base = new Font("Arial", FontStyle.REGULAR, 10, Color.BLACK, TextLinePosition.UNDER);
    try {
      SpreadsheetDocument doc = SpreadsheetDocument.loadDocument(ResourceUtilities
          .getTestResourceAsStream(filename));
      Table table = doc.getTableByName("A");
      Cell cell1 = table.getCellByPosition("A2");
      CellStyleHandler handler1 = cell1.getStyleHandler();
      Font font1 = handler1.getFont(Document.ScriptType.WESTERN);
      Assert.assertEquals(font1Base, font1);

      Cell cell2 = table.getCellByPosition("A3");
      CellStyleHandler handler2 = cell2.getStyleHandler();
      Font font2 = handler2.getFont(Document.ScriptType.WESTERN);
      Assert.assertEquals(font2Base, font2);

      Cell cell3 = table.getCellByPosition("A4");
      CellStyleHandler handler3 = cell3.getStyleHandler();
      Font font3 = handler3.getFont(Document.ScriptType.CJK);
      Assert.assertEquals(font3Base, font3);
      Font font4 = handler3.getFont(Document.ScriptType.WESTERN);
      Assert.assertEquals(font4Base, font4);

      Cell cell5 = table.getCellByPosition("B2");
      cell5.getStyleHandler().setFont(font1Base);
      cell5.setStringValue("Arial Italic black 10");
      Assert.assertEquals(font1Base, cell5.getStyleHandler().getFont(Document.ScriptType.WESTERN));

      Cell cell6 = table.getCellByPosition("B3");
      // font2Base.setLocale();
      cell6.getStyleHandler()
          .setFont(font2Base, new Locale(Locale.ENGLISH.getLanguage(), Locale.US.getCountry()));
      cell6.setStringValue("Times New Roman, Regular, 13.9, Red");
      Assert.assertEquals(font2Base, cell6.getStyleHandler().getFont(Document.ScriptType.WESTERN));

      Cell cell7 = table.getCellByPosition("B4");
      cell7.getStyleHandler().setFont(font3Base,
          new Locale(Locale.CHINESE.getLanguage(), Locale.CHINA.getCountry()));
      cell7.getStyleHandler()
          .setFont(font4Base, new Locale(Locale.ENGLISH.getLanguage(), Locale.US.getCountry()));
      cell7.setStringValue("SimSun BOLD 8 BLACK");
      Assert.assertEquals(font3Base, cell7.getStyleHandler().getFont(Document.ScriptType.CJK));
      Assert.assertEquals(font4Base, cell7.getStyleHandler().getFont(Document.ScriptType.WESTERN));

      doc.save(ResourceUtilities.newTestOutputFile("testFontOutput.ods"));

    } catch (Exception e) {
      e.printStackTrace();
View Full Code Here

  public void testNewFont1() {
    try {
      SpreadsheetDocument document = SpreadsheetDocument.newSpreadsheetDocument();
      Table table = document.getTableByName("Sheet1");
      Font font = new Font("Arial", StyleTypeDefinitions.FontStyle.ITALIC, 17.5);
      Cell cell = table.getCellByPosition("A1");
      cell.setFont(font);
      cell.setStringValue("Hello world .");
     
      //save
      document.save(ResourceUtilities.newTestOutputFile("testFontOutput1.ods"));
     
      //validate
      SpreadsheetDocument doc = SpreadsheetDocument.loadDocument(ResourceUtilities
          .getTestResourceAsStream("testFontOutput1.ods"));
      Table table1 = doc.getTableByName("Sheet1");
      Cell cell1 = table1.getCellByPosition("A1");
      Font font1 = cell1.getFont();
      Assert.assertEquals(font.getFamilyName(), font1.getFamilyName());
      Assert.assertEquals(font.getSize(), font1.getSize());
      Assert.assertEquals(font.getFontStyle(), font1.getFontStyle());
     
    } catch (Exception e) {
View Full Code Here

  public void testNewFont2() {
    try {
      SpreadsheetDocument document = SpreadsheetDocument.newSpreadsheetDocument();
      Table table = document.getTableByName("Sheet1");
      Font font = new Font("Arial", StyleTypeDefinitions.FontStyle.ITALIC, 17.5, Color.BLUE);
      Cell cell = table.getCellByPosition("A1");
      cell.setFont(font);
      cell.setStringValue("Hello world .");
     
      //save
      document.save(ResourceUtilities.newTestOutputFile("testFontOutput1.ods"));
     
      //validate
      SpreadsheetDocument doc = SpreadsheetDocument.loadDocument(ResourceUtilities
          .getTestResourceAsStream("testFontOutput1.ods"));
      Table table1 = doc.getTableByName("Sheet1");
      Cell cell1 = table1.getCellByPosition("A1");
      Font font1 = cell1.getFont();
      Assert.assertEquals(font.getFamilyName(), font1.getFamilyName());
      Assert.assertEquals(font.getSize(), font1.getSize());
      Assert.assertEquals(font.getFontStyle(), font1.getFontStyle());
      Assert.assertEquals(font.getColor().toString(), font1.getColor().toString());
      Assert.assertEquals(font, font1);
View Full Code Here

  public void testNewFont3() {
    try {
      SpreadsheetDocument document = SpreadsheetDocument.newSpreadsheetDocument();
      Table table = document.getTableByName("Sheet1");
      Font font = new Font("Arial", StyleTypeDefinitions.FontStyle.ITALIC, 17.5, Locale.ENGLISH);
      Cell cell = table.getCellByPosition("A1");
      cell.setFont(font);
      cell.setStringValue("Hi World.");
     
      //save
      document.save(ResourceUtilities.newTestOutputFile("testFontOutput1.ods"));
     
      //validate
      SpreadsheetDocument doc = SpreadsheetDocument.loadDocument(ResourceUtilities
          .getTestResourceAsStream("testFontOutput1.ods"));
      Table table1 = doc.getTableByName("Sheet1");
      Cell cell1 = table1.getCellByPosition("A1");
      Font font1 = cell1.getFont();
      Assert.assertEquals(font.getFamilyName(), font1.getFamilyName());
      Assert.assertEquals(font.getSize(), font1.getSize());
      Assert.assertEquals(font.getFontStyle(), font1.getFontStyle());
      Assert.assertEquals(font.getTextLinePosition(), font1.getTextLinePosition());
    //  Assert.assertEquals(font, font1);
View Full Code Here

  public void testNewFont4() {
    try {
      SpreadsheetDocument document = SpreadsheetDocument.newSpreadsheetDocument();
      Table table = document.getTableByName("Sheet1");
      Font font = new Font("Arial", StyleTypeDefinitions.FontStyle.ITALIC, 17.5, Color.GREEN, Locale.ENGLISH);
      Cell cell = table.getCellByPosition("A1");
      cell.setFont(font);
      cell.setStringValue("Hi World.");
     
      //save
      document.save(ResourceUtilities.newTestOutputFile("testFontOutput1.ods"));
     
      //validate
      SpreadsheetDocument doc = SpreadsheetDocument.loadDocument(ResourceUtilities
          .getTestResourceAsStream("testFontOutput1.ods"));
      Table table1 = doc.getTableByName("Sheet1");
      Cell cell1 = table1.getCellByPosition("A1");
      Font font1 = cell1.getFont();
      Assert.assertEquals(font.getFamilyName(), font1.getFamilyName());
      Assert.assertEquals(font.getSize(), font1.getSize());
      Assert.assertEquals(font.getFontStyle(), font1.getFontStyle());
      Assert.assertEquals(font.getTextLinePosition(), font1.getTextLinePosition());
      Assert.assertEquals(font.getColor().toString(), font1.getColor().toString());
View Full Code Here

  public void testNewFont5() {
    try {
      SpreadsheetDocument document = SpreadsheetDocument.newSpreadsheetDocument();
      Table table = document.getTableByName("Sheet1");
      Font font = new Font("Arial", StyleTypeDefinitions.FontStyle.ITALIC, 17.5, Color.GREEN, StyleTypeDefinitions.TextLinePosition.REGULAR, Locale.ENGLISH);
      Cell cell = table.getCellByPosition("A1");
      cell.setFont(font);
      cell.setStringValue("Hi World.");
     
      //save
      document.save(ResourceUtilities.newTestOutputFile("testFontOutput1.ods"));
     
      //validate
      SpreadsheetDocument doc = SpreadsheetDocument.loadDocument(ResourceUtilities
          .getTestResourceAsStream("testFontOutput1.ods"));
      Table table1 = doc.getTableByName("Sheet1");
      Cell cell1 = table1.getCellByPosition("A1");
      Font font1 = cell1.getFont();
      Assert.assertEquals(font.getFamilyName(), font1.getFamilyName());
      Assert.assertEquals(font.getSize(), font1.getSize());
      Assert.assertEquals(font.getFontStyle(), font1.getFontStyle());
      Assert.assertEquals(font.getTextLinePosition(), font1.getTextLinePosition());
      Assert.assertEquals(font.getColor().toString(), font1.getColor().toString());
View Full Code Here

  public void testEquals() {
    try {
      SpreadsheetDocument document = SpreadsheetDocument.newSpreadsheetDocument();
      Table table = document.getTableByName("Sheet1");
      Font font = new Font("Arial", StyleTypeDefinitions.FontStyle.ITALIC, 17.5, Color.GREEN, StyleTypeDefinitions.TextLinePosition.REGULAR, Locale.ENGLISH);
      Cell cell = table.getCellByPosition("A1");
      cell.setFont(font);
      cell.setStringValue("Hi World.");
     
      //save
      document.save(ResourceUtilities.newTestOutputFile("testFontOutput1.ods"));
     
      //validate
      SpreadsheetDocument doc = SpreadsheetDocument.loadDocument(ResourceUtilities
          .getTestResourceAsStream("testFontOutput1.ods"));
      Table table1 = doc.getTableByName("Sheet1");
      Cell cell1 = table1.getCellByPosition("A1");
      Font font1 = cell1.getFont();
     
      Assert.assertTrue(font.equals(font1));
     
    } catch (Exception e) {
      e.printStackTrace();
View Full Code Here

TOP

Related Classes of org.odftoolkit.simple.table.Cell$ListContainerImpl

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.