Examples of OdfTextParagraph


Examples of org.odftoolkit.odfdom.incubator.doc.text.OdfTextParagraph

  public void testReplaceWithHiddenTextField() {
    try {
      search = new TextNavigation("ReplaceHiddenTextTarget", doc);
      // declare simple variable
      VariableField simpleVariableField = Fields.createSimpleVariableField(doc, "test_con_variable");
      OdfTextParagraph varParagraph = doc.newParagraph("test_con_variable:");
      simpleVariableField.updateField("true", varParagraph);

      // count the initial date field count. should be 1.
      OdfContentDom contentDom = doc.getContentDom();
      NodeList nodeList = contentDom.getElementsByTagName(TextConditionalTextElement.ELEMENT_NAME.getQName());
View Full Code Here

Examples of org.odftoolkit.odfdom.incubator.doc.text.OdfTextParagraph

      content = "";
    }
    removeContent();

    OdfWhitespaceProcessor textProcessor = new OdfWhitespaceProcessor();
    OdfTextParagraph para = new OdfTextParagraph((OdfFileDom) mCellElement.getOwnerDocument());
    textProcessor.append(para, content);

    mCellElement.appendChild(para);
  }
View Full Code Here

Examples of org.odftoolkit.odfdom.incubator.doc.text.OdfTextParagraph

      content = "";
    }
    removeContent();

    OdfWhitespaceProcessor textProcessor = new OdfWhitespaceProcessor();
    OdfTextParagraph para = new OdfTextParagraph((OdfFileDom) mCellElement.getOwnerDocument());
    if ((stylename != null) && (stylename.length() > 0)) {
      para.setStyleName(stylename);
    }
    textProcessor.append(para, content);

    mCellElement.appendChild(para);
  }
View Full Code Here

Examples of org.odftoolkit.odfdom.incubator.doc.text.OdfTextParagraph

   * @param text
   * @return the new paragraph
   * @throws Exception if the file DOM could not be created.
   */
  public OdfTextParagraph newParagraph(String text) throws Exception {
    OdfTextParagraph para = newParagraph();
    para.addContent(text);
    return para;
  }
View Full Code Here

Examples of org.odftoolkit.odfdom.incubator.doc.text.OdfTextParagraph

   * @throws Exception if the file DOM could not be created.
   */
  public OdfTextParagraph addText(String text) throws Exception {
    OfficeTextElement odfText = getContentRoot();
    Node n = odfText.getLastChild();
    OdfTextParagraph para;
    if (OdfTextParagraph.class.isInstance(n)) {
      para = (OdfTextParagraph) n;
    } else {
      para = newParagraph();
    }
    para.addContent(text);
    return para;
  }
View Full Code Here

