Search in sources :

Example 11 with InternalFileException

use of net.heartsome.cat.converter.msexcel2007.common.InternalFileException in project translationstudio8 by heartsome.

the class AbstractPart method save.

public void save() throws InternalFileException {
    FileOutputStream os;
    File f = new File(this.partXmlPath);
    try {
        os = new FileOutputStream(f);
        xm.output(os);
        os.close();
    } catch (Exception e) {
        throw new InternalFileException("保存文件出错\n" + e.getMessage());
    }
}
Also used : FileOutputStream(java.io.FileOutputStream) File(java.io.File) InternalFileException(net.heartsome.cat.converter.msexcel2007.common.InternalFileException) IOException(java.io.IOException) VTDException(com.ximpleware.VTDException) InternalFileException(net.heartsome.cat.converter.msexcel2007.common.InternalFileException)

Example 12 with InternalFileException

use of net.heartsome.cat.converter.msexcel2007.common.InternalFileException in project translationstudio8 by heartsome.

the class DrawingsPart method updateDrawingObject.

public void updateDrawingObject() throws InternalFileException {
    StringBuffer bf = new StringBuffer();
    for (CellAnchor c : cellAnchorList) {
        c.updateCellAnchor();
        bf.append(c.getXmlContent());
    }
    vu.update(getAutoPilot(), xm, "/xdr:wsDr/text()", bf.toString());
    save();
}
Also used : CellAnchor(net.heartsome.cat.converter.msexcel2007.document.drawing.CellAnchor)

Example 13 with InternalFileException

use of net.heartsome.cat.converter.msexcel2007.common.InternalFileException 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;
}
Also used : VTDException(com.ximpleware.VTDException) AutoPilot(com.ximpleware.AutoPilot) UnsupportedEncodingException(java.io.UnsupportedEncodingException) InternalFileException(net.heartsome.cat.converter.msexcel2007.common.InternalFileException)

Example 14 with InternalFileException

use of net.heartsome.cat.converter.msexcel2007.common.InternalFileException in project translationstudio8 by heartsome.

the class WorkBookPart method loadShareStringTable.

private void loadShareStringTable() throws InternalFileException {
    List<Relationship> rList = relsPart.getRelationshipByType(Constants.PART_TYPE_SST);
    if (rList.size() != 1) {
        return;
    }
    Relationship r = rList.get(0);
    try {
        sst = new ShareStringTablePart(r.getTarget());
    } catch (FileNotFoundException e) {
    // 可能没有sharedStrings.xml
    }
}
Also used : Relationship(net.heartsome.cat.converter.msexcel2007.document.rels.Relationship) FileNotFoundException(java.io.FileNotFoundException)

Aggregations

VTDException (com.ximpleware.VTDException)7 InternalFileException (net.heartsome.cat.converter.msexcel2007.common.InternalFileException)7 IOException (java.io.IOException)5 AutoPilot (com.ximpleware.AutoPilot)4 SheetPart (net.heartsome.cat.converter.msexcel2007.document.SheetPart)4 Relationship (net.heartsome.cat.converter.msexcel2007.document.rels.Relationship)4 NullProgressMonitor (org.eclipse.core.runtime.NullProgressMonitor)4 File (java.io.File)3 VTDGen (com.ximpleware.VTDGen)2 FileInputStream (java.io.FileInputStream)2 FileNotFoundException (java.io.FileNotFoundException)2 Cell (net.heartsome.cat.converter.msexcel2007.document.Cell)2 DrawingsPart (net.heartsome.cat.converter.msexcel2007.document.DrawingsPart)2 HeaderFooter (net.heartsome.cat.converter.msexcel2007.document.HeaderFooter)2 WorkBookPart (net.heartsome.cat.converter.msexcel2007.document.WorkBookPart)2 CellAnchor (net.heartsome.cat.converter.msexcel2007.document.drawing.CellAnchor)2 VTDUtils (net.heartsome.xml.vtdimpl.VTDUtils)2 SubProgressMonitor (org.eclipse.core.runtime.SubProgressMonitor)2 XMLModifier (com.ximpleware.XMLModifier)1 FileOutputStream (java.io.FileOutputStream)1