Package org.odftoolkit.simple.table

Examples of org.odftoolkit.simple.table.Cell


      // label3
      Paragraph para = doc.addParagraph("Insert a Label here.");
      form.createLabel(para, labelRtg, "Label3", "Label3");
      // label4
      Table table1 = Table.newTable(doc, 2, 2);
      Cell cell = table1.getCellByPosition("B1");
      para = cell.addParagraph("Insert a Label here.");
      form.createLabel(para, labelRtg, "Label4", "Label4");
      doc
          .save(ResourceUtilities
              .newTestOutputFile("TestCreateLabel.odt"));
View Full Code Here


    try {
      Border borderbase = new Border(Color.LIME, 4.0701, 1.0008, 1.0346, SupportedLinearMeasure.CM);
      SpreadsheetDocument doc = SpreadsheetDocument.newSpreadsheetDocument();
      Table table = doc.getTableByName("Sheet1");
     
      Cell cell = table.getCellByPosition(2, 2);
      cell.setBorders(CellBordersType.TOP, borderbase);
      cell.setBorders(CellBordersType.LEFT, borderbase);

      //verification
      Border base = cell.getBorder(CellBordersType.LEFT);
      base = cell.getBorder(CellBordersType.TOP);
      Assert.assertEquals(borderbase, base);
     
      //
      double ins = SupportedLinearMeasure.PT.toINs(216.00);
      Assert.assertTrue(3.0 == ins);
View Full Code Here

    try {
      Border borderbase = new Border(Color.LIME, 4.0701, 1.0008, 1.0346, SupportedLinearMeasure.CM);
      SpreadsheetDocument doc = SpreadsheetDocument.newSpreadsheetDocument();
      Table table = doc.getTableByName("Sheet1");
     
      Cell cell = table.getCellByPosition(2, 2);
      cell.setBorders(CellBordersType.TOP, borderbase);
      cell.setBorders(CellBordersType.LEFT, borderbase);

      //verification
      Border base = cell.getBorder(CellBordersType.LEFT);
      base = cell.getBorder(CellBordersType.TOP);
      Assert.assertEquals(borderbase, base);
     
      //
      CellBordersType cellType = CellBordersType.enumValueOf("bottom");
      Assert.assertEquals("bottom", cellType.toString());
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.TOP, borderbase);
      cell.setBorders(CellBordersType.LEFT, borderbase);

      //verification
      Border base = cell.getBorder(CellBordersType.LEFT);
      base = cell.getBorder(CellBordersType.TOP);
      Assert.assertEquals(borderbase, base);
      Assert.assertEquals(StyleTypeDefinitions.LineType.SINGLE, borderbase.getLineStyle());
      //
      StyleTypeDefinitions.LineType lType = StyleTypeDefinitions.LineType.enumValueOf("double");
      Assert.assertEquals("double", lType.toString());
View Full Code Here

  public void testFrameVerticalPosition() throws Exception{
      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.setVerticalPosition(FrameVerticalPosition.BELOW);
   
    //validate
    Assert.assertEquals(FrameVerticalPosition.BELOW, image3.getVerticalPosition());
   
View Full Code Here

  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());
     
      //
      FrameHorizontalPosition hor = FrameHorizontalPosition.enumValueOf("");
View Full Code Here

    TextSelection item = null;
    Node parent = containerElement.getParentNode();
    while (parent != null) {
      if (TableTableCellElementBase.class.isInstance(parent)) {
        TableTableCellElementBase cellElement = (TableTableCellElementBase) parent;
        Cell cell = Cell.getInstance(cellElement);
        item = new CellSelection(this, mNextText, containerElement,
            nextIndex, cell);
        break;
      } else {
        OdfName odfName = ((OdfElement) parent).getOdfName();
View Full Code Here

    int rowCount = table.getRowCount();
    for (int i = rowCount - 1; i >= 0; i--) {
      Row row = table.getRowByIndex(i);
      int cellCount = row.getCellCount();
      for (int j = cellCount - 1; j >= 0; j--) {
        Cell cell = row.getCellByIndex(j);
        paragraph = cell.getParagraphByReverseIndex(0, false);
        if (paragraph != null)
          return paragraph;
      }
    }
    return paragraph;
View Full Code Here

    TableTemplate template = new TableTemplate(getStylesDom()
        .newOdfElement(TableTableTemplateElement.class));

    // first-row-start-column
    Cell cell = table.getCellByPosition(0, 0);
    cell.getParagraphIterator().hasNext();
    cell.getParagraphIterator().next().getStyleName();
    Paragraph para = cell.getParagraphByIndex(0, false);
    String paraStyle = (para != null ? para.getStyleName() : null);
    template.setExtendedStyleByType(
        TableTemplate.ExtendedStyleType.FIRSTROWSTARTCOLUM, cell
            .getStyleName(), paraStyle);
    TableTableCellElementBase oldCellEle = cell.getOdfElement();
    TableTableCellElementBase newCellEle = (TableTableCellElementBase) oldCellEle
        .cloneNode(true);
    copyForeignStyleRef(newCellEle, cell.getOwnerDocument());

    // first-row-end-column
    cell = table.getCellByPosition(4, 0);
    para = cell.getParagraphByIndex(0, false);
    paraStyle = (para != null ? para.getStyleName() : null);
    template.setExtendedStyleByType(
        TableTemplate.ExtendedStyleType.FIRSTROWENDCOLUMN, cell
            .getStyleName(), paraStyle);
    oldCellEle = cell.getOdfElement();
    newCellEle = (TableTableCellElementBase) oldCellEle.cloneNode(true);
    copyForeignStyleRef(newCellEle, cell.getOwnerDocument());

    // last-row-start-column
    cell = table.getCellByPosition(0, 4);
    para = cell.getParagraphByIndex(0, false);
    paraStyle = (para != null ? para.getStyleName() : null);
    template.setExtendedStyleByType(
        TableTemplate.ExtendedStyleType.LASTROWSTARTCOLUMN, cell
            .getStyleName(), paraStyle);
    oldCellEle = cell.getOdfElement();
    newCellEle = (TableTableCellElementBase) oldCellEle.cloneNode(true);
    copyForeignStyleRef(newCellEle, cell.getOwnerDocument());

    // last-row-end-column
    cell = table.getCellByPosition(4, 4);
    para = cell.getParagraphByIndex(0, false);
    paraStyle = (para != null ? para.getStyleName() : null);
    template.setExtendedStyleByType(
        TableTemplate.ExtendedStyleType.LASTROWENDCOLUMN, cell
            .getStyleName(), paraStyle);
    oldCellEle = cell.getOdfElement();
    newCellEle = (TableTableCellElementBase) oldCellEle.cloneNode(true);
    copyForeignStyleRef(newCellEle, cell.getOwnerDocument());

    // first column
    cell = table.getCellByPosition(0, 1);
    para = cell.getParagraphByIndex(0, false);
    paraStyle = (para != null ? para.getStyleName() : null);
    template.setTableFirstColumnStyle(cell.getStyleName(), paraStyle);
    oldCellEle = cell.getOdfElement();
    newCellEle = (TableTableCellElementBase) oldCellEle.cloneNode(true);
    copyForeignStyleRef(newCellEle, cell.getOwnerDocument());

    // last column
    cell = table.getCellByPosition(4, 2);
    para = cell.getParagraphByIndex(0, false);
    paraStyle = (para != null ? para.getStyleName() : null);
    template.setTableLastColumnStyle(cell.getStyleName(), paraStyle);
    oldCellEle = cell.getOdfElement();
    newCellEle = (TableTableCellElementBase) oldCellEle.cloneNode(true);
    copyForeignStyleRef(newCellEle, cell.getOwnerDocument());

    // first row
    cell = table.getCellByPosition(1, 0);
    para = cell.getParagraphByIndex(0, false);
    paraStyle = (para != null ? para.getStyleName() : null);
    template.setTableFirstRowStyle(cell.getStyleName(), paraStyle);
    oldCellEle = cell.getOdfElement();
    newCellEle = (TableTableCellElementBase) oldCellEle.cloneNode(true);
    copyForeignStyleRef(newCellEle, cell.getOwnerDocument());

    // last row
    cell = table.getCellByPosition(1, 4);
    para = cell.getParagraphByIndex(0, false);
    paraStyle = (para != null ? para.getStyleName() : null);
    template.setTableLastRowStyle(cell.getStyleName(), paraStyle);
    oldCellEle = cell.getOdfElement();
    newCellEle = (TableTableCellElementBase) oldCellEle.cloneNode(true);
    copyForeignStyleRef(newCellEle, cell.getOwnerDocument());

    // body (=odd row/column)
    cell = table.getCellByPosition(1, 1);
    para = cell.getParagraphByIndex(0, false);
    paraStyle = (para != null ? para.getStyleName() : null);
    template.setTableBodyStyle(cell.getStyleName(), paraStyle);
    template.setTableOddRowsStyle(cell.getStyleName(), paraStyle);
    template.setTableOddColumnsStyle(cell.getStyleName(), paraStyle);
    oldCellEle = cell.getOdfElement();
    newCellEle = (TableTableCellElementBase) oldCellEle.cloneNode(true);
    copyForeignStyleRef(newCellEle, cell.getOwnerDocument());

    // even row
    cell = table.getCellByPosition(1, 2);
    para = cell.getParagraphByIndex(0, false);
    paraStyle = (para != null ? para.getStyleName() : null);
    template.setTableEvenRowsStyle(cell.getStyleName(), paraStyle);
    oldCellEle = cell.getOdfElement();
    newCellEle = (TableTableCellElementBase) oldCellEle.cloneNode(true);
    copyForeignStyleRef(newCellEle, cell.getOwnerDocument());

    // even row
    cell = table.getCellByPosition(2, 1);
    para = cell.getParagraphByIndex(0, false);
    paraStyle = (para != null ? para.getStyleName() : null);
    template.setTableEvenColumnsStyle(cell.getStyleName(), paraStyle);
    oldCellEle = cell.getOdfElement();
    newCellEle = (TableTableCellElementBase) oldCellEle.cloneNode(true);
    copyForeignStyleRef(newCellEle, cell.getOwnerDocument());

    return template;
  }
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.