選択できるのは25トピックまでです。 トピックは、先頭が英数字で、英数字とダッシュ('-')を使用した35文字以内のものにしてください。

TestXSLFSlideShow.java 3.9KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108
  1. /* ====================================================================
  2. Licensed to the Apache Software Foundation (ASF) under one or more
  3. contributor license agreements. See the NOTICE file distributed with
  4. this work for additional information regarding copyright ownership.
  5. The ASF licenses this file to You under the Apache License, Version 2.0
  6. (the "License"); you may not use this file except in compliance with
  7. the License. You may obtain a copy of the License at
  8. http://www.apache.org/licenses/LICENSE-2.0
  9. Unless required by applicable law or agreed to in writing, software
  10. distributed under the License is distributed on an "AS IS" BASIS,
  11. WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
  12. See the License for the specific language governing permissions and
  13. limitations under the License.
  14. ==================================================================== */
  15. package org.apache.poi.xslf.usermodel;
  16. import junit.framework.TestCase;
  17. import java.awt.Dimension;
  18. import java.util.List;
  19. import org.apache.poi.POIXMLDocumentPart;
  20. import org.apache.poi.xslf.XSLFTestDataSamples;
  21. /**
  22. * @author Yegor Kozlov
  23. */
  24. public class TestXSLFSlideShow extends TestCase {
  25. public void testCreateSlide(){
  26. XMLSlideShow ppt = new XMLSlideShow();
  27. assertEquals(0, ppt.getSlides().length);
  28. XSLFSlide slide1 = ppt.createSlide();
  29. assertEquals(1, ppt.getSlides().length);
  30. assertSame(slide1, ppt.getSlides()[0]);
  31. List<POIXMLDocumentPart> rels = slide1.getRelations();
  32. assertEquals(1, rels.size());
  33. assertEquals(slide1.getSlideMaster().getLayout(SlideLayout.BLANK), rels.get(0));
  34. XSLFSlide slide2 = ppt.createSlide();
  35. assertEquals(2, ppt.getSlides().length);
  36. assertSame(slide2, ppt.getSlides()[1]);
  37. ppt.setSlideOrder(slide2, 0);
  38. assertSame(slide2, ppt.getSlides()[0]);
  39. assertSame(slide1, ppt.getSlides()[1]);
  40. ppt = XSLFTestDataSamples.writeOutAndReadBack(ppt);
  41. assertEquals(2, ppt.getSlides().length);
  42. rels = ppt.getSlides()[0].getRelations();
  43. }
  44. public void testRemoveSlide(){
  45. XMLSlideShow ppt = new XMLSlideShow();
  46. assertEquals(0, ppt.getSlides().length);
  47. XSLFSlide slide1 = ppt.createSlide();
  48. XSLFSlide slide2 = ppt.createSlide();
  49. assertEquals(2, ppt.getSlides().length);
  50. assertSame(slide1, ppt.getSlides()[0]);
  51. assertSame(slide2, ppt.getSlides()[1]);
  52. XSLFSlide removedSlide = ppt.removeSlide(0);
  53. assertSame(slide1, removedSlide);
  54. assertEquals(1, ppt.getSlides().length);
  55. assertSame(slide2, ppt.getSlides()[0]);
  56. ppt = XSLFTestDataSamples.writeOutAndReadBack(ppt);
  57. assertEquals(1, ppt.getSlides().length);
  58. }
  59. public void testDimension(){
  60. XMLSlideShow ppt = new XMLSlideShow();
  61. Dimension sz = ppt.getPageSize();
  62. assertEquals(720, sz.width);
  63. assertEquals(540, sz.height);
  64. ppt.setPageSize(new Dimension(792, 612));
  65. sz = ppt.getPageSize();
  66. assertEquals(792, sz.width);
  67. assertEquals(612, sz.height);
  68. }
  69. public void testSlideMasters(){
  70. XMLSlideShow ppt = new XMLSlideShow();
  71. XSLFSlideMaster[] masters = ppt.getSlideMasters();
  72. assertEquals(1, masters.length);
  73. XSLFSlide slide = ppt.createSlide();
  74. assertSame(masters[0], slide.getSlideMaster());
  75. }
  76. public void testSlideLayout(){
  77. XMLSlideShow ppt = new XMLSlideShow();
  78. XSLFSlideMaster[] masters = ppt.getSlideMasters();
  79. assertEquals(1, masters.length);
  80. XSLFSlide slide = ppt.createSlide();
  81. XSLFSlideLayout layout = slide.getSlideLayout();
  82. assertNotNull(layout);
  83. assertSame(masters[0], layout.getSlideMaster());
  84. }
  85. }