use of com.ximpleware.VTDException 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.VTDException 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.VTDException 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;
}
use of com.ximpleware.VTDException in project translationstudio8 by heartsome.
the class Cell method loadCellText.
/**
* 加载Cell的文本内容
* @param content
* @return ;
*/
private String loadCellText(String content) {
String result = "";
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();
do {
String tVal = vu.getChildContent("t");
bf.append(tVal);
} while (ap.evalXPath() != -1);
result = bf.toString();
} else {
vu.pilot("/si/t");
result = vu.getElementContent();
}
} catch (VTDException e) {
e.printStackTrace();
}
return result;
}
use of com.ximpleware.VTDException in project translationstudio8 by heartsome.
the class DrawingsPart method loadShapeAnchor.
private void loadShapeAnchor() {
cellAnchorList = new ArrayList<CellAnchor>();
AutoPilot ap = getAutoPilot();
try {
ap.selectXPath("/xdr:wsDr/xdr:twoCellAnchor | xdr:oneCellAnchor");
while (ap.evalXPath() != -1) {
String anchorXML = vu.getElementFragment();
String fromCol = vu.getElementContent("./xdr:from/xdr:col");
String fromRow = vu.getElementContent("./xdr:from/xdr:row");
CellAnchor a = new CellAnchor(anchorXML, fromRow, fromCol);
cellAnchorList.add(a);
}
} catch (VTDException e) {
}
// sort by row&col ASC
if (cellAnchorList.size() > 0) {
Collections.sort(cellAnchorList, new Comparator<CellAnchor>() {
public int compare(CellAnchor o1, CellAnchor o2) {
int o1r = Integer.parseInt(o1.getFromRow());
int o2r = Integer.parseInt(o2.getFromRow());
int o1c = Integer.parseInt(o1.getFromCol());
int o2c = Integer.parseInt(o2.getFromCol());
if (o1r != o2r) {
return o1r - o2r;
} else {
return o1c - o2c;
}
}
});
}
}
Aggregations