Examples of org.odftoolkit.odfdom.incubator.doc.text.OdfTextParagraph

      for (Sample s : samples) {
        OdfTableRow row = oTable.appendRow();

        OdfTableCell cell0 = row.getCellByIndex(0);
        OdfTextParagraph cp0 = new OdfTextParagraph(contentDom);
        cp0.setTextContent(s.getAlias());
        cp0.setProperty(StyleTextPropertiesElement.FontSize, "8pt");
        cell0.getOdfElement().appendChild(cp0);

        OdfTableCell cell1 = row.getCellByIndex(1);
        OdfTextParagraph cp1 = new OdfTextParagraph(contentDom);
        cp1.setTextContent(s.getScientificName());
        cp1.setProperty(StyleTextPropertiesElement.FontSize, "8pt");
        cell1.getOdfElement().appendChild(cp1);

        OdfTableCell cell2 = row.getCellByIndex(2);
        OdfTextParagraph cp2 = new OdfTextParagraph(contentDom);
        cp2.setTextContent(s.getIdentificationBarcode());
        cp2.setProperty(StyleTextPropertiesElement.FontSize, "8pt");
        cell2.getOdfElement().appendChild(cp2);

        OdfTableCell cell3 = row.getCellByIndex(3);
        OdfTextParagraph cp3 = new OdfTextParagraph(contentDom);
        cp3.setTextContent(s.getSampleType());
        cp3.setProperty(StyleTextPropertiesElement.FontSize, "8pt");
        cell3.getOdfElement().appendChild(cp3);
      }

      int count = 0;
      for (OdfTableRow row : oTable.getRowList()) {
View Full Code Here

Examples of org.odftoolkit.odfdom.incubator.doc.text.OdfTextParagraph

    Object[] valueCellRange = getValueCellRange();
    for (int i = 0; i < numColumns; i++) {
      TableTableCellElement cell = headerRow.newTableTableCellElement(0.0, "string");
      cell.setOfficeValueTypeAttribute(OfficeValueTypeAttribute.Value.STRING.toString());
      String[] cellContents = dataset.getLocalTableFirstRow();
      OdfTextParagraph paragraph = (OdfTextParagraph) cell.newTextPElement();

      if (isFirstRowAsLabel && !isRowAsSeries) {
        if ((String) labelCellRange[i] != null) {
          paragraph.setTextIdAttribute((String) labelCellRange[i]);
        }
      }
      if (isFirstRowAsLabel && isRowAsSeries && i == 0) {
        if ((String) getTableCellRange() != null) {
          paragraph.setTextIdAttribute(getTableCellRange());
        }
      }
      if (cellContents[i] != null) {
        paragraph.setTextContent(cellContents[i]);
      } else {
        paragraph.setTextContent("");
      }
    }

    // create table rows
    Double[][] cellValues = dataset.getLocalTableData();
    for (int i = 0; i < numRows; i++) {
      TableTableRowElement row = rows.newTableTableRowElement();
      TableTableCellElement nameCell = row.newTableTableCellElement(0.0, "string");
      nameCell.setOfficeValueTypeAttribute(OfficeValueTypeAttribute.Value.STRING.toString());
      OdfTextParagraph paragraph = (OdfTextParagraph) nameCell.newTextPElement();
      String[] cellContents = dataset.getLocalTableFirstColumn();
      if (cellContents[i] != null) {
        if (isFirstColumnAsLabel) {
          if (isRowAsSeries) {
            paragraph.setTextIdAttribute((String) labelCellRange[i]);
          }
          if (!isRowAsSeries && i == 0) {
            paragraph.setTextIdAttribute(getTableCellRange());
          }
        }
        paragraph.setTextContent(cellContents[i]);
      } else {
        paragraph.setTextContent("");
      }
      for (int j = 0; j < numColumns; j++) {
        TableTableCellElement cell = row.newTableTableCellElement(0.0, "string");
        cell.setOfficeValueTypeAttribute(OfficeValueTypeAttribute.Value.FLOAT.toString());
        if (cellValues[i][j] != null) {
          cell.setOfficeValueAttribute(cellValues[i][j]);
          OdfTextParagraph paragraph1 = (OdfTextParagraph) cell.newTextPElement();
          paragraph1.setTextContent(cellValues[i][j].toString());
          if (isRowAsSeries && j == 0) {
            paragraph1.setTextIdAttribute((String) valueCellRange[i]);
          }
          if (!isRowAsSeries && i == 0) {
            paragraph1.setTextIdAttribute((String) valueCellRange[j]);
          }
        } else {
          cell.setOfficeValueAttribute(new Double(Double.NaN));
          OdfTextParagraph paragraph1 = (OdfTextParagraph) cell.newTextPElement();
          paragraph1.setTextContent("1.#NAN");
          if (isRowAsSeries && j == 0) {
            paragraph1.setTextIdAttribute((String) valueCellRange[i]);
          }
          if (!isRowAsSeries && i == 0) {
            paragraph1.setTextIdAttribute((String) valueCellRange[j]);
          }
        }
      }
    }
  }
View Full Code Here

Examples of org.odftoolkit.odfdom.incubator.doc.text.OdfTextParagraph

    }
    NodeList paras = chartTitle.getElementsByTagNameNS(OdfDocumentNamespace.TEXT.getUri(), "p");
    if (paras.getLength() == 0) {
      chartTitle.newTextPElement().setTextContent(title);
    } else {
      OdfTextParagraph para0 = (OdfTextParagraph) paras.item(0);
      para0.setTextContent(title);
    }
    return true;
  }
