Java XSLFGroupShape不包含其子形状

Java XSLFGroupShape不包含其子形状,java,apache-poi,xslf,Java,Apache Poi,Xslf,我正在使用ApachePOI3.16(撰写本文时的最新版本)。在以下代码段中,我创建了一个XSLFGroupShape,然后用它创建了一组子形状: XSLFGroupShape group = slide.createGroup(); XSLFAutoShape cardRect = group.createAutoShape(); cardRect.setShapeType(ShapeType.RECT); cardRect.setAnchor(rect); XSLFPictureShap

我正在使用ApachePOI3.16(撰写本文时的最新版本)。在以下代码段中,我创建了一个XSLFGroupShape,然后用它创建了一组子形状:

XSLFGroupShape group = slide.createGroup();

XSLFAutoShape cardRect = group.createAutoShape();
cardRect.setShapeType(ShapeType.RECT);
cardRect.setAnchor(rect);

XSLFPictureShape avatarShape = group.createPicture(avatar);

// More shapes added to the group here...
问题在于:在生成的PowerPoint文件中,组位置和尺寸似乎未初始化(我选择了内容为像素化的矩形;整个矩形及其内容是单个XSLFGroupShape;请注意幻灯片左上角的组操纵器):


我的代码中有什么遗漏吗?有没有办法绕过或解决此问题?

GroupShape需要一个
定位点和一个
内部定位点
。并且分组的形状必须适合
GroupShape
PowerPoint
GUI在用户使用组时自动管理这些内容。但是
apachepoi
需要正确的设置,因为它只是将程序所说的内容写入文件

示例:一个宽度为350、高度为300、左侧为100、顶部为50的组形状以及每个角上的一个简单形状

import java.io.FileOutputStream;

import org.apache.poi.xslf.usermodel.*;
import org.apache.poi.sl.usermodel.*;

import java.awt.Rectangle;
import java.awt.Color;

public class CreatePPTXGroupShape {

 public static void main(String[] args) throws Exception {

  SlideShow slideShow = new XMLSlideShow();

  Slide slide = slideShow.createSlide();

  int groupLeft = 100;
  int groupTop = 50;
  int groupWidth = 350;
  int groupHeight = 300;
  int groupPadding= 10;

  GroupShape group = slide.createGroup();
  group.setInteriorAnchor(new Rectangle(groupLeft, groupTop, groupWidth, groupHeight));
  group.setAnchor(new Rectangle(groupLeft+groupPadding, groupTop+groupPadding, groupWidth-groupPadding, groupHeight-groupPadding));

  AutoShape shape = group.createAutoShape();
  shape.setShapeType(ShapeType.RECT);
  shape.setFillColor(Color.GREEN);
  shape.setAnchor(new Rectangle(groupLeft, groupTop, 150, 100));

  shape = group.createAutoShape();
  shape.setShapeType(ShapeType.TRIANGLE);
  shape.setFillColor(Color.RED);
  shape.setAnchor(new Rectangle(groupLeft+groupWidth-120, groupTop, 120, 100));

  shape = group.createAutoShape();
  shape.setShapeType(ShapeType.DONUT);
  shape.setFillColor(Color.YELLOW);
  shape.setAnchor(new Rectangle(groupLeft, groupTop+groupHeight-90, 90, 90));

  shape = group.createAutoShape();
  shape.setShapeType(ShapeType.ELLIPSE);
  shape.setFillColor(Color.BLUE);
  shape.setAnchor(new Rectangle(groupLeft+groupWidth-100, groupTop+groupHeight-100, 100, 100));

  FileOutputStream out = new FileOutputStream("CreatePPTXGroupShape.pptx");
  slideShow.write(out);
  out.close();
 }
}