Package org.odftoolkit.simple.table

Examples of org.odftoolkit.simple.table.Cell


    // Paragraph, insert before the second Paragraph.
    search = new TextNavigation("SIMPLE", doc);
    while (search.hasNext()) {
      TextSelection item = (TextSelection) search.nextSelection();
      table = sourcedoc.getTableByName("Table1");
      Cell cell = table.getCellByPosition(0, 0);
      cell.setStringValue("SIMPLE");
      Table newtable = item.replaceWith(table);
      Assert.assertNotNull(newtable);
      Assert.assertEquals(1, newtable.getHeaderColumnCount());
      Assert.assertEquals(1, newtable.getHeaderRowCount());
      Assert.assertEquals(7 + 1, newtable.getRowCount());
      Assert.assertEquals(5 + 1, newtable.getColumnCount());
      cell = newtable.getCellByPosition(1, 1);
      Assert.assertEquals("string", cell.getValueType());
    }
    // 2 Task1, #1 at the start of original Paragraph, #2 replace original
    // Paragraph
    search = new TextNavigation("Task1", doc);
    while (search.hasNext()) {
      TextSelection item = (TextSelection) search.nextSelection();
      table = sourcedoc.getTableByName("Table2");
      Table newtable = item.replaceWith(table);
      Cell cell = newtable.getCellByPosition(0, 0);
      cell.setStringValue("From Source Table2");
      Assert.assertNotNull(newtable);
      Assert.assertEquals(1, newtable.getHeaderColumnCount());
      Assert.assertEquals(1, newtable.getHeaderRowCount());
      Assert.assertEquals(10 + 1, newtable.getRowCount());
      Assert.assertEquals(4 + 1, newtable.getColumnCount());
     
      cell = newtable.getCellByPosition(1, 1);
      Assert.assertEquals("float", cell.getValueType());
    }
    // 1 RESS%>, #1 at the end of original Paragraph,
    search = new TextNavigation("RESS%>", doc);
   
    while (search.hasNext()) {
      TextSelection item = (TextSelection) search.nextSelection();
      table = sourcedoc.getTableByName("Table3");
      Table newtable = item.replaceWith(table);
      Cell cell = newtable.getCellByPosition(0, 0);
      cell.setStringValue("From Source Table3");
      Assert.assertNotNull(newtable);
      Assert.assertEquals(5, newtable.getRowCount());
      Assert.assertEquals(3, newtable.getColumnCount());
    }
    try {
      doc.save(ResourceUtilities.newTestOutputFile("TextSelectionReplacewithTableResult.odt"));
    } catch (Exception e) {
      Logger.getLogger(TextSelectionTest.class.getName()).log(Level.SEVERE, e.getMessage(), e);
      Assert.fail("Failed with " + e.getClass().getName() + ": '" + e.getMessage() + "'");
    }
    doc = (TextDocument) Document.loadDocument(ResourceUtilities
        .getAbsolutePath(TEST_FILE));
    search = new TextNavigation("<<target>>", doc);
    int i = 0;
    try {
      while (search.hasNext()) {
        i++;
        TextSelection item = (TextSelection) search.nextSelection();
        table = sourcedoc.getTableByName("Table1");
        Table newtable = item.replaceWith(table);
        Assert.assertNotNull(newtable);
        Assert.assertEquals(1, newtable.getHeaderColumnCount());
        Assert.assertEquals(1, newtable.getHeaderRowCount());
        Assert.assertEquals(7 + 1, newtable.getRowCount());
        Assert.assertEquals(5 + 1, newtable.getColumnCount());
        Cell cell = newtable.getCellByPosition(1, 1);
        Assert.assertEquals("string", cell.getValueType());
      }
      doc.save(ResourceUtilities
          .newTestOutputFile("TextSelectionReplacewithTableResult-BasicCases.odt"));
      verifyReplaceWithTableByBasicCases("TextSelectionReplacewithTableResult-BasicCases.odt");
    } catch (Exception e) {
View Full Code Here


      TextDocument doc = TextDocument.newTextDocument();
      Section sect = doc.appendSection("TableSeciton");
      sect.addTable(2, 2);
      sect.addTable(2, 2);
      sect.addTable(5, 5).getCellByPosition("E5").setBooleanValue(true);
      Cell cell = sect.getTableByName("Table3").getCellByPosition(4, 4);
      Assert.assertNotNull(cell);
      Assert.assertTrue(cell.getBooleanValue());

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

          "RadioGroup1", "RadioButton 3", "3");
      radiobutton.setCurrentSelected(true);
      radiobutton.setAnchorType(AnchorType.AS_CHARACTER);

      Table table1 = Table.newTable(doc, 2, 2);
      Cell cell = table1.getCellByPosition("B1");
      para = cell.addParagraph("Insert a check box here.");
      form.createRadioButton(para, radioRtg, "RadioGroup1",
          "RadioButton 4", "4");
      doc.save(ResourceUtilities
          .newTestOutputFile("TestCreateRadioButton.odt"));
