Search in sources :

Example 16 with VTDException

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

Example 17 with VTDException

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);
    }
}
Also used : VTDException(com.ximpleware.VTDException) AutoPilot(com.ximpleware.AutoPilot) UnsupportedEncodingException(java.io.UnsupportedEncodingException)

Example 18 with VTDException

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);
    }
}
Also used : VTDException(com.ximpleware.VTDException) AutoPilot(com.ximpleware.AutoPilot)

Example 19 with VTDException

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;
}
Also used : VTDException(com.ximpleware.VTDException) AutoPilot(com.ximpleware.AutoPilot) ArrayList(java.util.ArrayList)

Example 20 with VTDException

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);
    }
}
Also used : VTDException(com.ximpleware.VTDException) AutoPilot(com.ximpleware.AutoPilot) UnsupportedEncodingException(java.io.UnsupportedEncodingException)

Aggregations

VTDException (com.ximpleware.VTDException)27 AutoPilot (com.ximpleware.AutoPilot)20 VTDUtils (net.heartsome.xml.vtdimpl.VTDUtils)9 VTDGen (com.ximpleware.VTDGen)8 IOException (java.io.IOException)6 InternalFileException (net.heartsome.cat.converter.msexcel2007.common.InternalFileException)5 XMLModifier (com.ximpleware.XMLModifier)3 File (java.io.File)3 FileInputStream (java.io.FileInputStream)3 UnsupportedEncodingException (java.io.UnsupportedEncodingException)3 Relationship (net.heartsome.cat.converter.msexcel2007.document.rels.Relationship)3 NavException (com.ximpleware.NavException)2 VTDNav (com.ximpleware.VTDNav)2 FileNotFoundException (java.io.FileNotFoundException)2 ArrayList (java.util.ArrayList)2 OperationCanceledException (org.eclipse.core.runtime.OperationCanceledException)2 EOFException (com.ximpleware.EOFException)1 EncodingException (com.ximpleware.EncodingException)1 EntityException (com.ximpleware.EntityException)1 ModifyException (com.ximpleware.ModifyException)1