You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

TestXSLFTextRun.java 2.9KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980
  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.apache.poi.sl.TestCommonSL.sameColor;
  21. import static org.junit.Assert.assertEquals;
  22. import static org.junit.Assert.assertFalse;
  23. import static org.junit.Assert.assertTrue;
  24. import java.awt.Color;
  25. import java.io.IOException;
  26. import org.junit.Test;
  27. /**
  28. * @author Yegor Kozlov
  29. */
  30. public class TestXSLFTextRun {
  31. @Test
  32. public void testRunProperties() throws IOException {
  33. XMLSlideShow ppt = new XMLSlideShow();
  34. XSLFSlide slide = ppt.createSlide();
  35. XSLFTextShape sh = slide.createAutoShape();
  36. XSLFTextRun r = sh.addNewTextParagraph().addNewTextRun();
  37. assertEquals("en-US", r.getRPr(true).getLang());
  38. assertEquals(0., r.getCharacterSpacing(), 0);
  39. r.setCharacterSpacing(3);
  40. assertEquals(3., r.getCharacterSpacing(), 0);
  41. r.setCharacterSpacing(-3);
  42. assertEquals(-3., r.getCharacterSpacing(), 0);
  43. r.setCharacterSpacing(0);
  44. assertEquals(0., r.getCharacterSpacing(), 0);
  45. assertFalse(r.getRPr(true).isSetSpc());
  46. assertTrue(sameColor(Color.black, r.getFontColor()));
  47. r.setFontColor(Color.red);
  48. assertTrue(sameColor(Color.red, r.getFontColor()));
  49. assertEquals("Calibri", r.getFontFamily());
  50. r.setFontFamily("Arial");
  51. assertEquals("Arial", r.getFontFamily());
  52. assertEquals(18.0, r.getFontSize(), 0);
  53. r.setFontSize(13.0);
  54. assertEquals(13.0, r.getFontSize(), 0);
  55. assertEquals(false, r.isSuperscript());
  56. r.setSuperscript(true);
  57. assertEquals(true, r.isSuperscript());
  58. r.setSuperscript(false);
  59. assertEquals(false, r.isSuperscript());
  60. assertEquals(false, r.isSubscript());
  61. r.setSubscript(true);
  62. assertEquals(true, r.isSubscript());
  63. r.setSubscript(false);
  64. assertEquals(false, r.isSubscript());
  65. ppt.close();
  66. }
  67. }