List of usage examples for org.apache.poi.hwpf.model PropertyNode getStart
public int getStart()
From source file:b01.officeLink.ExtendedWordDocument.java
License:Apache License
public void replace_XXXXX(String oldString, String newString) { // hack to get the ending cp of the document, Have to revisit this. if (getHwpfDocument() != null && getHwpfDocument().getTextTable() != null) { java.util.List text = getHwpfDocument().getTextTable().getTextPieces(); for (int i = 0; i < text.size(); i++) { PropertyNode p = (PropertyNode) text.get(i); System.out.println("Property Node " + i + " = " + p); System.out.println("Start = " + p.getStart() + " End = " + p.getEnd()); System.out.println("Class = " + p.getClass().getName()); if (p instanceof TextPiece) { TextPiece tp = (TextPiece) p; StringBuffer buffer = tp.getStringBuffer(); System.out.println("Buffer = " + buffer); int start = buffer.indexOf(oldString); int end = start + oldString.length(); //buffer.indexOf(newString); buffer.replace(start, end, newString); tp.setEnd(tp.getEnd() + (newString.length() - oldString.length())); }//from www .j a v a 2s .com } } }