我需要一个powerpoint循环,直到用户按下退出键。通过在powerpoint的幻灯片放映设置选项中选中“连续循环直到'ESC'”选项后保存并解压缩文件,我得到了更改的文件的差异(ppt/presProps.xml)。
未修复:
<p:presentationPr xmlns:p="http://schemas.openxmlformats.org/presentationml/2006/main" xmlns:a="http://schemas.openxmlformats.org/drawingml/2006/main" xmlns:r="http://schemas.openxmlformats.org/officeDocument/2006/relationships">
<p:showPr showNarration="1">
<p:present />
<p:sldAll />
<p:penClr>
<a:prstClr val="red" />
</p:penClr>
<p:extLst>
<p:ext uri="{EC167BDD-8182-4AB7-AECC-EB403E3ABB37}">
<p14:laserClr xmlns:p14="http://schemas.microsoft.com/office/powerpoint/2010/main">
<a:srgbClr val="FF0000" />
</p14:laserClr>
</p:ext>
<p:ext uri="{2FDB2607-1784-4EEB-B798-7EB5836EED8A}">
<p14:showMediaCtrls xmlns:p14="http://schemas.microsoft.com/office/powerpoint/2010/main" val="1" />
</p:ext>
</p:extLst>
</p:showPr>
<p:extLst>
<p:ext uri="{E76CE94A-603C-4142-B9EB-6D1370010A27}">
<p14:discardImageEditData xmlns:p14="http://schemas.microsoft.com/office/powerpoint/2010/main" val="0" />
</p:ext>
<p:ext uri="{D31A062A-798A-4329-ABDD-BBA856620510}">
<p14:defaultImageDpi xmlns:p14="http://schemas.microsoft.com/office/powerpoint/2010/main" val="220" />
</p:ext>
<p:ext uri="{FD5EFAAD-0ECE-453E-9831-46B23BE46B34}">
<p15:chartTrackingRefBased xmlns:p15="http://schemas.microsoft.com/office/powerpoint/2012/main" val="0" />
</p:ext>
</p:extLst>
</p:presentationPr>已修复:
<p:presentationPr xmlns:p="http://schemas.openxmlformats.org/presentationml/2006/main" xmlns:a="http://schemas.openxmlformats.org/drawingml/2006/main" xmlns:r="http://schemas.openxmlformats.org/officeDocument/2006/relationships">
<p:showPr loop="1" showNarration="1">
<p:present />
<p:sldAll />
<p:penClr>
<a:prstClr val="red" />
</p:penClr>
<p:extLst>
<p:ext uri="{EC167BDD-8182-4AB7-AECC-EB403E3ABB37}">
<p14:laserClr xmlns:p14="http://schemas.microsoft.com/office/powerpoint/2010/main">
<a:srgbClr val="FF0000" />
</p14:laserClr>
</p:ext>
<p:ext uri="{2FDB2607-1784-4EEB-B798-7EB5836EED8A}">
<p14:showMediaCtrls xmlns:p14="http://schemas.microsoft.com/office/powerpoint/2010/main" val="1" />
</p:ext>
</p:extLst>
</p:showPr>
<p:extLst>
<p:ext uri="{E76CE94A-603C-4142-B9EB-6D1370010A27}">
<p14:discardImageEditData xmlns:p14="http://schemas.microsoft.com/office/powerpoint/2010/main" val="0" />
</p:ext>
<p:ext uri="{D31A062A-798A-4329-ABDD-BBA856620510}">
<p14:defaultImageDpi xmlns:p14="http://schemas.microsoft.com/office/powerpoint/2010/main" val="220" />
</p:ext>
<p:ext uri="{FD5EFAAD-0ECE-453E-9831-46B23BE46B34}">
<p15:chartTrackingRefBased xmlns:p15="http://schemas.microsoft.com/office/powerpoint/2012/main" val="0" />
</p:ext>
</p:extLst>
</p:presentationPr>元素差异:
3c3
< <p:showPr showNarration="1">
---
> <p:showPr loop="1" showNarration="1">它看起来像是在presentation元素中的p元素上,但是我不知道如何在POI中设置该属性。
发布于 2018-03-13 07:32:32
这只是一个快速的技巧,以显示包部分的修改,这些修改不能通过API访问。由于XmlBeans将循环属性设置为"true"而不是"1",因此可能需要通过XmlCursor API设置它。
public static void main(String[] args) throws Exception {
OPCPackage opc = OPCPackage.open("headers.pptx", PackageAccess.READ_WRITE);
try (XMLSlideShow ppt = new XMLSlideShow(opc)) {
PackagePart presProps = ppt.getPackage().getPart(PackagingURIHelper.createPartName("/ppt/presProps.xml"));
PresentationPrDocument doc = PresentationPrDocument.Factory.parse(presProps.getInputStream());
CTPresentationProperties pr = doc.getPresentationPr();
CTShowProperties showPr = pr.isSetShowPr() ? pr.getShowPr() : pr.addNewShowPr();
showPr.setLoop(true);
presProps.clear();
try (OutputStream os = presProps.getOutputStream()) {
doc.save(os);
}
}
}https://stackoverflow.com/questions/49240059
复制相似问题