Package org.odftoolkit.simple

Examples of org.odftoolkit.simple.Document


   *            an instance of <code>TableTableElement</code>
   * @return an instance of <code>Table</code> that can represent
   *         <code>element</code>
   */
  public static Table getInstance(TableTableElement element) {
    Document ownerDocument = (Document) ((OdfFileDom) (element.getOwnerDocument())).getDocument();
    return ownerDocument.getTableBuilder().getTableInstance(element);
  }
View Full Code Here


    return createTable(container, numRows, numCols, headerRowNumber, headerColumnNumber, 0, 0);
  }

  private static TableTableElement createTable(TableContainer container, int numRows, int numCols,
      int headerRowNumber, int headerColumnNumber, double marginLeft, double marginRight) throws Exception {
    Document document = getOwnerDocument(container);
    OdfElement containerElement = container.getTableContainerElement();
    OdfFileDom dom = (OdfFileDom) containerElement.getOwnerDocument();
    double tableWidth = getTableWidth(container, marginLeft, marginRight);

    boolean isTextDocument = document instanceof TextDocument;
View Full Code Here

    if (template == null)
      throw new IllegalArgumentException(
          "The template cannot null to be applied to a table.");

    Document doc = this.getOwnerDocument();
    OdfOfficeAutomaticStyles styles = doc.getContentDom()
        .getAutomaticStyles();

    // decide row style or column style
    boolean isEqualTableStyle = true;
    boolean isEqualParaStyle = true;
View Full Code Here

  @Test
  public void testGetRowCount() {
    try {
      // without table rows
      Document mOdpDoc = Document.loadDocument(ResourceUtilities
          .getTestResourceAsStream("TableCountTestcase.odp"));
      Table table = mOdpDoc.getTableByName("Table1");
      int rowCount = table.getRowCount();
      Assert.assertEquals(5, rowCount);
      // with table rows
      Document mOdcDoc = mOdpDoc.getEmbeddedDocument("Object 2/");
      table = mOdcDoc.getTableByName("local-table");
      rowCount = table.getRowCount();
      Assert.assertEquals(5, rowCount);
    } catch (Exception e) {
      Logger.getLogger(TableTest.class.getName()).log(Level.SEVERE, null, e);
      e.printStackTrace();
View Full Code Here

  private static final String TEST_FILE_NAME = "CellStyleHandlerTest.odp";

  @Test
  public void testGetFont() {
    try {
      Document doc = Document.loadDocument(ResourceUtilities.getTestResourceAsStream(TEST_FILE_NAME));
      Table table = doc.getTableByName("slideTable");
      CellStyleHandler styleHandler = table.getCellByPosition(1, 1).getStyleHandler();
      // NullPointerException should not be thrown even if no default text
      // properties style exists.
      styleHandler.getFont(Document.ScriptType.WESTERN);
    } catch (Exception e) {
View Full Code Here

 
 
  @Test
  public void testGetCountry() {
    try {
      Document doc = Document.loadDocument(ResourceUtilities.getTestResourceAsStream(TEST_FILE_NAME));
      Table table = doc.getTableByName("slideTable");
      CellStyleHandler styleHandler = table.getCellByPosition(1, 1).getStyleHandler();
     
      styleHandler.setCountry("English", Document.ScriptType.WESTERN);
      //validate
      String country = styleHandler.getCountry(Document.ScriptType.WESTERN);
View Full Code Here

      chart.setUseLegend(false);
      Assert.assertEquals(chart.getChartTitle(), "Chart with local-data");
      Assert.assertFalse(chart.isUseLegend() == true);
      doc.save(ResourceUtilities.newTestOutputFile(CHART_FILE1));

      Document doc1 = Document.loadDocument(ResourceUtilities.getTestResourceAsStream(CHART_FILE1));
      Assert.assertEquals(doc1.getMediaTypeString(), Document.OdfMediaType.SPREADSHEET.getMediaTypeString());
      doc = (SpreadsheetDocument) doc1;

      Assert.assertNotNull(doc.getChartByTitle("Chart with local-data"));
      Assert.assertNotNull(doc.getChartByTitle("LocalData"));
View Full Code Here

  @Test
  public void testGetRowCount() {
    try {
      // without table rows
      Document mOdpDoc = Document.loadDocument(ResourceUtilities
          .getTestResourceAsStream("TableCountTestcase.odp"));
      Table table = mOdpDoc.getTableByName("Table1");
      int rowCount = table.getRowCount();
      Assert.assertEquals(5, rowCount);
      // with table rows
      Document mOdcDoc = mOdpDoc.getEmbeddedDocument("Object 2/");
      table = mOdcDoc.getTableByName("local-table");
      rowCount = table.getRowCount();
      Assert.assertEquals(5, rowCount);
    } catch (Exception e) {
      Logger.getLogger(TableTest.class.getName()).log(Level.SEVERE, null, e);
      e.printStackTrace();
View Full Code Here

      Assert.assertNull(fileEntry);
      Slide newPage1 = doc2.copyForeignSlide(2, doc, 2);
      Assert.assertTrue(2 == newPage1.getSlideIndex());
      // slide at index 2 of doc contains an embedded document called
      // "Object 3"
      Document embedDoc = doc2.getEmbeddedDocument(embedDocName);
      Assert.assertNotNull(embedDoc);
      int size = doc2.getEmbeddedDocuments().size();
      Assert.assertTrue(size == (nEmbedDoc + 1));
      // the copied slide also have an bitmap background, and the image
      // bullet
View Full Code Here

   * Remove this item from its owner list.
   */
  public void remove() {
    Node parentElement = listItemElement.getParentNode();
    OdfFileDom ownerDocument = (OdfFileDom) listItemElement.getOwnerDocument();
    Document doc = (Document) ownerDocument.getDocument();
    doc.removeElementLinkedResource(listItemElement);
    parentElement.removeChild(listItemElement);
  }
View Full Code Here

TOP

Related Classes of org.odftoolkit.simple.Document

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.