if(fontSize == -1.0) {\r
if(rPr.isSetSz()) rPr.unsetSz();\r
} else {\r
+ if(fontSize < 1.0) {\r
+ throw new IllegalArgumentException("Minimum font size is 1pt but was " + fontSize);\r
+ }\r
+\r
rPr.setSz((int)(100*fontSize));\r
}\r
}\r
return fetcher.getValue() == null ? 0 : fetcher.getValue();\r
}\r
\r
+ /**\r
+ * Set the spacing between characters within a text run.\r
+ * <p>\r
+ * The spacing is specified in points. Positive values will cause the text to expand,\r
+ * negative values to condense.\r
+ * </p>\r
+ *\r
+ * @param spc character spacing in points.\r
+ */\r
+ public void setCharacterSpacing(double spc){\r
+ CTTextCharacterProperties rPr = getRpR();\r
+ if(spc == 0.0) {\r
+ if(rPr.isSetSpc()) rPr.unsetSpc();\r
+ } else {\r
+ rPr.setSpc((int)(100*spc));\r
+ }\r
+ }\r
+\r
/**\r
* Specifies the typeface, or name of the font that is to be used for this text run.\r
*\r
--- /dev/null
+/*\r
+ * ====================================================================\r
+ * Licensed to the Apache Software Foundation (ASF) under one or more\r
+ * contributor license agreements. See the NOTICE file distributed with\r
+ * this work for additional information regarding copyright ownership.\r
+ * The ASF licenses this file to You under the Apache License, Version 2.0\r
+ * (the "License"); you may not use this file except in compliance with\r
+ * the License. You may obtain a copy of the License at\r
+ *\r
+ * http://www.apache.org/licenses/LICENSE-2.0\r
+ *\r
+ * Unless required by applicable law or agreed to in writing, software\r
+ * distributed under the License is distributed on an "AS IS" BASIS,\r
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\r
+ * See the License for the specific language governing permissions and\r
+ * limitations under the License.\r
+ * ====================================================================\r
+ */\r
+package org.apache.poi.xslf.usermodel;\r
+\r
+import junit.framework.TestCase;\r
+import org.apache.poi.util.POILogFactory;\r
+import org.apache.poi.util.POILogger;\r
+import org.apache.poi.xslf.XSLFTestDataSamples;\r
+\r
+import java.awt.*;\r
+import java.awt.geom.Rectangle2D;\r
+import java.awt.image.BufferedImage;\r
+import java.util.List;\r
+\r
+/**\r
+ * @author Yegor Kozlov\r
+ */\r
+public class TestXSLFTextRun extends TestCase {\r
+\r
+ public void testRunProperties(){\r
+ XMLSlideShow ppt = new XMLSlideShow();\r
+ XSLFSlide slide = ppt.createSlide();\r
+ XSLFTextShape sh = slide.createAutoShape();\r
+\r
+ XSLFTextRun r = sh.addNewTextParagraph().addNewTextRun();\r
+ assertEquals("en-US", r.getRpR().getLang());\r
+\r
+ assertEquals(0., r.getCharacterSpacing());\r
+ r.setCharacterSpacing(3);\r
+ assertEquals(3., r.getCharacterSpacing());\r
+ r.setCharacterSpacing(-3);\r
+ assertEquals(-3., r.getCharacterSpacing());\r
+ r.setCharacterSpacing(0);\r
+ assertEquals(0., r.getCharacterSpacing());\r
+ assertFalse(r.getRpR().isSetSpc());\r
+\r
+ assertEquals(Color.black, r.getFontColor());\r
+ r.setFontColor(Color.red);\r
+ assertEquals(Color.red, r.getFontColor());\r
+\r
+ assertEquals("Calibri", r.getFontFamily());\r
+ r.setFontFamily("Arial");\r
+ assertEquals("Arial", r.getFontFamily());\r
+\r
+ assertEquals(18.0, r.getFontSize());\r
+ r.setFontSize(13.0);\r
+ assertEquals(13.0, r.getFontSize());\r
+\r
+ }\r
+}\r