Package org.odftoolkit.simple.table

Examples of org.odftoolkit.simple.table.Table


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


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

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

  public void testAddTable() {
    try {
      TextDocument doc = TextDocument.newTextDocument();
      Section theSec = doc.appendSection("TableSection");

      Table table1 = theSec.addTable();
      table1.getCellByPosition("A1").addParagraph("A1");
      OdfElement odfEle = theSec.getTableContainerElement();
      Assert.assertEquals("A1", Table.getInstance(
          (TableTableElement) odfEle.getLastChild())
          .getCellByPosition("A1").getDisplayText());

      Table table2 = theSec.addTable(3, 3);
      table2.getCellByPosition("C3").addParagraph("C3");
      odfEle = theSec.getTableContainerElement();
      Assert.assertEquals("C3", Table.getInstance(
          (TableTableElement) odfEle.getLastChild())
          .getCellByPosition("C3").getDisplayText());

      table1.remove();
      table2.remove();
      OdfElement odfEle1 = theSec.getTableContainerElement();
      Assert.assertNull(odfEle1.getLastChild());

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

      }
      search = new TextNavigation("#3", doc);
      OdfElement description = search.nextSelection().getElement();
      Node replacement = description.getNextSibling();
      Assert.assertTrue(replacement instanceof TableTableElement);
      Table table = Table.getInstance((TableTableElement) replacement);
      String breakBefore = table.getStyleHandler()
          .getTablePropertiesForRead().getBreakBefore();
      Assert.assertNotNull(breakBefore);
      description = search.nextSelection().getElement();
      replacement = description.getNextSibling();
      Assert.assertEquals("prefix", TextExtractor
          .getText((TextParagraphElementBase) replacement));
      Paragraph para = Paragraph
          .getInstanceof((TextParagraphElementBase) replacement);
      breakBefore = para.getStyleHandler()
          .getParagraphPropertiesForRead().getBreakBefore();
      Assert.assertNotNull(breakBefore);
      replacement = replacement.getNextSibling();
      Assert.assertTrue(replacement instanceof TableTableElement);
      table = Table.getInstance((TableTableElement) replacement);
      breakBefore = table.getStyleHandler().getTablePropertiesForRead()
          .getBreakBefore();
      Assert.assertNull(breakBefore);
      replacement = replacement.getNextSibling();
      Assert.assertEquals("suffix", TextExtractor
          .getText((TextParagraphElementBase) replacement));
      para = Paragraph
          .getInstanceof((TextParagraphElementBase) replacement);
      breakBefore = para.getStyleHandler()
          .getParagraphPropertiesForRead().getBreakBefore();
      Assert.assertNull(breakBefore);
      description = search.nextSelection().getElement();
      replacement = description.getNextSibling();
      Assert.assertTrue(replacement instanceof TableTableElement);
      table = Table.getInstance((TableTableElement) replacement);
      String masterStyle = table.getStyleHandler()
          .getStyleElementForRead()
          .getAttribute("style:master-page-name");
      Assert.assertNotNull(masterStyle);
    } catch (Exception e) {
      Logger.getLogger(TextSelectionTest.class.getName()).log(
View Full Code Here

  @Test
  public void testFrameHorizontalPosition() {
    try {
      // new image in a table
      TextDocument sDoc = TextDocument.newTextDocument();
      Table table1 = sDoc.addTable(2, 2);
      Cell cell1 = table1.getCellByPosition(0, 0);
      Image image3 = cell1.setImage(ResourceUtilities.getURI("image_list_item.png"));
      image3.setHorizontalPosition(FrameHorizontalPosition.LEFT);
      Assert.assertEquals(FrameHorizontalPosition.LEFT, image3.getHorizontalPosition());
     
      //
View Full Code Here

      radiobutton = (RadioButton) form.createRadioButton(para, radioRtg,
          "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

  public void testAddTable() {
    try {
      doc = PresentationDocument.loadDocument(ResourceUtilities.getTestResourceAsStream(TEST_PRESENTATION_FILE_MAIN));
      // add table.
      TableContainer container = doc.newSlide(2, "title_plus_text", Slide.SlideLayout.TITLE_PLUS_TEXT);
      Table table = container.addTable();
      table.setTableName("SlideTable");
      String slideTableCellValue = "SlideTable Cell String";
      table.getCellByPosition(0, 0).setStringValue(slideTableCellValue);
      doc.save(ResourceUtilities.newTestOutputFile("SlideTableOutput.odp"));
     
      //load
      doc = PresentationDocument.loadDocument(ResourceUtilities.getTestResourceAsStream("SlideTableOutput.odp"));
      Assert.assertEquals(slideTableCellValue, table.getCellByPosition(0, 0).getStringValue());

    } catch (Exception e) {
      LOG.log(Level.SEVERE, null, e);
      Assert.fail(e.getMessage());
    }
View Full Code Here

    try {
      //Creates an empty presentation document.
      doc = PresentationDocument.newPresentationDocument();
     
      TableContainer container = doc.newSlide(0, "testlayout", Slide.SlideLayout.TITLE_SUBTITLE);
      Table table = container.addTable();
      table.setTableName("SlideTable");
      String slideTableCellValue = " Cell[0,0]";
      table.getCellByPosition(0, 0).setStringValue(slideTableCellValue);
      String slideTableCellValue1 = " Cell[0,1]";
      table.getCellByPosition(0, 1).setStringValue(slideTableCellValue1);
      doc.save(ResourceUtilities.newTestOutputFile("slidetitlelayout.odp"));
     
      //load
      doc = PresentationDocument.loadDocument(ResourceUtilities.getTestResourceAsStream("slidetitlelayout.odp"));
      Slide slide = doc.getSlideByIndex(0);
      Slide slide1 = doc.getSlideByName("testlayout");

      //validate
      Node nodetitle = slide1.getOdfElement().getFirstChild();
      Assert.assertEquals("frame", nodetitle.getLocalName());
      NamedNodeMap map = nodetitle.getAttributes();
      Assert.assertEquals("layout", map.item(0).getNodeValue());
      Assert.assertEquals("title", map.item(1).getNodeValue());
     
      //
      Node nodetitle1 = slide1.getOdfElement().getFirstChild().getNextSibling();
      Assert.assertEquals("frame", nodetitle1.getLocalName());
      NamedNodeMap map1 = nodetitle1.getAttributes();
      Assert.assertEquals("layout", map1.item(0).getNodeValue());
      Assert.assertEquals("subtitle", map1.item(1).getNodeValue());
     
      if(slide.equals(slide1))
        Assert.assertEquals(slide, slide1);

      Assert.assertEquals(slideTableCellValue, table.getCellByPosition(0, 0).getStringValue());
      Assert.assertEquals(slideTableCellValue1, table.getCellByPosition(0, 1).getStringValue());

    } catch (Exception e) {
      LOG.log(Level.SEVERE, e.getMessage(), e);
      Assert.fail("Failed with " + e.getClass().getName() + ": '" + e.getMessage() + "'");
    }
View Full Code Here

    try {
     
        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
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.