mirror of https://github.com/apache/poi.git
Get to a consistent indent
git-svn-id: https://svn.apache.org/repos/asf/poi/trunk@948116 13f79535-47bb-0310-9956-ffa450edef68
This commit is contained in:
parent
d8f85ad2eb
commit
2836dd45d6
|
@ -76,75 +76,73 @@ public class XWPFWordExtractor extends POIXMLTextExtractor {
|
||||||
XWPFHeaderFooterPolicy hfPolicy = document.getHeaderFooterPolicy();
|
XWPFHeaderFooterPolicy hfPolicy = document.getHeaderFooterPolicy();
|
||||||
|
|
||||||
// Start out with all headers
|
// Start out with all headers
|
||||||
extractHeaders(text, hfPolicy);
|
extractHeaders(text, hfPolicy);
|
||||||
|
|
||||||
// First up, all our paragraph based text
|
// First up, all our paragraph based text
|
||||||
Iterator<XWPFParagraph> i = document.getParagraphsIterator();
|
Iterator<XWPFParagraph> i = document.getParagraphsIterator();
|
||||||
while(i.hasNext()) {
|
while(i.hasNext()) {
|
||||||
XWPFParagraph paragraph = i.next();
|
XWPFParagraph paragraph = i.next();
|
||||||
|
|
||||||
|
try {
|
||||||
|
CTSectPr ctSectPr = null;
|
||||||
|
if (paragraph.getCTP().getPPr()!=null) {
|
||||||
|
ctSectPr = paragraph.getCTP().getPPr().getSectPr();
|
||||||
|
}
|
||||||
|
|
||||||
try {
|
XWPFHeaderFooterPolicy headerFooterPolicy = null;
|
||||||
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);
|
||||||
|
}
|
||||||
|
|
||||||
if (ctSectPr!=null) {
|
XWPFParagraphDecorator decorator = new XWPFCommentsDecorator(
|
||||||
headerFooterPolicy = new XWPFHeaderFooterPolicy(document, ctSectPr);
|
new XWPFHyperlinkDecorator(paragraph, null, fetchHyperlinks));
|
||||||
|
text.append(decorator.getText()).append('\n');
|
||||||
|
|
||||||
extractHeaders(text, headerFooterPolicy);
|
if (ctSectPr!=null) {
|
||||||
}
|
extractFooters(text, headerFooterPolicy);
|
||||||
|
}
|
||||||
XWPFParagraphDecorator decorator = new XWPFCommentsDecorator(
|
} catch (IOException e) {
|
||||||
new XWPFHyperlinkDecorator(paragraph, null, fetchHyperlinks));
|
throw new POIXMLException(e);
|
||||||
text.append(decorator.getText()).append('\n');
|
} catch (XmlException e) {
|
||||||
|
throw new POIXMLException(e);
|
||||||
if (ctSectPr!=null) {
|
}
|
||||||
extractFooters(text, headerFooterPolicy);
|
}
|
||||||
}
|
|
||||||
} catch (IOException e) {
|
|
||||||
throw new POIXMLException(e);
|
|
||||||
} catch (XmlException e) {
|
|
||||||
throw new POIXMLException(e);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
// Then our table based text
|
// Then our table based text
|
||||||
Iterator<XWPFTable> j = document.getTablesIterator();
|
Iterator<XWPFTable> j = document.getTablesIterator();
|
||||||
while(j.hasNext()) {
|
while(j.hasNext()) {
|
||||||
text.append(j.next().getText()).append('\n');
|
text.append(j.next().getText()).append('\n');
|
||||||
}
|
}
|
||||||
|
|
||||||
// Finish up with all the footers
|
// Finish up with all the footers
|
||||||
extractFooters(text, hfPolicy);
|
extractFooters(text, hfPolicy);
|
||||||
|
|
||||||
return text.toString();
|
return text.toString();
|
||||||
}
|
}
|
||||||
|
|
||||||
private void extractFooters(StringBuffer text, XWPFHeaderFooterPolicy hfPolicy) {
|
private void extractFooters(StringBuffer text, XWPFHeaderFooterPolicy hfPolicy) {
|
||||||
if(hfPolicy.getFirstPageFooter() != null) {
|
if(hfPolicy.getFirstPageFooter() != null) {
|
||||||
text.append( hfPolicy.getFirstPageFooter().getText() );
|
text.append( hfPolicy.getFirstPageFooter().getText() );
|
||||||
}
|
}
|
||||||
if(hfPolicy.getEvenPageFooter() != null) {
|
if(hfPolicy.getEvenPageFooter() != null) {
|
||||||
text.append( hfPolicy.getEvenPageFooter().getText() );
|
text.append( hfPolicy.getEvenPageFooter().getText() );
|
||||||
}
|
}
|
||||||
if(hfPolicy.getDefaultFooter() != null) {
|
if(hfPolicy.getDefaultFooter() != null) {
|
||||||
text.append( hfPolicy.getDefaultFooter().getText() );
|
text.append( hfPolicy.getDefaultFooter().getText() );
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private void extractHeaders(StringBuffer text, XWPFHeaderFooterPolicy hfPolicy) {
|
private void extractHeaders(StringBuffer text, XWPFHeaderFooterPolicy hfPolicy) {
|
||||||
if(hfPolicy.getFirstPageHeader() != null) {
|
if(hfPolicy.getFirstPageHeader() != null) {
|
||||||
text.append( hfPolicy.getFirstPageHeader().getText() );
|
text.append( hfPolicy.getFirstPageHeader().getText() );
|
||||||
}
|
}
|
||||||
if(hfPolicy.getEvenPageHeader() != null) {
|
if(hfPolicy.getEvenPageHeader() != null) {
|
||||||
text.append( hfPolicy.getEvenPageHeader().getText() );
|
text.append( hfPolicy.getEvenPageHeader().getText() );
|
||||||
}
|
}
|
||||||
if(hfPolicy.getDefaultHeader() != null) {
|
if(hfPolicy.getDefaultHeader() != null) {
|
||||||
text.append( hfPolicy.getDefaultHeader().getText() );
|
text.append( hfPolicy.getDefaultHeader().getText() );
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue