--- src/java/org/apache/poi/util/Units.java (revisi¢n: 1655973) +++ src/java/org/apache/poi/util/Units.java (copia de trabajo) @@ -26,11 +26,20 @@ /** * Converts points to EMUs * @param points points - * @return emus + * @return EMUs */ public static int toEMU(double points){ return (int)Math.round(EMU_PER_POINT*points); } + + /** + * Converts pixels to EMUs + * @param pixels pixels + * @return EMUs + */ + public static int pixelToEMU(int pixels) { + return pixels*EMU_PER_PIXEL; + } /** * Converts EMUs to points --- src/ooxml/java/org/apache/poi/xwpf/usermodel/XWPFDocument.java (revisi¢n: 1655973) +++ src/ooxml/java/org/apache/poi/xwpf/usermodel/XWPFDocument.java (copia de trabajo) @@ -330,7 +330,7 @@ */ @Override public XWPFTable getTableArray(int pos) { - if (pos > 0 && pos < tables.size()){ + if (pos >= 0 && pos < tables.size()){ return tables.get(pos); } return null; @@ -345,7 +345,10 @@ } public XWPFFooter getFooterArray(int pos){ - return footers.get(pos); + if(pos >=0 && pos < footers.size()) { + return footers.get(pos); + } + return null; } /** @@ -357,7 +360,10 @@ } public XWPFHeader getHeaderArray(int pos){ - return headers.get(pos); + if(pos >=0 && pos < headers.size()) { + return headers.get(pos); + } + return null; } public String getTblStyle(XWPFTable table){ --- src/ooxml/java/org/apache/poi/xwpf/usermodel/XWPFFootnote.java (revisi¢n: 1655973) +++ src/ooxml/java/org/apache/poi/xwpf/usermodel/XWPFFootnote.java (copia de trabajo) @@ -111,7 +111,7 @@ * @see org.apache.poi.xwpf.usermodel.IBody#getTableArray(int) */ public XWPFTable getTableArray(int pos) { - if(pos > 0 && pos < tables.size()){ + if(pos >= 0 && pos < tables.size()){ return tables.get(pos); } return null; @@ -177,8 +177,10 @@ * @see org.apache.poi.xwpf.usermodel.IBody#getParagraphArray(int pos) */ public XWPFParagraph getParagraphArray(int pos) { - - return paragraphs.get(pos); + if(pos >=0 && pos < paragraphs.size()) { + return paragraphs.get(pos); + } + return null; } /** @@ -206,7 +208,7 @@ return null; } XWPFTableRow tableRow = table.getRow(row); - if(row == null){ + if(tableRow == null){ return null; } return tableRow.getTableCell(cell); --- src/ooxml/java/org/apache/poi/xwpf/usermodel/XWPFHeaderFooter.java (revisi¢n: 1655973) +++ src/ooxml/java/org/apache/poi/xwpf/usermodel/XWPFHeaderFooter.java (copia de trabajo) @@ -203,8 +203,10 @@ * the text of the header or footer. */ public XWPFParagraph getParagraphArray(int pos) { - - return paragraphs.get(pos); + if(pos >= 0 && pos 0 && pos < tables.size()){ + if(pos >= 0 && pos < tables.size()){ return tables.get(pos); } return null; --- src/ooxml/java/org/apache/poi/xwpf/usermodel/XWPFTableCell.java (revisi¢n: 1655973) +++ src/ooxml/java/org/apache/poi/xwpf/usermodel/XWPFTableCell.java (copia de trabajo) @@ -340,7 +340,7 @@ * @see org.apache.poi.xwpf.usermodel.IBody#getParagraphArray(int) */ public XWPFParagraph getParagraphArray(int pos) { - if(pos > 0 && pos < paragraphs.size()){ + if(pos >= 0 && pos < paragraphs.size()){ return paragraphs.get(pos); } return null; @@ -379,7 +379,7 @@ * @see org.apache.poi.xwpf.usermodel.IBody#getTableArray(int) */ public XWPFTable getTableArray(int pos) { - if(pos > 0 && pos < tables.size()){ + if(pos >= 0 && pos < tables.size()){ return tables.get(pos); } return null;