Du kannst nicht mehr als 25 Themen auswählen Themen müssen mit entweder einem Buchstaben oder einer Ziffer beginnen. Sie können Bindestriche („-“) enthalten und bis zu 35 Zeichen lang sein.

TestPPTX2PNG.java 3.7KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293
  1. /*
  2. * ====================================================================
  3. * Licensed to the Apache Software Foundation (ASF) under one or more
  4. * contributor license agreements. See the NOTICE file distributed with
  5. * this work for additional information regarding copyright ownership.
  6. * The ASF licenses this file to You under the Apache License, Version 2.0
  7. * (the "License"); you may not use this file except in compliance with
  8. * the License. You may obtain a copy of the License at
  9. *
  10. * http://www.apache.org/licenses/LICENSE-2.0
  11. *
  12. * Unless required by applicable law or agreed to in writing, software
  13. * distributed under the License is distributed on an "AS IS" BASIS,
  14. * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
  15. * See the License for the specific language governing permissions and
  16. * limitations under the License.
  17. * ====================================================================
  18. */
  19. package org.apache.poi.xslf.usermodel;
  20. import static org.junit.Assume.assumeFalse;
  21. import java.io.File;
  22. import java.util.Collection;
  23. import java.util.function.Function;
  24. import java.util.stream.Collectors;
  25. import java.util.stream.Stream;
  26. import org.apache.poi.POIDataSamples;
  27. import org.apache.poi.xslf.util.PPTX2PNG;
  28. import org.junit.BeforeClass;
  29. import org.junit.Test;
  30. import org.junit.runner.RunWith;
  31. import org.junit.runners.Parameterized;
  32. import org.junit.runners.Parameterized.Parameter;
  33. import org.junit.runners.Parameterized.Parameters;
  34. /**
  35. * Test class for testing PPTX2PNG utility which renders .ppt and .pptx slideshows
  36. */
  37. @RunWith(Parameterized.class)
  38. public class TestPPTX2PNG {
  39. private static boolean xslfOnly;
  40. private static final POIDataSamples samples = POIDataSamples.getSlideShowInstance();
  41. private static final File basedir = null;
  42. private static final String files =
  43. "53446.ppt, alterman_security.ppt, alterman_security.pptx, KEY02.pptx, themes.pptx, " +
  44. "backgrounds.pptx, layouts.pptx, sample.pptx, shapes.pptx, 54880_chinese.ppt, keyframes.pptx," +
  45. "customGeo.pptx, customGeo.ppt, wrench.emf, santa.wmf, missing-moveto.ppt";
  46. @BeforeClass
  47. public static void checkHslf() {
  48. try {
  49. Class.forName("org.apache.poi.hslf.usermodel.HSLFSlideShow");
  50. } catch (Exception e) {
  51. xslfOnly = true;
  52. }
  53. }
  54. // use filename instead of File object to omit full pathname in test name
  55. @Parameter
  56. public String pptFile;
  57. @SuppressWarnings("ConstantConditions")
  58. @Parameters(name="{0}")
  59. public static Collection<String> data() {
  60. Function<String, Stream<String>> fun = (basedir == null) ? Stream::of :
  61. (f) -> Stream.of(basedir.listFiles(p -> p.getName().matches(f))).map(File::getName);
  62. return Stream.of(files.split(", ?")).flatMap(fun).collect(Collectors.toList());
  63. }
  64. @Test
  65. public void render() throws Exception {
  66. assumeFalse("ignore HSLF (.ppt) / HEMF (.emf) / HWMF (.wmf) files in no-scratchpad run", xslfOnly && pptFile.matches(".*\\.(ppt|emf|wmf)$"));
  67. String[] args = {
  68. "-format", "null", // png,gif,jpg or null for test
  69. "-slide", "-1", // -1 for all
  70. "-outdir", new File("build/tmp/").getCanonicalPath(),
  71. "-outpat", "${basename}-${slideno}-${ext}.${format}",
  72. // "-dump", new File("build/tmp/", pptFile+".json").getCanonicalPath(),
  73. "-dump", "null",
  74. "-quiet",
  75. "-fixside", "long",
  76. "-scale", "800",
  77. // "-scale", "1.333333333",
  78. (basedir == null ? samples.getFile(pptFile) : new File(basedir, pptFile)).getAbsolutePath()
  79. };
  80. PPTX2PNG.main(args);
  81. }
  82. }