Examples of OdfTextParagraph


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

      // find the last paragraph
      NodeList lst = contentDom.getElementsByTagNameNS(
          OdfTextParagraph.ELEMENT_NAME.getUri(),
          OdfTextParagraph.ELEMENT_NAME.getLocalName());
      Assert.assertTrue(lst.getLength() > 0);
      OdfTextParagraph p0 = (OdfTextParagraph) lst.item(lst.getLength() - 1);

      TextListItemElement listItem = contentDom.newOdfElement(TextListItemElement.class);
      //create children elements
      TextHElement heading = listItem.newTextHElement(1);
      TextListElement list = listItem.newTextListElement();
      TextPElement paragraph = listItem.newTextPElement();
      TextSoftPageBreakElement softPageBreak = listItem.newTextSoftPageBreakElement();

      p0.getParentNode().insertBefore(listItem, p0);
      XPath xpath = contentDom.getXPath();
      TextListItemElement listItemTest = (TextListItemElement) xpath.evaluate("//text:list-item[last()]", contentDom, XPathConstants.NODE);
      Assert.assertNotNull(listItemTest.getChildNodes());

      Assert.assertTrue(listItemTest.getChildNodes().item(0) instanceof OdfTextHeading);
View Full Code Here

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

      // find the last paragraph
      NodeList lst = contentDom.getElementsByTagNameNS(
          OdfTextParagraph.ELEMENT_NAME.getUri(),
          OdfTextParagraph.ELEMENT_NAME.getLocalName());
      Assert.assertTrue(lst.getLength() > 0);
      OdfTextParagraph p0 = (OdfTextParagraph) lst.item(lst.getLength() - 1);

      TextListItemElement listItem = contentDom.newOdfElement(TextListItemElement.class);
      //create children elements
      TextHElement heading = listItem.newTextHElement(1);
      TextListElement list = listItem.newTextListElement();
      TextPElement paragraph = listItem.newTextPElement();
      TextSoftPageBreakElement softPageBreak = listItem.newTextSoftPageBreakElement();

      p0.getParentNode().insertBefore(listItem, p0);
      XPath xpath = contentDom.getXPath();
      TextListItemElement listItemTest = (TextListItemElement) xpath.evaluate("//text:list-item[last()]", contentDom, XPathConstants.NODE);
      Assert.assertNotNull(listItemTest.getChildNodes());

      Assert.assertTrue(listItemTest.getChildNodes().item(0) instanceof OdfTextHeading);
View Full Code Here

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

            // Postive test for XPath on ODF attributes
            String resTest1 = xpath.evaluate("//text:p[@text:style-name='Standard']", contentDom);
            Assert.assertTrue(resTest1 != null);

            // Test XPath on none ODF attributes (added explicitly via DOM)
            OdfTextParagraph p = doc.newParagraph();
            p.setAttributeNS("http://myAttributeNamespace", "my:attr", "attrValue");
            String resAttr1 = xpath.evaluate("//*[@my:attr = 'attrValue']", contentDom);
            Assert.assertTrue(resAttr1 != null);

            // Test XPath on none ODF element (added explicitly via DOM)
            p.appendChild(contentDom.createElementNS("http://myElementNamespace", "my:element"));
            String resElement1 = xpath.evaluate("//my:element", contentDom);
            Assert.assertTrue(resElement1 != null);

            // Save documnet
            File targetFile = ResourceUtilities.newTestOutputFile(TARGET);
            doc.save(targetFile);


           
            // Load document with ODF foreign attriute
            OdfTextDocument docReloaded = (OdfTextDocument) OdfDocument.loadDocument(ResourceUtilities.getAbsolutePath(TARGET));
            OdfFileDom contentDomReloaded = docReloaded.getContentDom();

            // Postive test for XPath on ODF attributes
            xpath = contentDomReloaded.getXPath();
            String resTest2 = xpath.evaluate("//text:p[@text:style-name='Standard']", contentDomReloaded);
            Assert.assertTrue(resTest2 != null);
           
            // Test XPath on none ODF attributes (added via load)
            String resAttr2 = xpath.evaluate("//*[@my:attr = 'attrValue']", contentDomReloaded);
            Assert.assertTrue(resAttr2 != null);

            // Test XPath on none ODF element (added via load)
            p.appendChild(contentDom.createElementNS("http://myElementNamespace", "my:element"));
            String resElement2 = xpath.evaluate("//my:element", contentDomReloaded);
            Assert.assertTrue(resElement2 != null);

        } catch (Exception ex) {
          Logger.getLogger(NamespaceTest.class.getName()).log(Level.SEVERE, ex.getMessage(), ex);
View Full Code Here

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

    LOG.info("append");
    Element element = null;
    OdfWhitespaceProcessor instance = new OdfWhitespaceProcessor();
    int i;
    for (i = 0; i < plainText.length; i++) {
      element = new OdfTextParagraph(dom);
      instance.append(element, plainText[i]);
      compareResults(element, plainText[i], elementResult[i]);
    }
  }
