Examples of XWPFParagraph


Examples of org.apache.poi.xwpf.usermodel.XWPFParagraph

  private void extractContent(StringBuilder buffy, XWPFDocument document)
  throws IOException, XmlException {
    // first all paragraphs
    Iterator<XWPFParagraph> i = document.getParagraphsIterator();
    while (i.hasNext()) {
      XWPFParagraph paragraph = i.next();
      CTSectPr ctSectPr = null;
      if (paragraph.getCTP().getPPr() != null) {
        ctSectPr = paragraph.getCTP().getPPr().getSectPr();
      }

      XWPFHeaderFooterPolicy headerFooterPolicy = null;
      if (ctSectPr != null) {
        headerFooterPolicy = new XWPFHeaderFooterPolicy(document, ctSectPr);
        extractHeaders(buffy, headerFooterPolicy);
      }

      XWPFParagraphDecorator decorator = new XWPFCommentsDecorator(new XWPFHyperlinkDecorator(paragraph, null, true));

      CTBookmark[] bookmarks = paragraph.getCTP().getBookmarkStartArray();
      for (CTBookmark bookmark : bookmarks) {
        buffy.append(bookmark.getName()).append(' ');
      }

      buffy.append(decorator.getText()).append(' ');
View Full Code Here

Examples of org.apache.poi.xwpf.usermodel.XWPFParagraph

 
  public void testAddParagraph(){
     XWPFDocument doc = XWPFTestDataSamples.openSampleDocument("sample.docx");
     assertEquals(3, doc.getParagraphs().size());

     XWPFParagraph p = doc.createParagraph();
     assertEquals(p, doc.getParagraphs().get(3));
     assertEquals(4, doc.getParagraphs().size());
    
     assertEquals(3, doc.getParagraphPos(3));
      assertEquals(3, doc.getPosOfParagraph(p));

     CTP ctp = p.getCTP();
     XWPFParagraph newP = doc.getParagraph(ctp);
     assertSame(p, newP);
     XmlCursor cursor = doc.getDocument().getBody().getPArray(0).newCursor();
     XWPFParagraph cP = doc.insertNewParagraph(cursor);
     assertSame(cP, doc.getParagraphs().get(0));
     assertEquals(5, doc.getParagraphs().size());
  }
View Full Code Here

Examples of org.apache.poi.xwpf.usermodel.XWPFParagraph

  public void testRemoveBodyElement() {
     XWPFDocument doc = XWPFTestDataSamples.openSampleDocument("sample.docx");
     assertEquals(3, doc.getParagraphs().size());
      assertEquals(3, doc.getBodyElements().size());
     
      XWPFParagraph p1 = doc.getParagraphs().get(0);
      XWPFParagraph p2 = doc.getParagraphs().get(1);
      XWPFParagraph p3 = doc.getParagraphs().get(2);
     
      assertEquals(p1, doc.getBodyElements().get(0));
      assertEquals(p1, doc.getParagraphs().get(0));
      assertEquals(p2, doc.getBodyElements().get(1));
      assertEquals(p2, doc.getParagraphs().get(1));
      assertEquals(p3, doc.getBodyElements().get(2));
      assertEquals(p3, doc.getParagraphs().get(2));
     
      // Add another
      XWPFParagraph p4 = doc.createParagraph();
     
      assertEquals(4, doc.getParagraphs().size());
      assertEquals(4, doc.getBodyElements().size());
      assertEquals(p1, doc.getBodyElements().get(0));
      assertEquals(p1, doc.getParagraphs().get(0));
View Full Code Here

Examples of org.apache.poi.xwpf.usermodel.XWPFParagraph

    CTTextPath shapeTextPath = shape.addNewTextpath();
    shapeTextPath.setStyle("font-family:&quot;Cambria&quot;;font-size:1pt");
    shapeTextPath.setString(text);
    pict.set(group);
    // end watermark paragraph
    return new XWPFParagraph(p, doc);
  }
View Full Code Here

Examples of org.apache.poi.xwpf.usermodel.XWPFParagraph

    private void extractIBodyText(IBody bodyElement, XHTMLContentHandler xhtml)
            throws SAXException, XmlException, IOException {
       for(IBodyElement element : bodyElement.getBodyElements()) {
          if(element instanceof XWPFParagraph) {
             XWPFParagraph paragraph = (XWPFParagraph)element;
             extractParagraph(paragraph, xhtml);
          }
          if(element instanceof XWPFTable) {
             XWPFTable table = (XWPFTable)element;
             extractTable(table, xhtml);
View Full Code Here

Examples of org.apache.poi.xwpf.usermodel.XWPFParagraph

          xhtml.characters(footnameText + "\n");
       }

       // Also extract any paragraphs embedded in text boxes:
       for (XmlObject embeddedParagraph : paragraph.getCTP().selectPath("declare namespace w='http://schemas.openxmlformats.org/wordprocessingml/2006/main' declare namespace wps='http://schemas.microsoft.com/office/word/2010/wordprocessingShape' .//*/wps:txbx/w:txbxContent/w:p")) {
           extractParagraph(new XWPFParagraph(CTP.Factory.parse(embeddedParagraph.xmlText()), paragraph.getBody()), xhtml);
       }

       // Finish this paragraph
       xhtml.endElement(tag);

View Full Code Here

Examples of org.apache.poi.xwpf.usermodel.XWPFParagraph

    }

    public void testIntegration() throws Exception {
        XWPFDocument doc = new XWPFDocument();

        XWPFParagraph p1 = doc.createParagraph();

        XWPFRun r1 = p1.createRun();
        r1.setText("Lorem ipsum dolor sit amet.");
        doc.enforceCommentsProtection();

        File tempFile = File.createTempFile("documentProtectionFile", ".docx");
        FileOutputStream out = new FileOutputStream(tempFile);
View Full Code Here

Examples of org.apache.poi.xwpf.usermodel.XWPFParagraph

    CTTextPath shapeTextPath = shape.addNewTextpath();
    shapeTextPath.setStyle("font-family:&quot;Cambria&quot;;font-size:1pt");
    shapeTextPath.setString(text);
    pict.set(group);
    // end watermark paragraph
    return new XWPFParagraph(p);
  }
View Full Code Here

Examples of org.apache.poi.xwpf.usermodel.XWPFParagraph

        extractHeaders(xhtml, hfPolicy);

        // first all paragraphs
        Iterator<XWPFParagraph> i = document.getParagraphsIterator();
        while (i.hasNext()) {
            XWPFParagraph paragraph = i.next();

            CTSectPr ctSectPr = null;
            if (paragraph.getCTP().getPPr() != null) {
                ctSectPr = paragraph.getCTP().getPPr().getSectPr();
            }

            XWPFHeaderFooterPolicy headerFooterPolicy = null;

            if (ctSectPr != null) {
                headerFooterPolicy =
                    new XWPFHeaderFooterPolicy(document, ctSectPr);
                extractHeaders(xhtml, headerFooterPolicy);
            }

            XWPFParagraphDecorator decorator = new XWPFCommentsDecorator(
                    new XWPFHyperlinkDecorator(paragraph, null, true));

            CTBookmark[] bookmarks = paragraph.getCTP().getBookmarkStartArray();
            for (CTBookmark bookmark : bookmarks) {
                xhtml.element("p", bookmark.getName());
            }

            xhtml.element("p", decorator.getText());
View Full Code Here

Examples of org.apache.poi.xwpf.usermodel.XWPFParagraph

                CTTc[] cells = row.getTcArray();
                for (CTTc tc : cells) {
                    xhtml.startElement("td");
                    CTP[] content = tc.getPArray();
                    for (CTP ctp : content) {
                        XWPFParagraph p = new MyXWPFParagraph(ctp, doc);

                        XWPFParagraphDecorator decorator = new XWPFCommentsDecorator(
                                new XWPFHyperlinkDecorator(p, null, true));

                        xhtml.element("p", decorator.getText());
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.