Search in sources :

Example 1 with DocumentRelation

use of net.heartsome.cat.converter.word2007.partOper.DocumentRelation in project translationstudio8 by heartsome.

the class TestWord2007 method xliff2Docx.

public void xliff2Docx() {
    try {
        String xliffFile = "/home/robert/workspace/runtime-UltimateEdition.product/testDocxConverter/XLIFF/zh-CN/测试简单word文档.docx.hsxliff";
        String outputFile = "/home/robert/Desktop/word 2007 skeleton/最终word文档.docx";
        String skeletonFile = "/home/robert/Desktop/word 2007 skeleton/测试简单word文档.docx_files";
        //			String xliffFile = "E:\\workspaces\\runtime-UltimateEdition.product\\testWord2007Convert\\XLIFF\\zh-CN\\测试简单word文档.docx.hsxliff";
        //			String outputFile = "/home/robert/Desktop/word 2007 skeleton/最终word文档.docx";
        //			String skeletonFile = "C:\\Users\\Administrator\\Desktop\\word 2007 skeleton\\测试简单word文档.docx_files";
        // 先解压 docx 文件
        String docxFolderPath = ZipUtil.upZipFile(skeletonFile, null);
        PathUtil pathUtil = new PathUtil(docxFolderPath);
        // 定义一个 hsxliff 的读入器
        XliffInputer xlfInput = new XliffInputer(xliffFile, pathUtil);
        // 正转换是从 主文档入手的,而逆转换则是从 word/_rels/document.xml.rels 入手,先处理掉 页眉,页脚,脚注,批注,尾注
        String docRelsPath = pathUtil.getPackageFilePath(PathConstant.DOCUMENTRELS, false);
        DocumentRelation docRels = new DocumentRelation(docRelsPath, pathUtil);
        docRels.arrangeRelations(xlfInput, new NullProgressMonitor());
    // 再处理主文档
    //			pathUtil.setSuperRoot();
    //			String docPath = pathUtil.getPackageFilePath(PathConstant.DOCUMENT, false);
    //			DocumentPart documentPart = new DocumentPart(docPath, xlfInput);
    //			documentPart.reverseConvert();
    } catch (Exception e) {
        e.printStackTrace();
    } finally {
        try {
            System.out.println("----------");
        } catch (Exception e2) {
            e2.printStackTrace();
        }
    }
}
Also used : DocumentRelation(net.heartsome.cat.converter.word2007.partOper.DocumentRelation) NullProgressMonitor(org.eclipse.core.runtime.NullProgressMonitor) PathUtil(net.heartsome.cat.converter.word2007.common.PathUtil)

Aggregations

PathUtil (net.heartsome.cat.converter.word2007.common.PathUtil)1 DocumentRelation (net.heartsome.cat.converter.word2007.partOper.DocumentRelation)1 NullProgressMonitor (org.eclipse.core.runtime.NullProgressMonitor)1