Package org.apache.poi.xwpf.model

Examples of org.apache.poi.xwpf.model.XWPFHeaderFooterPolicy


            }
            cursor.dispose();

            // Sort out headers and footers
            if (doc.getDocument().getBody().getSectPr() != null)
                headerFooterPolicy = new XWPFHeaderFooterPolicy(this);

            // Create for each XML-part in the Package a PartClass
            for (POIXMLDocumentPart p : getRelations()) {
                String relation = p.getPackageRelationship().getRelationshipType();
                if (relation.equals(XWPFRelation.STYLES.getRelation())) {
View Full Code Here


    extractor.close();
  }
 
    public String getText() {
        StringBuffer text = new StringBuffer();
        XWPFHeaderFooterPolicy hfPolicy = document.getHeaderFooterPolicy();

        // Start out with all headers
        extractHeaders(text, hfPolicy);

        // Process all body elements
View Full Code Here

          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);
          }


          for(IRunElement run : paragraph.getRuns()) {
View Full Code Here

     * @see org.apache.poi.xwpf.extractor.XWPFWordExtractor#getText()
     */
    @Override
    protected void buildXHTML(XHTMLContentHandler xhtml)
            throws SAXException, XmlException, IOException {
        XWPFHeaderFooterPolicy hfPolicy = document.getHeaderFooterPolicy();

        // headers
        extractHeaders(xhtml, hfPolicy);

        // process text in the order that it occurs in
View Full Code Here

    private void extractParagraph(XWPFParagraph paragraph, XHTMLContentHandler xhtml)
            throws SAXException, XmlException, IOException {
       // If this paragraph is actually a whole new section, then
       //  it could have its own headers and footers
       // Check and handle if so
       XWPFHeaderFooterPolicy headerFooterPolicy = null;
       if (paragraph.getCTP().getPPr() != null) {
           CTSectPr ctSectPr = paragraph.getCTP().getPPr().getSectPr();
           if(ctSectPr != null) {
              headerFooterPolicy =
                  new XWPFHeaderFooterPolicy(document, ctSectPr);
              extractHeaders(xhtml, headerFooterPolicy);
           }
       }
      
       // Is this a paragraph, or a heading?
View Full Code Here

            for(CTTbl table : body.getTblArray()) {
                tables.add(new XWPFTable(table));
            }

            // Sort out headers and footers
            headerFooterPolicy = new XWPFHeaderFooterPolicy(this);

            for(POIXMLDocumentPart p : getRelations()){
                String relation = p.getPackageRelationship().getRelationshipType();
                if(relation.equals(XWPFRelation.COMMENT.getRelation())){
                    CommentsDocument cmntdoc = CommentsDocument.Factory.parse(p.getPackagePart().getInputStream());
View Full Code Here

    System.out.println(extractor.getText());
  }
 
  public String getText() {
    StringBuffer text = new StringBuffer();
    XWPFHeaderFooterPolicy hfPolicy = document.getHeaderFooterPolicy();
   
    // Start out with all headers
    // TODO - put them in where they're needed
    if(hfPolicy.getFirstPageHeader() != null) {
      text.append( hfPolicy.getFirstPageHeader().getText() );
    }
    if(hfPolicy.getEvenPageHeader() != null) {
      text.append( hfPolicy.getEvenPageHeader().getText() );
    }
    if(hfPolicy.getDefaultHeader() != null) {
      text.append( hfPolicy.getDefaultHeader().getText() );
    }
   
    // First up, all our paragraph based text
    Iterator<XWPFParagraph> i = document.getParagraphsIterator();
    while(i.hasNext()) {
      XWPFParagraphDecorator decorator = new XWPFCommentsDecorator(
          new XWPFHyperlinkDecorator(i.next(), null, fetchHyperlinks));
      text.append(decorator.getText()+"\n");
    }

    // Then our table based text
    Iterator<XWPFTable> j = document.getTablesIterator();
    while(j.hasNext()) {
      text.append(j.next().getText()+"\n");
    }
   
    // Finish up with all the footers
    // TODO - put them in where they're needed
    if(hfPolicy.getFirstPageFooter() != null) {
      text.append( hfPolicy.getFirstPageFooter().getText() );
    }
    if(hfPolicy.getEvenPageFooter() != null) {
      text.append( hfPolicy.getEvenPageFooter().getText() );
    }
    if(hfPolicy.getDefaultFooter() != null) {
      text.append( hfPolicy.getDefaultFooter().getText() );
    }
   
    return text.toString();
  }
View Full Code Here

    System.out.println(extractor.getText());
  }
 
  public String getText() {
    StringBuffer text = new StringBuffer();
    XWPFHeaderFooterPolicy hfPolicy = document.getHeaderFooterPolicy();

    // Start out with all headers
                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);
                                }

                                XWPFParagraphDecorator decorator = new XWPFCommentsDecorator(
View Full Code Here

            for(CTTbl table : body.getTblArray()) {
                tables.add(new XWPFTable(this, table));
            }

            // Sort out headers and footers
            headerFooterPolicy = new XWPFHeaderFooterPolicy(this);

            for(POIXMLDocumentPart p : getRelations()){
                String relation = p.getPackageRelationship().getRelationshipType();
                if(relation.equals(XWPFRelation.COMMENT.getRelation())){
                    CommentsDocument cmntdoc = CommentsDocument.Factory.parse(p.getPackagePart().getInputStream());
View Full Code Here

public final class TestXWPFHeader extends TestCase {

  public void testSimpleHeader() {
    XWPFDocument sampleDoc = XWPFTestDataSamples.openSampleDocument("headerFooter.docx");

    XWPFHeaderFooterPolicy policy = sampleDoc.getHeaderFooterPolicy();


    XWPFHeader header = policy.getDefaultHeader();
    XWPFFooter footer = policy.getDefaultFooter();
    assertNotNull(header);
    assertNotNull(footer);

    // TODO verify if the following is correct
    assertNull(header.toString());
View Full Code Here

TOP

Related Classes of org.apache.poi.xwpf.model.XWPFHeaderFooterPolicy

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.