有一个名为AnimationInfo的类,它应该从演示中提供动画信息。但我运气不好我没能得到。
List<XSLFShape> shapes = slide.getShapes();
for (XSLFShape shape: shapes) {
//Need to get animation of this shape here
}有人能帮我吗?谢谢。
PS:我正在使用3.17版本的POI。
发布于 2017-08-13 21:08:16
如果只检测动画,则可以检查工作表的时间信息,该信息很可能标识动画的存在,也就是说,在动画被添加并再次删除时,您可以获得假阳性。此外,您需要检查所有的幻灯片,直到找到一个动画。
import java.io.FileInputStream;
import org.apache.poi.hslf.record.Record;
import org.apache.poi.hslf.record.RecordContainer;
import org.apache.poi.hslf.record.RecordTypes;
import org.apache.poi.hslf.usermodel.HSLFSlide;
import org.apache.poi.sl.usermodel.Slide;
import org.apache.poi.sl.usermodel.SlideShow;
import org.apache.poi.sl.usermodel.SlideShowFactory;
import org.apache.poi.xslf.usermodel.XSLFSlide;
public class AnimCheck {
private static final int timingRecordPath[] = {
RecordTypes.ProgTags.typeID,
RecordTypes.ProgBinaryTag.typeID,
RecordTypes.BinaryTagData.typeID,
0xf144
};
public static void main(String[] args) throws Exception {
SlideShow<?,?> ppt = SlideShowFactory.create(new FileInputStream("no_anim.pptx"));
Slide<?,?> slide = ppt.getSlides().get(0);
boolean hasTiming;
if (slide instanceof XSLFSlide) {
XSLFSlide xsld = (XSLFSlide)slide;
hasTiming = xsld.getXmlObject().isSetTiming();
} else {
HSLFSlide hsld = (HSLFSlide)slide;
Record lastRecord = hsld.getSheetContainer();
boolean found = true;
for (int ri : timingRecordPath) {
lastRecord = ((RecordContainer)lastRecord).findFirstOfType(ri);
if (lastRecord == null) {
found = false;
break;
}
}
hasTiming = found;
}
ppt.close();
System.out.println(hasTiming);
}
}https://stackoverflow.com/questions/45649724
复制相似问题