View Full Code Here

Examples of org.odftoolkit.odfdom.incubator.doc.text.OdfTextParagraph

    TableTableCellElement cell;
    OdfFileDom dom;
    NodeList tableList;
    TableTableElement myTable;
    NodeList lst;
    OdfTextParagraph p;
    OfficeSpreadsheetElement spreadsheet = null;

    try {
      dom = odfdoc.getContentDom();
      tableList = dom.getElementsByTagNameNS(
          OdfDocumentNamespace.TABLE.getUri(), "table");
      spreadsheet = (OfficeSpreadsheetElement) dom.getElementsByTagNameNS(
          OdfDocumentNamespace.OFFICE.getUri(), "spreadsheet").item(0);

      i = 0;
      if (tableList.getLength() > 0) {
        for (; i < tableList.getLength(); i++) {
          String currentname = ((TableTableElement) tableList.item(i)).getTableNameAttribute();
          if (currentname == null) {
            currentname = "";
          }
          if (currentname.equalsIgnoreCase(tablename)) {
            break;
          }
        }
      }
      if (i < tableList.getLength()) //table with the specific table name is found
      {
        myTable = (TableTableElement) tableList.item(i);
      } else { //table with the specific table name is not found. Create table
        myTable = dom.newOdfElement(TableTableElement.class);
        myTable.setTableNameAttribute(tablename);
        spreadsheet.appendChild(myTable);
      }

      lst = myTable.getElementsByTagNameNS(OdfDocumentNamespace.TABLE.getUri(), "table-row");
      if (lst.getLength() == 0) { //the first table row is not existed. Create table row
        td = dom.newOdfElement(TableTableRowElement.class);
        cell = dom.newOdfElement(TableTableCellElement.class);
        p = dom.newOdfElement(OdfTextParagraph.class);
        if (tablename.startsWith("Memory")) {
          p.setTextContent("memory(b)");
        } else {
          p.setTextContent("time(ms)");
        }
        td.appendChild(cell);
        cell.appendChild(p);
        myTable.appendChild(td);
      } else {
        td = (TableTableRowElement) lst.item(0); //the first table row is existed.
      }
      cell = dom.newOdfElement(TableTableCellElement.class);
      td.appendChild(cell);
      p = dom.newOdfElement(OdfTextParagraph.class);
      p.setTextContent(testTag);
      cell.appendChild(p);


      for (i = 1; i < values.length + 1; i++) {
        if (i < lst.getLength()) { //table row is existed
          td = (TableTableRowElement) lst.item(i);
        } else { //table row is not existed.
          td = dom.newOdfElement(TableTableRowElement.class);
          myTable.appendChild(td);
          //append first cell with labels
          cell = dom.newOdfElement(TableTableCellElement.class);
          td.appendChild(cell);
          p = dom.newOdfElement(OdfTextParagraph.class);
          p.setTextContent(labels[j]);
          cell.appendChild(p);
        }
        cell = dom.newOdfElement(TableTableCellElement.class);
        cell.setOfficeValueTypeAttribute("float");
        cell.setOfficeValueAttribute(new Double(values[j]));
        p = dom.newOdfElement(OdfTextParagraph.class);
        p.setTextContent(values[j] + "");
        cell.appendChild(p);
        td.appendChild(cell);
        j++;
      }
    } catch (Exception e) {
View Full Code Here

Examples of org.odftoolkit.odfdom.incubator.doc.text.OdfTextParagraph

  @Test
  public void testReturnChar() {
    try {
      TextDocument textDoc = TextDocument.newTextDocument();
      textDoc.newParagraph();
      OdfTextParagraph graph = textDoc.newParagraph("abc");

      TextExtractor extractor = TextExtractor.newOdfTextExtractor(textDoc.getContentRoot());
      String text = extractor.getText();
      System.out.println(text);
View Full Code Here
TOP
Copyright © 2018 www.massapi.com. 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.