View Full Code Here

        Border borderbase = new Border(Color.LIME, 1.0701, 0.0208, 0.0346, SupportedLinearMeasure.CM);
      borderbase.setLineStyle(StyleTypeDefinitions.LineType.SINGLE);
      SpreadsheetDocument doc = SpreadsheetDocument.newSpreadsheetDocument();
      Table table = doc.getTableByName("Sheet1");
     
      Cell cell = table.getCellByPosition(2, 2);
      cell.setBorders(CellBordersType.BOTTOM, borderbase);
      cell.setBorders(CellBordersType.RIGHT, borderbase);
      cell.setBorders(CellBordersType.DIAGONALTLBR, borderbase);

      //verification
      Border base = cell.getBorder(CellBordersType.BOTTOM);
      base = cell.getBorder(CellBordersType.RIGHT);
      base = cell.getBorder(CellBordersType.DIAGONALTLBR);
      Assert.assertEquals(borderbase, base);
      Assert.assertEquals(StyleTypeDefinitions.LineType.SINGLE, borderbase.getLineStyle());
     
      //save
      doc.save(ResourceUtilities.newTestOutputFile("testSupportedLinearMeasure.ods"));
View Full Code Here

        Border borderbase = new Border(Color.LIME, 3.0701, 0.0208, 0.0346, SupportedLinearMeasure.CM);
      borderbase.setLineStyle(StyleTypeDefinitions.LineType.SINGLE);
      SpreadsheetDocument doc = SpreadsheetDocument.newSpreadsheetDocument();
      Table table = doc.getTableByName("Sheet1");
     
      Cell cell = table.getCellByPosition(0, 0);
      //cell.setBorders(CellBordersType.DIAGONAL_LINES, borderbase);
      cell.setBorders(CellBordersType.RIGHT, borderbase);

      //validate
      TableCellProperties styleCell = cell.getStyleHandler().getTableCellPropertiesForWrite();
      NamedNodeMap attr = styleCell.mElement.getAttributes();
      Node nod = attr.getNamedItem(FoBorderRightAttribute.ATTRIBUTE_NAME.getQName());
      Assert.assertEquals("3.0701cm solid #00ff00", nod.getNodeValue());
     
      cell.setBorders(CellBordersType.NONE, borderbase);
     
      TableCellProperties styleCell1 = cell.getStyleHandler().getTableCellPropertiesForWrite();
      NamedNodeMap attr1 = styleCell1.mElement.getAttributes();
      Node nod1 = attr1.getNamedItem(FoBorderRightAttribute.ATTRIBUTE_NAME.getQName());
      Assert.assertNull(nod1);
     
      //save
View Full Code Here

        Border borderbase = new Border(Color.LIME, 3.0701, 0.0208, 0.0346, SupportedLinearMeasure.CM);
      borderbase.setLineStyle(StyleTypeDefinitions.LineType.SINGLE);
      SpreadsheetDocument doc = SpreadsheetDocument.newSpreadsheetDocument();
      Table table = doc.getTableByName("Sheet1");
     
      Cell cell = table.getCellByPosition(0, 0);
      cell.setBorders(CellBordersType.DIAGONAL_LINES, borderbase);

      //validate
      TableCellProperties styleCell = cell.getStyleHandler().getTableCellPropertiesForWrite();
      NamedNodeMap attr = styleCell.mElement.getAttributes();
     
      Node nod = attr.getNamedItem("style:diagonal-bl-tr");
      Assert.assertEquals("3.0701cm solid #00ff00", nod.getNodeValue());
     
