use of com.ximpleware.AutoPilot in project translationstudio8 by heartsome.
the class ShapeParagraph method getChilderFragment.
private String getChilderFragment(String elementName) throws VTDException {
String text = null;
AutoPilot ap = getDeclareNSAutoPilot();
ap.selectXPath("./" + elementName);
vu.getVTDNav().push();
if (ap.evalXPath() != -1) {
text = vu.getElementFragment();
}
vu.getVTDNav().pop();
return text;
}
use of com.ximpleware.AutoPilot in project translationstudio8 by heartsome.
the class ShapeParagraph method getCellValueText.
private String getCellValueText() {
String result = "";
try {
AutoPilot ap = getDeclareNSAutoPilot();
ap.selectXPath("/a:p/a:r");
if (ap.evalXPath() != -1) {
StringBuffer bf = new StringBuffer();
do {
String tVal = vu.getChildContent("a:t");
bf.append(tVal);
} while (ap.evalXPath() != -1);
result = bf.toString();
}
} catch (VTDException e) {
logger.error("", e);
}
return result;
}
use of com.ximpleware.AutoPilot in project translationstudio8 by heartsome.
the class ShapeTxBody method loadParagraph.
private void loadParagraph() {
pList = new ArrayList<ShapeParagraph>();
String xpath = "/xdr:txBody/a:p";
AutoPilot ap = getDeclareNSAutoPilot();
try {
ap.selectXPath(xpath);
while (ap.evalXPath() != -1) {
ShapeParagraph p = new ShapeParagraph(vu.getElementFragment());
pList.add(p);
}
} catch (VTDException e) {
logger.error("", e);
}
}
use of com.ximpleware.AutoPilot in project translationstudio8 by heartsome.
the class Cell method getNonTextContent.
/**
* Get rPh & phoneticPr Element fragment
* @return ;
*/
private String getNonTextContent() {
StringBuffer result = new StringBuffer();
VTDGen vg = new VTDGen();
vg.setDoc(content.getBytes());
VTDUtils vu = null;
try {
vg.parse(true);
vu = new VTDUtils(vg.getNav());
AutoPilot ap = new AutoPilot(vu.getVTDNav());
ap.selectXPath("/si/rPh | phoneticPr");
while (ap.evalXPath() != -1) {
result.append(vu.getElementFragment());
}
} catch (VTDException e) {
e.printStackTrace();
}
return result.toString();
}
use of com.ximpleware.AutoPilot in project translationstudio8 by heartsome.
the class Cell method loadCellCharacterStyle.
private List<Object[]> loadCellCharacterStyle(String content, String cellText) {
List<Object[]> result = new ArrayList<Object[]>();
VTDGen vg = new VTDGen();
vg.setDoc(content.getBytes());
VTDUtils vu = null;
try {
vg.parse(true);
vu = new VTDUtils(vg.getNav());
AutoPilot ap = new AutoPilot(vu.getVTDNav());
ap.selectXPath("/si/r");
if (ap.evalXPath() != -1) {
StringBuffer bf = new StringBuffer();
int start = 0;
do {
String rPrC = vu.getChildContent("rPr");
if (rPrC != null) {
rPrC = "<rPr>" + rPrC + "</rPr>";
bf.append("rPr=\"").append(ReaderUtil.cleanAttribute(rPrC)).append("\"");
} else {
bf.append(" ");
}
String tVal = vu.getChildContent("t");
if (tVal == null || tVal.length() == 0) {
// clear
bf.delete(0, bf.length());
continue;
}
int sos = cellText.indexOf(tVal, start);
int length = tVal.length();
Object[] obj = new Object[3];
obj[0] = sos;
obj[1] = start = sos + length;
obj[2] = bf.toString();
result.add(obj);
// clear
bf.delete(0, bf.length());
} while (ap.evalXPath() != -1);
}
} catch (VTDException e) {
logger.error("", e);
}
return result;
}
Aggregations