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

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


    LOG.info("addStyleSpan");
    String content = "heading content";
    String spanContent = "span content";
    String styleName = "testStyle";
    String spanStyleName = "spanStyle";
    OdfTextParagraph instance = new OdfTextParagraph(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";
    OdfTextParagraph instance = new OdfTextParagraph(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

      content = "";
    }
    removeContent();

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

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

      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

   * @deprecated As of Simple version 0.5, replaced by
   *             <code>addParagraph(String text)</code>
   * @see #addParagraph(String)
   */
  public OdfTextParagraph newParagraph(String text) throws Exception {
    OdfTextParagraph para = newParagraph();
    para.addContent(text);
    return para;
  }
View Full Code Here

   * @see #getParagraphByReverseIndex(int, boolean)
   */
  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

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

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

            OdfTextParagraph otp = (OdfTextParagraph) e;
            if (hasPageBreak(otp)) {
                createNewResource();
            }

            newElement = getCurrentResource().getDocument().createElement("p");

            if (dstElement != null) {
                dstElement.add(newElement);
            } else {
                getCurrentResource().getDocument().getBody().add(newElement);
            }

            newElement.setClassName(otp.getStyleName().trim());

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

                }
                Collections.reverse(classeCSS);
                for (OdfStyleBase odfStyleBase : classeCSS) {
                    stylesPropsToCSS(odfStyleBase.getStyleProperties(), newElement.getClassName());
                }

                // while(p!=null){
                // if(p.getAttribute("style:name")!=null&&p.getAttribute("style:name").trim().length()>0){
                // newElement.setClassName(p.getAttribute("style:name").trim()+" "+newElement.getClassName());
                // stylesPropsToCSS(p.getStyleProperties(),
                // p.getAttribute("style:name"));
                // }
                // p=p.getParentStyle();
                //
                // }
                // Object
                // n=getXpath().evaluate("//style:style[@style:name='Body_20_Text_20_3']",
                // getOdt().getDocumentStyles(), XPathConstants.NODE);
                // n=getXpath().evaluate("//style:style[@style:name='Standard']",
                // getOdt().getDocumentStyles(), XPathConstants.NODE);
                // getXpath().evaluate("//style:style[@style:name='P38']",
                // getOdt().getDocumentStyles(), XPathConstants.NODE)
                stylesPropsToCSS(otp.getAutomaticStyle().getStyleProperties(), otp.getStyleName());

                if (isDebugMode()) {
                    Utils.printStyleProps(otp.getAutomaticStyle().getStyleProperties());
                }
            }

        } else if (e instanceof OdfTextSpan) {// text:span
            // System.out.println(e.getTextContent());
View Full Code Here

TOP

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

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.