Package org.odftoolkit.odfdom.incubator.doc.text

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


   */
  @Test
  public void testAddContent() {
    LOG.info("addContent");
    String content = "heading content";
    OdfTextHeading instance = new OdfTextHeading(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


   */
  @Test
  public void testAddContent() {
    LOG.info("addContent");
    String content = "heading content";
    OdfTextHeading instance = new OdfTextHeading(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

  public void testAddContentWhitespace() {
    LOG.info("text:h addContentWhitespace");
    String content = "a\tb";
    String part1 = "a";
    String part2 = "b";
    OdfTextHeading instance = new OdfTextHeading(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

  @Test
  public void testAddStyledContent() {
    LOG.info("addStyleContent");
    String content = "heading content";
    String styleName = "testStyle";
    OdfTextHeading instance = new OdfTextHeading(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

    LOG.info("text:h addStyledContentWhitespace");
    String content = "a\nb";
    String part1 = "a";
    String part2 = "b";
    String styleName = "testStyle";
    OdfTextHeading instance = new OdfTextHeading(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

    LOG.info("addStyleSpan");
    String content = "heading content";
    String spanContent = "span content";
    String styleName = "testStyle";
    String spanStyleName = "spanStyle";
    OdfTextHeading instance = new OdfTextHeading(dom);
    OdfTextSpan subElement;
    Node node;
    Assert.assertNotNull(instance);
    instance.addStyledContent(styleName, content).addStyledSpan(
        spanStyleName, spanContent);

    // first item should be text
    node = instance.getFirstChild();
    Assert.assertNotNull(node);
    Assert.assertEquals(Node.TEXT_NODE, node.getNodeType());
    Assert.assertEquals(node.getTextContent(), content);
    Assert.assertEquals(instance.getStyleName(), styleName);

    // followed by a span
    node = node.getNextSibling();
    Assert.assertNotNull(node);
    Assert.assertEquals(Node.ELEMENT_NODE, node.getNodeType());
View Full Code Here

    String spanContent = "span    content"// four blanks
    String part1 = "span ";
    String part2 = "content";
    String styleName = "testStyle";
    String spanStyleName = "spanStyle";
    OdfTextHeading instance = new OdfTextHeading(dom);
    OdfTextSpan subElement;
    Element element;
    Node node;
    Assert.assertNotNull(instance);
    instance.addStyledContent(styleName, content).addStyledSpanWhitespace(
        spanStyleName, spanContent);

    // first item should be text
    node = instance.getFirstChild();
    Assert.assertNotNull(node);
    Assert.assertEquals(Node.TEXT_NODE, node.getNodeType());
    Assert.assertEquals(content, node.getTextContent());
    Assert.assertEquals(styleName, instance.getStyleName());

    // followed by a span
    node = node.getNextSibling();
    Assert.assertNotNull(node);
    Assert.assertEquals(Node.ELEMENT_NODE, node.getNodeType());
View Full Code Here

            newElement = getCurrentResource().getDocument().createElement("td");
            dstElement.add(newElement);
            newElement.setClassName(otl.getStyleName());
        } else if (e instanceof OdfTextHeading) {// text:p
            // System.out.println(e.getTextContent());
            OdfTextHeading oth = (OdfTextHeading) e;
            if (hasPageBreak(oth)) {
                createNewResource();
            }
            newElement = getCurrentResource().getDocument().createElement("h" + oth.getAttribute("text:outline-level"));
            if (dstElement != null) {
                dstElement.add(newElement);
            } else {
                getCurrentResource().getDocument().getBody().add(newElement);
            }
            newElement.setClassName(oth.getStyleName());
            if (oth.getTextContent() != null && oth.getTextContent().trim().length() > 0) {
                addTocEntry(oth.getTextContent(), Integer.parseInt(oth.getAttribute("text:outline-level")), newElement);
            }

            if (oth.getAutomaticStyle() != null) {// probabile che sia stato
                // oth.getAutomaticStyles() // modificato lo stile
                List<OdfStyleBase> classeCSS = new ArrayList<OdfStyleBase>();
                OdfStyleBase p = oth.getAutomaticStyle().getParentStyle();
                while (p != null) {
                    classeCSS.add(p);
                    p = p.getParentStyle();

                }
                Collections.reverse(classeCSS);
                for (OdfStyleBase odfStyleBase : classeCSS) {
                    stylesPropsToCSS(odfStyleBase.getStyleProperties(), newElement.getClassName());
                }
                stylesPropsToCSS(oth.getAutomaticStyle().getStyleProperties(), oth.getStyleName());
                if (newElement != null) {
                    newElement.setClassName(oth.getStyleName());
                }
                if (isDebugMode()) {
                    Utils.printStyleProps(oth.getAutomaticStyle().getStyleProperties());
                }
            }

            getOdt().getDocumentStyles().getElementsByTagName(oth.getTextStyleNameAttribute());

        } else if (e instanceof OdfTextParagraph) {// text:p
            // System.out.println(e.getTextContent());

            OdfTextParagraph otp = (OdfTextParagraph) e;
View Full Code Here

TOP

Related Classes of org.odftoolkit.odfdom.incubator.doc.text.OdfTextHeading

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.