View Full Code Here

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

    OdfWhitespaceProcessor instance = new OdfWhitespaceProcessor();
    int i;
    String expResult = "";
    String result;
    for (i = 0; i < plainText.length; i++) {
      element = new OdfTextParagraph(dom);
      constructElement(element, elementResult[i]);
      result = plainText[i];
      expResult = instance.getText(element);
      Assert.assertEquals(expResult, result);
    }
View Full Code Here

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

  public void testAppendText() {
    LOG.info("appendText");
    Element element = null;
    int i;
    for (i = 0; i < plainText.length; i++) {
      element = new OdfTextParagraph(dom);
      OdfWhitespaceProcessor.appendText(element, plainText[i]);
      compareResults(element, plainText[i], elementResult[i]);
    }
  }
View Full Code Here

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

   */
  @Test
  public void testAddContent() {
    LOG.info("addContent");
    String content = "paragraph content";
    OdfTextParagraph instance = new OdfTextParagraph(dom);
    Node node;
    Assert.assertNotNull(instance);
    instance.addContent(content);
    node = instance.getFirstChild();
    Assert.assertNotNull(node);
    Assert.assertEquals(Node.TEXT_NODE, node.getNodeType());
    Assert.assertEquals(content, node.getTextContent());
  }
View Full Code Here

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

  public void testAddContentWhitespace() {
    LOG.info("text:p addContentWhitespace");
    String content = "a\tb";
    String part1 = "a";
    String part2 = "b";
    OdfTextParagraph instance = new OdfTextParagraph(dom);
    Node node;
    Assert.assertNotNull(instance);
    instance.addContentWhitespace(content);
    node = instance.getFirstChild();
    Assert.assertNotNull(node);
    Assert.assertEquals(Node.TEXT_NODE, node.getNodeType());
    Assert.assertEquals(part1, node.getTextContent());
    node = node.getNextSibling();
    Assert.assertEquals(Node.ELEMENT_NODE, node.getNodeType());
View Full Code Here

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

  @Test
  public void testAddStyledContent() {
    LOG.info("addStyleContent");
    String content = "paragraph content";
    String styleName = "testStyle";
    OdfTextParagraph instance = new OdfTextParagraph(dom);
    Node node;
    Assert.assertNotNull(instance);
    instance.addStyledContent(styleName, content);
    node = instance.getFirstChild();
    Assert.assertNotNull(node);
    Assert.assertEquals(Node.TEXT_NODE, node.getNodeType());
    Assert.assertEquals(node.getTextContent(), content);
    Assert.assertEquals(instance.getStyleName(), styleName);
  }
View Full Code Here

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

    LOG.info("text:p addStyledContentWhitespace");
    String content = "a\nb";
    String part1 = "a";
    String part2 = "b";
    String styleName = "testStyle";
    OdfTextParagraph instance = new OdfTextParagraph(dom);
    Node node;
    Assert.assertNotNull(instance);
    instance.addStyledContentWhitespace(styleName, content);
    Assert.assertEquals(styleName, instance.getStyleName());
    node = instance.getFirstChild();
    Assert.assertNotNull(node);
    Assert.assertEquals(Node.TEXT_NODE, node.getNodeType());
    Assert.assertEquals(part1, node.getTextContent());
    node = node.getNextSibling();
    Assert.assertEquals(Node.ELEMENT_NODE, node.getNodeType());
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.