void processShapes(List<XSSFShape> shapes, StringBuilder text) { if (shapes == null) { return; } for (XSSFShape shape : shapes) { if (shape instanceof XSSFSimpleShape) { String sText = ((XSSFSimpleShape) shape).getText(); if (sText != null && sText.length() > 0) { text.append(sText).append('\n'); } } } }
/** * Creates a simple shape. This includes such shapes as lines, rectangles, * and ovals. * * @param anchor the child anchor describes how this shape is attached * to the group. * @return the newly created shape. */ public XSSFSimpleShape createSimpleShape(XSSFChildAnchor anchor) { CTShape ctShape = ctGroup.addNewSp(); ctShape.set(XSSFSimpleShape.prototype()); XSSFSimpleShape shape = new XSSFSimpleShape(getDrawing(), ctShape); shape.parent = this; shape.anchor = anchor; shape.setXfrm(anchor.getCTTransform2D()); return shape; }
/** * Set a single paragraph of text on the shape. Note this will replace all * existing paragraphs created on the shape. * * @param text * string representing the paragraph text */ public void setText(String text) { clearText(); addNewTextParagraph().addNewTextRun().setText(text); }
out.append(getBulletPrefix(scheme, levelCount.get(level))); out.append(p.getText()); out.append('\n'); index = processAutoNumGroup(index + 1, nextp.getLevel(), levelCount, out); continue; // restart the loop given the new index } else if (nextp.getLevel() < level) { out.append(getBulletPrefix(nextScheme, levelCount.get(level))); out.append(nextp.getText());
/** * Creates a simple shape. This includes such shapes as lines, rectangles, * and ovals. * * @param anchor the child anchor describes how this shape is attached * to the group. * @return the newly created shape. */ public XSSFSimpleShape createSimpleShape(XSSFChildAnchor anchor) { CTShape ctShape = ctGroup.addNewSp(); ctShape.set(XSSFSimpleShape.prototype()); XSSFSimpleShape shape = new XSSFSimpleShape(getDrawing(), ctShape); shape.parent = this; shape.anchor = anchor; shape.getCTShape().getSpPr().setXfrm(anchor.getCTTransform2D()); return shape; }
for (XSSFShape shape : shapes) { if (shape instanceof XSSFSimpleShape) { String sText = ((XSSFSimpleShape) shape).getText(); if (sText != null && sText.length() > 0) { xhtml.element("p", sText); extractHyperLinksFromShape(((XSSFSimpleShape)shape).getCTShape(), xhtml);
XSSFWorkbook wb = (XSSFWorkbook) getDrawing().getParent().getParent(); str.setStylesTableReference(wb.getStylesSource()); rPr.setLang("en-US"); applyAttributes(ltPr, rPr); clearText(); ctShape.getTxBody().setPArray(new CTTextParagraph[] { p }); _paragraphs.add(new XSSFTextParagraph(ctShape.getTxBody().getPArray(0), ctShape));
shape.setShapeType(ShapeTypes.LINE); shape.setLineWidth(1.5); shape.setLineStyle(3); shape.setLineStyleColor(0,0,255); shape.getCTShape().getNvSpPr().getCNvPr().setId(shape.getCTShape().getNvSpPr().getCNvPr().getId()-1); CTShapeProperties shapeProperties = shape.getCTShape().getSpPr(); CTLineProperties lineProperties = shapeProperties.getLn();
/** * Creates a simple shape. This includes such shapes as lines, rectangles, * and ovals. * * @param anchor * the client anchor describes how this group is attached to the * sheet. * @return the newly created shape. */ public XSSFSimpleShape createSimpleShape(XSSFClientAnchor anchor) { long shapeId = newShapeId(); CTTwoCellAnchor ctAnchor = createTwoCellAnchor(anchor); CTShape ctShape = ctAnchor.addNewSp(); ctShape.set(XSSFSimpleShape.prototype()); ctShape.getNvSpPr().getCNvPr().setId(shapeId); ctShape.getSpPr().setXfrm(createXfrm(anchor)); XSSFSimpleShape shape = new XSSFSimpleShape(this, ctShape); shape.anchor = anchor; return shape; }
/** * Constructs a textbox. * * @param anchor the child anchor describes how this shape is attached * to the group. * @return the newly created textbox. */ public XSSFTextBox createTextbox(XSSFChildAnchor anchor){ CTShape ctShape = ctGroup.addNewSp(); ctShape.set(XSSFSimpleShape.prototype()); XSSFTextBox shape = new XSSFTextBox(getDrawing(), ctShape); shape.parent = this; shape.anchor = anchor; shape.setXfrm(anchor.getCTTransform2D()); return shape; } /**
public void setText(XSSFRichTextString str){ XSSFWorkbook wb = (XSSFWorkbook)getDrawing().getParent().getParent(); str.setStylesTableReference(wb.getStylesSource()); CTTextParagraph p = CTTextParagraph.Factory.newInstance(); if(str.numFormattingRuns() == 0){ CTRegularTextRun r = p.addNewR(); CTTextCharacterProperties rPr = r.addNewRPr(); rPr.setLang("en-US"); rPr.setSz(1100); r.setT(str.getString()); } else { for (int i = 0; i < str.getCTRst().sizeOfRArray(); i++) { CTRElt lt = str.getCTRst().getRArray(i); CTRPrElt ltPr = lt.getRPr(); if(ltPr == null) ltPr = lt.addNewRPr(); CTRegularTextRun r = p.addNewR(); CTTextCharacterProperties rPr = r.addNewRPr(); rPr.setLang("en-US"); applyAttributes(ltPr, rPr); r.setT(lt.getT()); } } ctShape.getTxBody().setPArray(new CTTextParagraph[]{p}); }
} else if (obj instanceof CTShape) { shape = hasOleLink(obj) ? new XSSFObjectData(this, (CTShape) obj) : new XSSFSimpleShape(this, (CTShape) obj); } else if (obj instanceof CTGraphicalObjectFrame) { shape = new XSSFGraphicFrame(this, (CTGraphicalObjectFrame) obj);
rPr.setLang("en-US"); applyAttributes(ltPr, rPr);
/** * Add a new paragraph run to this shape, set to the provided string * * @return created paragraph run */ public XSSFTextParagraph addNewTextParagraph(String text) { XSSFTextParagraph paragraph = addNewTextParagraph(); paragraph.addNewTextRun().setText(text); return paragraph; }
i = processAutoNumGroup(i, level, levelCount, out); } else {
private void processShapes(List<XSSFShape> shapes, XHTMLContentHandler xhtml) throws SAXException { if (shapes == null) { return; } for (XSSFShape shape : shapes) { if (shape instanceof XSSFSimpleShape) { String sText = ((XSSFSimpleShape) shape).getText(); if (sText != null && sText.length() > 0) { xhtml.element("p", sText); } extractHyperLinksFromShape(((XSSFSimpleShape)shape).getCTShape(), xhtml); } } }
XSSFWorkbook wb = (XSSFWorkbook) getDrawing().getParent().getParent(); str.setStylesTableReference(wb.getStylesSource()); rPr.setLang("en-US"); applyAttributes(ltPr, rPr); clearText(); ctShape.getTxBody().setPArray(new CTTextParagraph[] { p }); _paragraphs.add(new XSSFTextParagraph(ctShape.getTxBody().getPArray(0), ctShape));
/** * Creates a simple shape. This includes such shapes as lines, rectangles, * and ovals. * * @param anchor the client anchor describes how this group is attached * to the sheet. * @return the newly created shape. */ public XSSFSimpleShape createSimpleShape(XSSFClientAnchor anchor) { long shapeId = newShapeId(); CTTwoCellAnchor ctAnchor = createTwoCellAnchor(anchor); CTShape ctShape = ctAnchor.addNewSp(); ctShape.set(XSSFSimpleShape.prototype()); ctShape.getNvSpPr().getCNvPr().setId(shapeId); XSSFSimpleShape shape = new XSSFSimpleShape(this, ctShape); shape.anchor = anchor; return shape; }
/** * Constructs a textbox under the drawing. * * @param anchor * the client anchor describes how this group is attached to the * sheet. * @return the newly created textbox. */ public XSSFTextBox createTextbox(XSSFClientAnchor anchor) { long shapeId = newShapeId(); CTTwoCellAnchor ctAnchor = createTwoCellAnchor(anchor); CTShape ctShape = ctAnchor.addNewSp(); ctShape.set(XSSFSimpleShape.prototype()); ctShape.getNvSpPr().getCNvPr().setId(shapeId); XSSFTextBox shape = new XSSFTextBox(this, ctShape); shape.anchor = anchor; return shape; }
out.append(getBulletPrefix(scheme, levelCount.get(level))); out.append(p.getText()); out.append('\n'); index = processAutoNumGroup(index + 1, nextp.getLevel(), levelCount, out); continue; // restart the loop given the new index } else if (nextp.getLevel() < level) { out.append(getBulletPrefix(nextScheme, levelCount.get(level))); out.append(nextp.getText());