ASF Bugzilla – Attachment 32261 Details for
Bug 57312
XWPFRun.getUnderline() throws NullPointerException, when missing xml attribute "w:val"
Home
|
New
|
Browse
|
Search
|
[?]
|
Reports
|
Help
|
New Account
|
Log In
Remember
[x]
|
Forgot Password
Login:
[x]
Java code
GetUnderlineBug.java (text/x-java), 1.53 KB, created by
RafTrusz
on 2014-12-05 10:21:06 UTC
(
hide
)
Description:
Java code
Filename:
MIME Type:
Creator:
RafTrusz
Created:
2014-12-05 10:21:06 UTC
Size:
1.53 KB
patch
obsolete
>package poi; > >import java.io.File; >import java.io.FileInputStream; >import java.io.IOException; > >import org.apache.poi.xwpf.usermodel.BodyElementType; >import org.apache.poi.xwpf.usermodel.IBodyElement; >import org.apache.poi.xwpf.usermodel.IRunElement; >import org.apache.poi.xwpf.usermodel.UnderlinePatterns; >import org.apache.poi.xwpf.usermodel.XWPFDocument; >import org.apache.poi.xwpf.usermodel.XWPFParagraph; >import org.apache.poi.xwpf.usermodel.XWPFRun; > >public class GetUnderlineBug { > > public static void main(String[] args) throws IOException { > FileInputStream inputStream = null; > > try { > File file = new File("src/main/java/poi/rozdz-3b.docx"); > if (! file.exists() ){ > System.err.println("File " + file.getAbsolutePath() + " not found"); > return; > } > > inputStream = new FileInputStream(file); > XWPFDocument xwpfDocument = new XWPFDocument(inputStream); > > for( IBodyElement bodyElement : xwpfDocument.getBodyElements()){ > BodyElementType elementType = bodyElement.getElementType(); > > if(elementType == BodyElementType.PARAGRAPH) { > XWPFParagraph paragraph = (XWPFParagraph) bodyElement; > > for (IRunElement iRunElem : paragraph.getIRuns()){ > > if (iRunElem instanceof XWPFRun){ > XWPFRun runElement = (XWPFRun) iRunElem; > > UnderlinePatterns underline = runElement.getUnderline(); > //NullPointerException > } > } > } > } > } finally { > if (inputStream == null) return; > > inputStream.close(); > } > } > >}
You cannot view the attachment while viewing its details because your browser does not support IFRAMEs.
View the attachment on a separate page
.
View Attachment As Raw
Actions:
View
Attachments on
bug 57312
: 32261 |
32262