Examples of XWPFParagraph


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

        {
            for(CTTc cell : row.getTcArray())
            {
                for(CTP ctp : cell.getPArray())
                {
                    XWPFParagraph p = new XWPFParagraph(ctp);
                    this.text.append(p.getText()+"\t");
                }
            }
            this.text.append("\n");
        }
    }
View Full Code Here

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

    wordDoc =
      DocumentDocument.Factory.parse(getCorePart().getInputStream());
   
    // filling paragraph list
    for (CTP p : getDocumentBody().getPArray())  {
      paragraphs.add(new XWPFParagraph(p, this));
    }

    // Get the hyperlinks
    // TODO: make me optional/separated in private function
    try  {
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 = TempFile.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:"Cambria";font-size:1pt");
    shapeTextPath.setString(text);
    pict.set(group);
    // end watermark paragraph
    return new XWPFParagraph(p, null);
  }
View Full Code Here

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

    CTTextPath shapeTextPath = shape.addNewTextpath();
    shapeTextPath.setStyle("font-family:"Cambria";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

    }

    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 = TempFile.createTempFile("documentProtectionFile", ".docx");
        FileOutputStream out = new FileOutputStream(tempFile);
View Full Code Here

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

    extractHeaders(text, hfPolicy);
   
    // First up, all our paragraph based text
    Iterator<XWPFParagraph> i = document.getParagraphsIterator();
    while(i.hasNext()) {
      XWPFParagraph paragraph = i.next();

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

        XWPFHeaderFooterPolicy headerFooterPolicy = null;

        if (ctSectPr!=null) {
View Full Code Here

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

    extractHeaders(text, hfPolicy);
   
    // First up, all our paragraph based text
    Iterator<XWPFParagraph> i = document.getParagraphsIterator();
    while(i.hasNext()) {
      XWPFParagraph paragraph = i.next();

      try {
        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(text, headerFooterPolicy);
        }

        // Do the paragraph text
        for(XWPFRun run : paragraph.getRuns()) {
           text.append(run.toString());
           if(run instanceof XWPFHyperlinkRun && fetchHyperlinks) {
              XWPFHyperlink link = ((XWPFHyperlinkRun)run).getHyperlink(document);
              if(link != null)
                 text.append(" <" + link.getURL() + ">");
           }
        }

        // Add comments
        XWPFCommentsDecorator decorator = new XWPFCommentsDecorator(paragraph, null);
        text.append(decorator.getCommentText()).append('\n');
       
        // Do endnotes and footnotes
        String footnameText = paragraph.getFootnoteText();
         if(footnameText != null && footnameText.length() > 0) {
            text.append(footnameText + "\n");
         }

        if (ctSectPr!=null) {
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

        comments = XWPFTestDataSamples.openSampleDocument("WordWithAttachments.docx");
   }

    @SuppressWarnings("deprecation")
   public void testHyperlink() {
      XWPFParagraph ps;
      XWPFParagraph ph;
      assertEquals(7, simple.getParagraphs().size());
      assertEquals(5, hyperlink.getParagraphs().size());

      // Simple text
      ps = simple.getParagraphs().get(0);
      assertEquals("I am a test document", ps.getParagraphText());
      assertEquals(1, ps.getRuns().size());

      ph = hyperlink.getParagraphs().get(4);
      assertEquals("We have a hyperlink here, and another.", ph.getParagraphText());
      assertEquals(3, ph.getRuns().size());


      // The proper way to do hyperlinks(!)
      assertFalse(ps.getRuns().get(0) instanceof XWPFHyperlinkRun);
      assertFalse(ph.getRuns().get(0) instanceof XWPFHyperlinkRun);
      assertTrue(ph.getRuns().get(1) instanceof XWPFHyperlinkRun);
      assertFalse(ph.getRuns().get(2) instanceof XWPFHyperlinkRun);

      XWPFHyperlinkRun link = (XWPFHyperlinkRun)ph.getRuns().get(1);
      assertEquals("http://poi.apache.org/", link.getHyperlink(hyperlink).getURL());


      // Test the old style decorator
      // You probably don't want to still be using it...
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.