Examples of TextDocument


Examples of org.odftoolkit.simple.TextDocument

 
 
  @Test
  public void testGetTableList() {
    try {
      TextDocument doc = TextDocument.newTextDocument();
      Header header = doc.getHeader();
      Table tab = header.addTable();
     
      //validate
      List<Table> listTab = header.getTableList();
      Table tab1 = listTab.get(0);
      Assert.assertNotNull(tab1);
      Assert.assertEquals(tab, tab1);

      //save
      doc.save(ResourceUtilities.newTestOutputFile("headerTableOutput.odt"));
    } catch (Exception e) {
      Logger.getLogger(HeaderTest.class.getName()).log(Level.SEVERE, null, e);
      Assert.fail(e.getMessage());
    }
  }
View Full Code Here

Examples of org.odftoolkit.simple.TextDocument

 
 
  @Test
  public void testGetTableBuilder() {
    try {
      TextDocument doc = TextDocument.newTextDocument();
      Header header = doc.getHeader();
     
      TableBuilder tabBuilder = header.getTableBuilder();
      Table tab = tabBuilder.newTable();
      Assert.assertNotNull(tab);
      Assert.assertTrue(2 == tab.getRowCount());
      Assert.assertTrue(5 == tab.getColumnCount());
     
      //validate
      List<Table> listTab = header.getTableList();
      Table tab1 = listTab.get(0);
      Assert.assertNotNull(tab1);
      Assert.assertEquals(tab, tab1);

      //save
      doc.save(ResourceUtilities.newTestOutputFile("headerTableOutput.odt"));
    } catch (Exception e) {
      Logger.getLogger(HeaderTest.class.getName()).log(Level.SEVERE, null, e);
      Assert.fail(e.getMessage());
    }
  }
View Full Code Here

Examples of org.odftoolkit.simple.TextDocument

 
 
  @Test
  public void testGetVariableContainerElement() {
    try {
      TextDocument doc = TextDocument.newTextDocument();
      Header header = doc.getHeader();
     
      OdfElement odfEle = header.getVariableContainerElement();
     
      TableBuilder tb = header.getTableBuilder();
      Table tab = tb.newTable();
     
      Assert.assertNotNull(tab);
      Assert.assertTrue(2 == tab.getRowCount());
      Assert.assertTrue(5 == tab.getColumnCount());
     
      Node nod = odfEle.getFirstChild();
      Assert.assertEquals("table:table", nod.getNodeName());

      //save
      doc.save(ResourceUtilities.newTestOutputFile("headerTableOutput.odt"));
    } catch (Exception e) {
      Logger.getLogger(HeaderTest.class.getName()).log(Level.SEVERE, null, e);
      Assert.fail(e.getMessage());
    }
  }
View Full Code Here

Examples of org.odftoolkit.simple.TextDocument

 
 
  @Test
  public void testDeclareVariable() {
    try {
      TextDocument doc = TextDocument.newTextDocument();
      Header header = doc.getHeader();
     
      header.declareVariable("headername", VariableType.USER);
     
      //validate
      StyleHeaderElement styleHeader = header.getOdfElement();
      Node nod = styleHeader.getFirstChild().getFirstChild();
      NamedNodeMap nameMap = nod.getAttributes();
      Node nodtext = nameMap.getNamedItem("text:name");
      Assert.assertEquals("headername", nodtext.getNodeValue());

      //save
      doc.save(ResourceUtilities.newTestOutputFile("headerTableOutput.odt"));
    } catch (Exception e) {
      Logger.getLogger(HeaderTest.class.getName()).log(Level.SEVERE, null, e);
      Assert.fail(e.getMessage());
    }
  }
View Full Code Here

Examples of org.odftoolkit.simple.TextDocument

 
 
  @Test
  public void testGetVariableFieldByName() {
    try {
      TextDocument doc = TextDocument.newTextDocument();
      Header header = doc.getHeader();
     
      header.declareVariable("headername", VariableType.USER);
      VariableField vField = header.getVariableFieldByName("headername");
      String vName = vField.getVariableName();
     
      //validate
      StyleHeaderElement styleHead = header.getOdfElement();
      Node nod = styleHead.getFirstChild().getFirstChild();
      NamedNodeMap nameMap = nod.getAttributes();
      Node nodtext = nameMap.getNamedItem("text:name");
      Assert.assertEquals(vName, nodtext.getNodeValue());

      //save
      doc.save(ResourceUtilities.newTestOutputFile("headerTableOutput.odt"));
    } catch (Exception e) {
      Logger.getLogger(HeaderTest.class.getName()).log(Level.SEVERE, null, e);
      Assert.fail(e.getMessage());
    }
  }
