private void extractGroupText(XHTMLContentHandler xhtml, ShapeContainer shapeContainer, int depth) throws SAXException { List<HSLFShape> shapes = getShapes(shapeContainer); if (shapes == null) { return; } //Only process items with depth > 0 because they should have been included //already in slide.getTextParagraphs above. //However, cells are considered grouped within the table, so ignore them. //I don't believe that cells can be inside a text box or other //grouped text containing object, so always ignore them. //I also don't believe that a table can be grouped with a table. //If these beliefs are wrong...must fix! List<List<HSLFTextParagraph>> paragraphList = new ArrayList<>(); for (HSLFShape shape : shapes) { if (shape instanceof HSLFGroupShape) { //work recursively, HSLFGroupShape can contain HSLFGroupShape extractGroupText(xhtml, ((HSLFGroupShape)shape), depth+1); } else if (shape instanceof HSLFTextShape && ! (shape instanceof HSLFTableCell) && depth > 0) { paragraphList.add(((HSLFTextShape)shape).getTextParagraphs()); } } textRunsToText(xhtml, paragraphList); }
@Override protected void onAddTextShape(HSLFTextShape shape) { List<HSLFTextParagraph> newParas = shape.getTextParagraphs(); _paragraphs.add(newParas); }
@Override protected void onAddTextShape(HSLFTextShape shape) { List<HSLFTextParagraph> runs = shape.getTextParagraphs(); _paragraphs.add(runs); }
/** * Find hyperlinks in a text shape * * @param shape <code>TextRun</code> to lookup hyperlinks in * @return found hyperlinks or <code>null</code> if not found */ public static List<HSLFHyperlink> find(HSLFTextShape shape){ return find(shape.getTextParagraphs()); }
/** * Returns the raw text content of the shape. This hasn't had any * changes applied to it, and so is probably unlikely to print * out nicely. */ public String getRawText() { return HSLFTextParagraph.getRawText(getTextParagraphs()); }
/** * Saves the modified paragraphs/textrun to the records. * Also updates the styles to the correct text length. */ protected void storeText() { List<HSLFTextParagraph> paras = getTextParagraphs(); HSLFTextParagraph.storeText(paras); }
@Override public void setSheet(HSLFSheet sheet) { super.setSheet(sheet); // Initialize _txtrun object. // (We can't do it in the constructor because the sheet // is not assigned then, it's only built once we have // all the records) List<HSLFTextParagraph> ltp = getTextParagraphs(); HSLFTextParagraph.supplySheet(ltp, sheet); }
@Override public HSLFTextRun appendText(String text, boolean newParagraph) { // init paragraphs List<HSLFTextParagraph> paras = getTextParagraphs(); HSLFTextRun htr = HSLFTextParagraph.appendText(paras, text, newParagraph); setTextId(getRawText().hashCode()); return htr; }
@Override public HSLFTextRun setText(String text) { // init paragraphs List<HSLFTextParagraph> paras = getTextParagraphs(); HSLFTextRun htr = HSLFTextParagraph.setText(paras, text); setTextId(getRawText().hashCode()); return htr; }
private void extractGroupText(XHTMLContentHandler xhtml, ShapeContainer shapeContainer, int depth) throws SAXException { List<HSLFShape> shapes = getShapes(shapeContainer); if (shapes == null) { return; } //Only process items with depth > 0 because they should have been included //already in slide.getTextParagraphs above. //However, cells are considered grouped within the table, so ignore them. //I don't believe that cells can be inside a text box or other //grouped text containing object, so always ignore them. //I also don't believe that a table can be grouped with a table. //If these beliefs are wrong...must fix! List<List<HSLFTextParagraph>> paragraphList = new ArrayList<>(); for (HSLFShape shape : shapes) { if (shape instanceof HSLFGroupShape) { //work recursively, HSLFGroupShape can contain HSLFGroupShape extractGroupText(xhtml, ((HSLFGroupShape)shape), depth+1); } else if (shape instanceof HSLFTextShape && ! (shape instanceof HSLFTableCell) && depth > 0) { paragraphList.add(((HSLFTextShape)shape).getTextParagraphs()); } } textRunsToText(xhtml, paragraphList); }
private void writeDirtyParagraphs(HSLFShapeContainer container) { for (HSLFShape sh : container.getShapes()) { if (sh instanceof HSLFShapeContainer) { writeDirtyParagraphs((HSLFShapeContainer)sh); } else if (sh instanceof HSLFTextShape) { HSLFTextShape hts = (HSLFTextShape)sh; boolean isDirty = false; for (HSLFTextParagraph p : hts.getTextParagraphs()) { isDirty |= p.isDirty(); } if (isDirty) { hts.storeText(); } } } }