use of com.ximpleware.VTDException in project translationstudio8 by heartsome.
the class AbstractPart method loadFile.
protected void loadFile() throws InternalFileException {
File f = new File(this.partXmlPath);
VTDGen vg = new VTDGen();
FileInputStream fis = null;
byte[] b = new byte[(int) f.length()];
try {
fis = new FileInputStream(f);
fis.read(b);
} catch (IOException e) {
throw new InternalFileException(Messages.getString("msexcel.converter.exception.msg1"));
} finally {
if (fis != null) {
try {
fis.close();
} catch (Exception e) {
logger.error("", e);
}
}
}
vg.setDoc(b);
try {
vg.parse(true);
vu = new VTDUtils(vg.getNav());
xm = new XMLModifier(vu.getVTDNav());
} catch (VTDException e) {
String message = Messages.getString("msexcel.converter.exception.msg1");
message += "\nFile:" + f.getName() + "\n" + e.getMessage();
throw new InternalFileException(message);
}
}
use of com.ximpleware.VTDException in project translationstudio8 by heartsome.
the class RelsPart method loadRealtionship.
public void loadRealtionship() {
relationships = new ArrayList<Relationship>();
String xpath = "/Relationships/Relationship";
AutoPilot ap = new AutoPilot(vu.getVTDNav());
try {
ap.selectXPath(xpath);
while (ap.evalXPath() != -1) {
Hashtable<String, String> attrs = vu.getCurrentElementAttributs();
if (attrs == null) {
// TODO Error
}
String id = attrs.get("Id");
String type = attrs.get("Type");
String target = attrs.get("Target");
Relationship rsp = new Relationship(id, type, target);
relationships.add(rsp);
}
} catch (VTDException e) {
logger.error("", e);
}
}
use of com.ximpleware.VTDException in project translationstudio8 by heartsome.
the class SheetPart method fillShareStringTable.
/***
* 将Share String Tbale中的数据填充满,即每一个引用都对应独立的String item
* @param sst
* ;
* @throws InternalFileException
*/
public int fillShareStringTable(ShareStringTablePart sst, int index, StringBuffer siBf) throws InternalFileException {
String xpath = "/worksheet/sheetData/row/c[@t='s']/v";
try {
AutoPilot ap = new AutoPilot(vu.getVTDNav());
ap.selectXPath(xpath);
while (ap.evalXPath() != -1) {
String c = vu.getElementContent();
int cInt = 0;
try {
cInt = Integer.parseInt(c);
} catch (NumberFormatException e) {
throw new InternalFileException(Messages.getString("msexcel.converter.exception.msg1"));
}
siBf.append(sst.getStringItemFragment(cInt));
xm.updateToken(vu.getVTDNav().getCurrentIndex() + 1, index + "");
index++;
}
saveAndReload();
} catch (VTDException e) {
logger.error("", e);
} catch (UnsupportedEncodingException e) {
logger.error("", e);
}
return index;
}
use of com.ximpleware.VTDException in project translationstudio8 by heartsome.
the class SheetPart method loadHeaderFooter.
private void loadHeaderFooter() {
this.headers = new ArrayList<HeaderFooter>();
this.footers = new ArrayList<HeaderFooter>();
String xpath = "/worksheet/headerFooter/*";
AutoPilot ap = new AutoPilot(vu.getVTDNav());
try {
ap.selectXPath(xpath);
while (ap.evalXPath() != -1) {
String type = vu.getCurrentElementName();
String c = vu.getElementContent();
HeaderFooter e = new HeaderFooter(type, c);
if (type.equals("oddHeader") || type.equals("evenHeader") || type.equals("firstHeader")) {
headers.add(e);
} else if (type.equals("oddFooter") || type.equals("evenFooter") || type.equals("firstFooter")) {
footers.add(e);
}
}
} catch (VTDException e) {
logger.error("", e);
}
}
use of com.ximpleware.VTDException in project translationstudio8 by heartsome.
the class StylesPart method loadRedFgStyle.
private void loadRedFgStyle() {
redStyleIndexs = new ArrayList<Integer>();
String xpath = "/styleSheet/cellXfs/xf";
try {
AutoPilot ap = new AutoPilot(vu.getVTDNav());
ap.selectXPath(xpath);
while (ap.evalXPath() != -1) {
String fIdx = vu.getCurrentElementAttribut("fontId", "");
if (!fIdx.equals("") && isRedColor(Integer.parseInt(fIdx))) {
redStyleIndexs.add(vu.getVTDNav().getCurrentDepth() - 1);
}
}
} catch (VTDException e) {
e.printStackTrace();
}
}
Aggregations