本文整理了Java中org.apache.poi.xslf.usermodel.XSLFSheet.getShapes()
方法的一些代码示例,展示了XSLFSheet.getShapes()
的具体用法。这些代码示例主要来源于Github
/Stackoverflow
/Maven
等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。XSLFSheet.getShapes()
方法的具体详情如下:
包路径:org.apache.poi.xslf.usermodel.XSLFSheet
类名称:XSLFSheet
方法名:getShapes
[英]Returns an array containing all of the shapes in this sheet
[中]返回包含此工作表中所有形状的数组
代码示例来源:origin: org.apache.poi/poi-ooxml
/**
* Returns an iterator over the shapes in this sheet
*
* @return an iterator over the shapes in this sheet
*/
@Override
public Iterator<XSLFShape> iterator(){
return getShapes().iterator();
}
代码示例来源:origin: org.apache.poi/poi-ooxml
@SuppressWarnings("WeakerAccess")
protected XSLFTextShape getTextShapeByType(Placeholder type){
for(XSLFShape shape : this.getShapes()){
if(shape instanceof XSLFTextShape) {
XSLFTextShape txt = (XSLFTextShape)shape;
if(txt.getTextType() == type) {
return txt;
}
}
}
return null;
}
代码示例来源:origin: org.apache.poi/poi-ooxml
/**
* Removes all of the elements from this container (optional operation).
* The container will be empty after this call returns.
*/
@Override
public void clear() {
List<XSLFShape> shapes = new ArrayList<>(getShapes());
for(XSLFShape shape : shapes){
removeShape(shape);
}
}
代码示例来源:origin: org.apache.poi/poi-ooxml
@Override
public List<List<XSLFTextParagraph>> getTextParagraphs() {
List<List<XSLFTextParagraph>> tp = new ArrayList<>();
for (XSLFShape sh : super.getShapes()) {
if (sh instanceof XSLFTextShape) {
XSLFTextShape txt = (XSLFTextShape)sh;
tp.add(txt.getTextParagraphs());
}
}
return tp;
}
}
代码示例来源:origin: org.apache.poi/poi-ooxml
private void wipeAndReinitialize(XSLFSheet src, int offset) {
// explicitly initialize drawing and shapes from _spTree
_shapes = null;
_drawing = null;
initDrawingAndShapes();
// placeholders will be implicitly initialized when requested
_placeholders = null;
// update each shape according to its own additional copy rules
List<XSLFShape> tgtShapes = getShapes();
List<XSLFShape> srcShapes = src.getShapes();
for(int i = 0; i < srcShapes.size(); i++){
XSLFShape s1 = srcShapes.get(i);
XSLFShape s2 = tgtShapes.get(offset + i);
s2.copy(s1);
}
}
代码示例来源:origin: org.apache.poi/poi-ooxml
@Override
public XSLFTextBox createTextBox(){
XSLFTextBox sh = getDrawing().createTextBox();
getShapes().add(sh);
sh.setParent(this);
return sh;
}
代码示例来源:origin: org.apache.poi/poi-ooxml
@Override
public XSLFAutoShape createAutoShape(){
XSLFAutoShape sh = getDrawing().createAutoShape();
getShapes().add(sh);
sh.setParent(this);
return sh;
}
代码示例来源:origin: org.apache.poi/poi-ooxml
public XSLFTable createTable(){
XSLFTable sh = getDrawing().createTable();
getShapes().add(sh);
sh.setParent(this);
return sh;
}
代码示例来源:origin: org.apache.poi/poi-ooxml
@Override
public XSLFFreeformShape createFreeform(){
XSLFFreeformShape sh = getDrawing().createFreeform();
getShapes().add(sh);
sh.setParent(this);
return sh;
}
代码示例来源:origin: org.apache.poi/poi-ooxml
@Override
public XSLFConnectorShape createConnector(){
XSLFConnectorShape sh = getDrawing().createConnector();
getShapes().add(sh);
sh.setParent(this);
return sh;
}
代码示例来源:origin: org.apache.poi/poi-ooxml
@Override
public XSLFGroupShape createGroup(){
XSLFGroupShape sh = getDrawing().createGroup();
getShapes().add(sh);
sh.setParent(this);
return sh;
}
代码示例来源:origin: org.apache.poi/poi-ooxml
@Override
public XSLFTable createTable(int numRows, int numCols){
if (numRows < 1 || numCols < 1) {
throw new IllegalArgumentException("numRows and numCols must be greater than 0");
}
XSLFTable sh = getDrawing().createTable();
getShapes().add(sh);
sh.setParent(this);
for (int r=0; r<numRows; r++) {
XSLFTableRow row = sh.addRow();
for (int c=0; c<numCols; c++) {
row.addCell();
}
}
return sh;
}
代码示例来源:origin: org.apache.poi/poi-ooxml
private void initPlaceholders() {
if(_placeholders == null) {
_placeholders = new ArrayList<>();
_placeholderByIdMap = new HashMap<>();
_placeholderByTypeMap = new HashMap<>();
for(final XSLFShape sh : getShapes()){
if(sh instanceof XSLFTextShape){
final XSLFTextShape sShape = (XSLFTextShape)sh;
final CTPlaceholder ph = sShape.getPlaceholderDetails().getCTPlaceholder(false);
if(ph != null) {
_placeholders.add(sShape);
if(ph.isSetIdx()) {
int idx = (int)ph.getIdx();
_placeholderByIdMap.put(idx, sShape);
}
if(ph.isSetType()){
_placeholderByTypeMap.put(ph.getType().intValue(), sShape);
}
}
}
}
}
}
代码示例来源:origin: org.apache.poi/poi-ooxml
@Override
public XSLFPictureShape createPicture(PictureData pictureData){
if (!(pictureData instanceof XSLFPictureData)) {
throw new IllegalArgumentException("pictureData needs to be of type XSLFPictureData");
}
RelationPart rp = addRelation(null, XSLFRelation.IMAGES, (XSLFPictureData)pictureData);
XSLFPictureShape sh = getDrawing().createPicture(rp.getRelationship().getId());
new DrawPictureShape(sh).resize();
getShapes().add(sh);
sh.setParent(this);
return sh;
}
代码示例来源:origin: org.apache.poi/poi-ooxml
throw new IllegalArgumentException("Unsupported shape: " + xShape);
return getShapes().remove(xShape);
代码示例来源:origin: org.apache.poi/poi-ooxml
@Override
public XSLFObjectShape createOleShape(PictureData pictureData) {
if (!(pictureData instanceof XSLFPictureData)) {
throw new IllegalArgumentException("pictureData needs to be of type XSLFPictureData");
}
RelationPart rp = addRelation(null, XSLFRelation.IMAGES, (XSLFPictureData)pictureData);
XSLFObjectShape sh = getDrawing().createOleShape(rp.getRelationship().getId());
CTOleObject oleObj = sh.getCTOleObject();
Dimension dim = pictureData.getImageDimension();
oleObj.setImgW(Units.toEMU(dim.getWidth()));
oleObj.setImgH(Units.toEMU(dim.getHeight()));
getShapes().add(sh);
sh.setParent(this);
return sh;
}
代码示例来源:origin: org.apache.poi/poi-ooxml
/**
* Helper method for sheet and group shapes
*
* @param pictureShape the picture shapes whose relation is to be removed,
* only if there are no more relations on its sheet to that picture
*/
void removePictureRelation(XSLFPictureShape pictureShape) {
int numberOfRelations = 0;
String targetBlipId = pictureShape.getBlipId();
for (XSLFShape shape : pictureShape.getSheet().getShapes()) {
if (shape instanceof XSLFPictureShape) {
XSLFPictureShape currentPictureShape = ((XSLFPictureShape) shape);
String currentBlipId = currentPictureShape.getBlipId();
if (currentBlipId != null && currentBlipId.equals(targetBlipId)) {
numberOfRelations++;
}
}
}
if (numberOfRelations <= 1) {
removeRelation(pictureShape.getBlipId());
}
}
代码示例来源:origin: org.apache.poi/poi-ooxml
/**
* Append content to this sheet.
*
* @param src the source sheet
* @return modified <code>this</code>.
*/
@SuppressWarnings("unused")
public XSLFSheet appendContent(XSLFSheet src){
int numShapes = getShapes().size();
CTGroupShape spTree = getSpTree();
CTGroupShape srcTree = src.getSpTree();
for(XmlObject ch : srcTree.selectPath("*")){
if(ch instanceof CTShape){ // simple shape
spTree.addNewSp().set(ch.copy());
} else if (ch instanceof CTGroupShape){
spTree.addNewGrpSp().set(ch.copy());
} else if (ch instanceof CTConnector){
spTree.addNewCxnSp().set(ch.copy());
} else if (ch instanceof CTPicture){
spTree.addNewPic().set(ch.copy());
} else if (ch instanceof CTGraphicalObjectFrame){
spTree.addNewGraphicFrame().set(ch.copy());
}
}
wipeAndReinitialize(src, numShapes);
return this;
}
代码示例来源:origin: apache/tika
extractContent(slideMaster.getShapes(), true, xhtml, null);
代码示例来源:origin: org.apache.servicemix.bundles/org.apache.servicemix.bundles.poi
@Override
public XSLFFreeformShape createFreeform(){
XSLFFreeformShape sh = getDrawing().createFreeform();
getShapes().add(sh);
sh.setParent(this);
return sh;
}
内容来源于网络,如有侵权,请联系作者删除!