Search in sources :

Example 1 with ShapeParagraph

use of net.heartsome.cat.converter.msexcel2007.document.drawing.ShapeParagraph in project translationstudio8 by heartsome.

the class XliffReader method readSheet.

private void readSheet(List<SheetPart> sheetList, IProgressMonitor monitor) throws InternalFileException {
    if (monitor == null) {
        monitor = new NullProgressMonitor();
    }
    monitor.beginTask(Messages.getString("msexcel.xliff2mse.task4"), sheetList.size() * 5);
    List<String> sheetNames = new ArrayList<String>();
    for (SheetPart sp : sheetList) {
        monitor.worked(1);
        String name = sp.getName();
        name = processContent(name);
        // 处理重复名称
        int i = 1;
        while (sheetNames.contains(name)) {
            name += i;
            i++;
        }
        sheetNames.add(name);
        sp.setSheetName(name);
        // read headers
        monitor.worked(1);
        List<HeaderFooter> headers = sp.getHeader();
        for (HeaderFooter hf : headers) {
            String content = hf.getContent();
            content = processContent(content);
            hf.setContent(content);
        }
        // update the file
        sp.setHeaderFooter(headers);
        monitor.worked(1);
        DrawingsPart drawingp = sp.getDrawingsPart();
        if (drawingp != null) {
            List<CellAnchor> aList = drawingp.getCellAnchorList();
            for (CellAnchor a : aList) {
                List<ShapeTxBody> sList = a.getShapeList();
                if (sList.size() == 0) {
                    continue;
                }
                for (ShapeTxBody s : sList) {
                    List<ShapeParagraph> pList = s.getTxBodyParagraghList();
                    for (ShapeParagraph p : pList) {
                        String content = p.getXmlContent();
                        content = processContent(content);
                        p.setXmlContent(content);
                    }
                }
            }
            drawingp.updateDrawingObject();
        }
        monitor.worked(1);
        List<Cell> cellList = sp.getCells("s");
        for (Cell c : cellList) {
            String content = c.getFullContent();
            content = processContent(content);
            c.setShareStringItemFullContent(content);
        }
        monitor.worked(1);
        // read footer
        List<HeaderFooter> footers = sp.getFoolter();
        for (HeaderFooter hf : footers) {
            String content = hf.getContent();
            content = processContent(content);
            hf.setContent(content);
        }
        // update the file
        sp.setHeaderFooter(footers);
    }
    monitor.done();
}
Also used : NullProgressMonitor(org.eclipse.core.runtime.NullProgressMonitor) ArrayList(java.util.ArrayList) HeaderFooter(net.heartsome.cat.converter.msexcel2007.document.HeaderFooter) ShapeParagraph(net.heartsome.cat.converter.msexcel2007.document.drawing.ShapeParagraph) SheetPart(net.heartsome.cat.converter.msexcel2007.document.SheetPart) ShapeTxBody(net.heartsome.cat.converter.msexcel2007.document.drawing.ShapeTxBody) CellAnchor(net.heartsome.cat.converter.msexcel2007.document.drawing.CellAnchor) DrawingsPart(net.heartsome.cat.converter.msexcel2007.document.DrawingsPart) Cell(net.heartsome.cat.converter.msexcel2007.document.Cell)

Example 2 with ShapeParagraph

use of net.heartsome.cat.converter.msexcel2007.document.drawing.ShapeParagraph in project translationstudio8 by heartsome.

the class SpreadsheetReader method readDrawings.

private void readDrawings(DrawingsPart drawingp) throws IOException {
    List<CellAnchor> aList = drawingp.getCellAnchorList();
    for (CellAnchor a : aList) {
        List<ShapeTxBody> sList = a.getShapeList();
        if (sList.size() == 0) {
            continue;
        }
        for (ShapeTxBody s : sList) {
            List<ShapeParagraph> pList = s.getTxBodyParagraghList();
            for (ShapeParagraph p : pList) {
                String txt = p.getParagraghText();
                if (txt.length() == 0) {
                    continue;
                }
                List<Object[]> txtStyle = p.getParagraghCharacterStyle();
                String[] segs = segmenter.segment(txt);
                StringBuffer bf = new StringBuffer();
                for (String seg : segs) {
                    if (txtStyle.size() > 1) {
                        List<Object[]> style = ReaderUtil.getSegStyle(txtStyle, seg, txt);
                        if (style.size() != 0) {
                            seg = ReaderUtil.appendSegStyle(seg, style);
                        }
                    }
                    bf.append("%%%").append(xliffIdex).append("%%%");
                    writeXliffFile(xliffIdex, seg);
                    xliffIdex++;
                }
                // System.out.println(bf.toString());
                p.setParagraghText(bf.toString());
            }
        }
    }
}
Also used : ShapeParagraph(net.heartsome.cat.converter.msexcel2007.document.drawing.ShapeParagraph) ShapeTxBody(net.heartsome.cat.converter.msexcel2007.document.drawing.ShapeTxBody) CellAnchor(net.heartsome.cat.converter.msexcel2007.document.drawing.CellAnchor)

Aggregations

CellAnchor (net.heartsome.cat.converter.msexcel2007.document.drawing.CellAnchor)2 ShapeParagraph (net.heartsome.cat.converter.msexcel2007.document.drawing.ShapeParagraph)2 ShapeTxBody (net.heartsome.cat.converter.msexcel2007.document.drawing.ShapeTxBody)2 ArrayList (java.util.ArrayList)1 Cell (net.heartsome.cat.converter.msexcel2007.document.Cell)1 DrawingsPart (net.heartsome.cat.converter.msexcel2007.document.DrawingsPart)1 HeaderFooter (net.heartsome.cat.converter.msexcel2007.document.HeaderFooter)1 SheetPart (net.heartsome.cat.converter.msexcel2007.document.SheetPart)1 NullProgressMonitor (org.eclipse.core.runtime.NullProgressMonitor)1