View Full Code Here

Examples of org.odftoolkit.simple.TextDocument

  String footerDocumentPath = "FooterTableDocument.odt";

  @Test
  public void testAddTable() {
    try {
      TextDocument doc = TextDocument.newTextDocument();
      Footer footer = doc.getFooter();
      Assert.assertNotNull(footer);

      Table table = footer.addTable(1, 1);
      table.setTableName("footerTable");
      int rowCount = table.getRowCount();
      int columnCount = table.getColumnCount();
      String expectedCellValue = "footer table cell";
      Cell cellByPosition = table.getCellByPosition(0, 0);
      cellByPosition.setStringValue(expectedCellValue);
      cellByPosition.setHorizontalAlignment(HorizontalAlignmentType.CENTER);
      cellByPosition.setCellBackgroundColor(Color.GREEN);
     
      //first page
      footer = doc.getFooter(true);
      Assert.assertNotNull(footer);
      table = footer.addTable(1, 2);
      table.setTableName("footerFTable");
      doc.save(ResourceUtilities.newTestOutputFile(footerDocumentPath));

      // load the document again.
      doc = TextDocument.loadDocument(ResourceUtilities.getTestResourceAsStream(footerDocumentPath));
      footer = doc.getFooter();
      table = footer.getTableByName("footerTable");
      Assert.assertEquals(rowCount, table.getRowCount());
      Assert.assertEquals(columnCount, table.getColumnCount());
      Assert.assertEquals(expectedCellValue, cellByPosition.getStringValue());

      footer = doc.getFooter(true);
      table = footer.getTableByName("footerFTable");
      Assert.assertNotNull(table);
    } catch (Exception e) {
      Logger.getLogger(FooterTest.class.getName()).log(Level.SEVERE, null, e);
      Assert.fail(e.getMessage());
View Full Code Here

Examples of org.odftoolkit.simple.TextDocument

  }
 
  @Test
  public void testFooterHidden() {
    try {
      TextDocument doc = TextDocument.loadDocument(ResourceUtilities.getTestResourceAsStream("headerFooterHidden.odt"));
      Footer footer = doc.getFooter();
      Assert.assertEquals(true, footer.isVisible());
      footer.setVisible(false);
      Assert.assertEquals(false, footer.isVisible());
      doc.save(ResourceUtilities.newTestOutputFile("footerHiddenOutput.odt"));
    } catch (Exception e) {
      Logger.getLogger(FooterTest.class.getName()).log(Level.SEVERE, null, e);
      Assert.fail(e.getMessage());
    }
  }
View Full Code Here

Examples of org.odftoolkit.simple.TextDocument

 
  @Test
  public void testGetOdfElement() {
    try {
      //TextDocument doc = TextDocument.loadDocument(ResourceUtilities.getTestResourceAsStream("headerFooterHidden.odt"));
      TextDocument doc = TextDocument.newTextDocument();
      Footer footer = doc.getFooter();
      StyleFooterElement footerEle = footer.getOdfElement();
      footerEle.setTextContent("hello world");
      Assert.assertEquals("hello world", footerEle.getTextContent());

      //save
View Full Code Here

Examples of org.odftoolkit.simple.TextDocument

 
  @Test
  public void testAddtable() {
    try {
      //TextDocument doc = TextDocument.loadDocument(ResourceUtilities.getTestResourceAsStream("headerFooterHidden.odt"));
      TextDocument doc = TextDocument.newTextDocument();
      Footer footer = doc.getFooter();
      Table tab = footer.addTable();
      Assert.assertNotNull(tab);
      Assert.assertTrue(2 == tab.getRowCount());
      Assert.assertTrue(5 == tab.getColumnCount());
     
View Full Code Here

Examples of org.odftoolkit.simple.TextDocument

 
  @Test
  public void testGetTableList() {
    try {
      //TextDocument doc = TextDocument.loadDocument(ResourceUtilities.getTestResourceAsStream("headerFooterHidden.odt"));
      TextDocument doc = TextDocument.newTextDocument();
      Footer footer = doc.getFooter();
      Table tab = footer.addTable();
     
      List<Table> tabList = footer.getTableList();
      Assert.assertEquals(tab, tabList.get(0));
     
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.