https://bz.apache.org/bugzilla/show_bug.cgi?id=58993
Tim Allison <[email protected]> changed: What |Removed |Added ---------------------------------------------------------------------------- Status|NEW |RESOLVED Resolution|--- |WONTFIX --- Comment #2 from Tim Allison <[email protected]> --- At least with docx, I don't think this is a fault of POI, and I don't think we can fix it. Once you hit getCTP(), you are out of the hands of POI and into the hands of beans. If you look at the ECMA OOXML part 1 standard p. 312, you'll see exactly the same underlying xml that is in your docx, where the only indication is the presence of <rtl/> in both the pPr's rPr and each run's rPr. In short, there is no bidi element in the pPr. While I want your code to work, it looks like the way to get at whether a paragraph is basically rtl or whether a run is rtl _in your document_ (and the test document that I generated as well) is to check for the existence of rtl. For a paragraph, if p.getCTP().getPPr().getRPr.getRtl() is null, then the paragraph is probably lrt; if it is not null, then check its value. If its value is null, then the paragraph is basically LTR, otherwise, I imagine, follow whatever value it has. For a run, if r.getRPr().getRtl() is null, then that run is ltr, if it is not null, then you should probably check its value, which may or may not be null. InputStream is = new FileInputStream(f); XWPFDocument doc = new XWPFDocument(is); for (XWPFParagraph p : doc.getParagraphs()) { if (p.getCTP() != null && p.getCTP().getPPr() != null) { if (p.getCTP().getPPr().getRPr().getRtl() != null) { if (p.getCTP().getPPr().getRPr().getRtl().getVal() == null) { System.out.println("para: rtl"); } else { System.out.println("para: " + p.getCTP().getPPr().getRPr().getRtl().getVal()); } } else { System.out.println("para: ltr"); } } for (XWPFRun r : p.getRuns()) { if (r.getCTR().getRPr() != null && r.getCTR().getRPr().getRtl() != null) { //probably rtl if (r.getCTR().getRPr().getRtl().getVal() == null) { System.out.println("run: rtl"); } else { System.out.println("run: " +r.getCTR().getRPr().getRtl().getVal()); } } else { System.out.println("run: ltr"); } } } -- You are receiving this mail because: You are the assignee for the bug. --------------------------------------------------------------------- To unsubscribe, e-mail: [email protected] For additional commands, e-mail: [email protected]