View Full Code Here

      Border borderbase = new Border(Color.LIME, 3.0701, 0.0208, 0.0346, SupportedLinearMeasure.CM);
      borderbase.setLineStyle(StyleTypeDefinitions.LineType.SINGLE);
      SpreadsheetDocument doc = SpreadsheetDocument.newSpreadsheetDocument();
      Table table = doc.getTableByName("Sheet1");
     
      Cell cell = table.getCellByPosition(2, 2);
      cell.setBorders(CellBordersType.ALL_FOUR, borderbase);

      //validate
      TableCellProperties styleCell = cell.getStyleHandler().getTableCellPropertiesForWrite();
      Border bor = styleCell.getBorder();
      Assert.assertEquals(borderbase, bor);
     
      //save
      doc.save(ResourceUtilities.newTestOutputFile("testSupportedLinearMeasure.ods"));
View Full Code Here

      Border borderbase = new Border(Color.LIME, 3.0701, 0.0208, 0.0346, SupportedLinearMeasure.CM);
      borderbase.setLineStyle(StyleTypeDefinitions.LineType.DOUBLE);
      SpreadsheetDocument doc = SpreadsheetDocument.newSpreadsheetDocument();
      Table table = doc.getTableByName("Sheet1");
     
      Cell cell = table.getCellByPosition(2, 2);
      cell.setBorders(CellBordersType.RIGHT, borderbase);

      //validate
      TableCellProperties styleCell = cell.getStyleHandler().getTableCellPropertiesForWrite();
      Border bor = styleCell.getRightBorder();
      Assert.assertEquals(borderbase, bor);
     
      //save
      doc.save(ResourceUtilities.newTestOutputFile("testSupportedLinearMeasure.ods"));
View Full Code Here

 
        @Test
  public void testSettingNullBackgroundOnProperties() throws Exception {
            SpreadsheetDocument doc = SpreadsheetDocument.newSpreadsheetDocument();
            Table table = doc.getTableByName("Sheet1");
            Cell cell = table.getCellByPosition(1, 1);
            cell.setCellBackgroundColor(Color.BLACK);
            // setting null resets the element, see ODFTOOLKIT-326
            cell.getStyleHandler().getTableCellPropertiesForWrite().setBackgroundColor(null);
            Assert.assertNull(cell.getStyleHandler().getTableCellPropertiesForRead().getBackgroundColor());
            // defaulting to white when color is null
            Assert.assertEquals(Color.WHITE, cell.getCellBackgroundColor());
            Cell newCell = table.appendRow().getCellByIndex(1);
            Assert.assertNull(newCell.getStyleHandler().getTableCellPropertiesForRead().getBackgroundColor());
            Assert.assertEquals(Color.WHITE, newCell.getCellBackgroundColor());
        }
View Full Code Here

       
        @Test
        public void testSettingBlackBackgroundOnProperties() throws Exception {
            SpreadsheetDocument doc = SpreadsheetDocument.newSpreadsheetDocument();
            Table table = doc.getTableByName("Sheet1");
            Cell cell = table.getCellByPosition(1, 1);
            cell.setCellBackgroundColor(Color.BLUE);
            cell.getStyleHandler().getTableCellPropertiesForWrite().setBackgroundColor(Color.BLACK);
            Assert.assertEquals(Color.BLACK, cell.getStyleHandler().getTableCellPropertiesForRead().getBackgroundColor());
            Assert.assertEquals(Color.BLACK, cell.getCellBackgroundColor());
            Cell newCell = table.appendRow().getCellByIndex(1);
            Assert.assertEquals(Color.BLACK, newCell.getStyleHandler().getBackgroundColor());
        }
View Full Code Here

TOP

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

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.