use of com.ximpleware.VTDException in project translationstudio8 by heartsome.
the class XliffReader method getTargetById.
private String getTargetById(String id) throws InternalFileException {
String result = null;
String xpath = "/xliff/file/body/trans-unit[@id='" + id + "']";
AutoPilot ap = new AutoPilot(vu.getVTDNav());
try {
ap.selectXPath(xpath);
if (ap.evalXPath() != -1) {
String text = vu.getChildContent("./target");
if (text == null) {
text = vu.getChildContent("./target");
vu.pilot("./source");
} else {
vu.pilot("./target");
}
Map<Integer, String[]> anaysisRs = anaysisTarget();
result = converterAnaysisResult(anaysisRs);
}
} catch (VTDException e) {
logger.error("", e);
}
if (result == null) {
throw new InternalFileException(MessageFormat.format(Messages.getString("msexcel.xliff2mse.msg1"), id));
}
return result;
}
use of com.ximpleware.VTDException in project translationstudio8 by heartsome.
the class CellAnchor method updateCellAnchor.
public void updateCellAnchor() {
for (ShapeTxBody s : shapeList) {
s.updateParagragh();
}
String xpath = "//xdr:sp/xdr:txBody";
AutoPilot ap = getDeclareNSAutoPilot();
try {
ap.selectXPath(xpath);
int i = 0;
while (ap.evalXPath() != -1) {
ShapeTxBody s = shapeList.get(i);
xm.remove();
xm.insertAfterElement(s.getXmlContent());
i++;
}
save();
} catch (VTDException e) {
logger.error("", e);
} catch (UnsupportedEncodingException e) {
logger.error("", e);
}
}
use of com.ximpleware.VTDException in project translationstudio8 by heartsome.
the class CellAnchor method loadShapeAnchor.
private void loadShapeAnchor() {
this.shapeList = new ArrayList<ShapeTxBody>();
String xpath = "//xdr:sp";
AutoPilot ap = getDeclareNSAutoPilot();
try {
ap.selectXPath(xpath);
while (ap.evalXPath() != -1) {
AutoPilot _ap = getDeclareNSAutoPilot();
_ap.selectXPath("./xdr:txBody");
vu.getVTDNav().push();
if (_ap.evalXPath() != -1) {
ShapeTxBody s = new ShapeTxBody(vu.getElementFragment());
shapeList.add(s);
}
vu.getVTDNav().pop();
}
} catch (VTDException e) {
logger.error("", e);
}
}
use of com.ximpleware.VTDException in project translationstudio8 by heartsome.
the class ShapeParagraph method getParagraghCharacterStyle.
private List<Object[]> getParagraghCharacterStyle(String cellText) {
List<Object[]> result = new ArrayList<Object[]>();
try {
AutoPilot ap = getDeclareNSAutoPilot();
ap.selectXPath("/a:p/a:r");
if (ap.evalXPath() != -1) {
StringBuffer bf = new StringBuffer();
do {
String rPrC = getChilderFragment("a:rPr");
if (rPrC != null) {
bf.append("ctype=\"a\" rPr=\"").append(ReaderUtil.cleanAttribute(rPrC)).append("\"");
} else {
bf.append("ctype=\"a\">");
}
String tVal = vu.getChildContent("a:t");
int sos = cellText.indexOf(tVal);
int length = tVal.length();
Object[] obj = new Object[3];
obj[0] = sos;
obj[1] = 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 ShapeTxBody method updateParagragh.
void updateParagragh() {
String xpath = "/xdr:txBody/a:p";
AutoPilot ap = getDeclareNSAutoPilot();
try {
ap.selectXPath(xpath);
int i = 0;
while (ap.evalXPath() != -1) {
ShapeParagraph p = pList.get(i);
xm.remove();
xm.insertAfterElement(p.getXmlContent());
i++;
}
save();
} catch (VTDException e) {
logger.error("", e);
} catch (UnsupportedEncodingException e) {
logger.error("", e);
}
}
Aggregations