List of usage examples for org.apache.poi.hwpf.usermodel ParagraphProperties getIndentFromLeft
public int getIndentFromLeft()
From source file:ua.kiev.univ.linguistics.MSWordDocumentExtractor.java
License:Open Source License
/** * * @param pp//from w w w .jav a2s . c o m * @param text * @return -2 - free, -1 - left, 0 - tittle, 1 - right heading */ private static int getType(ParagraphProperties pp, String text) { if (pp.getJustification() == 1) { return 0; } if (pp.getJustification() == 2) { return 1; } int leftSpacing = 0, rightSpacing = 0; int i = 0, j = text.length() - 1; while (i < text.length() && (j = getWidthSpace(pp, text.charAt(i))) != -1) { leftSpacing += j; i++; } if (i == text.length()) { return -2; } while (i >= 0 && (j = getWidthSpace(pp, text.charAt(i))) != -1) { rightSpacing += j; i--; } int width = 3000; int leftTextBegin = pp.getIndentFromLeft() + leftSpacing; if (leftTextBegin > width * RIGHTCOEF) { return 1; } if (leftTextBegin > width * CENTERCOEF) { return 0; } return -1; }