gpt4 book ai didi

java - 如何从 Apache POI 演示文稿中获取 AnimationInfo

转载 作者:行者123 更新时间:2023-12-02 02:40:01 25 4
gpt4 key购买 nike

有一个名为AnimationInfo的类,它应该从Presentation中提供动画信息。但我运气不好,没能拿到。

List<XSLFShape> shapes = slide.getShapes();
for (XSLFShape shape: shapes) {
//Need to get animation of this shape here
}

有人可以帮我解决这个问题吗?谢谢。

PS:我使用的是 3.17 版本的 POI。

最佳答案

考虑到仅检测动画,可以检查工作表的计时信息,该信息很可能识别动画的存在,即,如果添加动画然后再次删除,您可能会得到误报。此外,您需要检查所有幻灯片,直到找到动画。

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);
}
}

关于java - 如何从 Apache POI 演示文稿中获取 AnimationInfo,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/45649724/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com