You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@poi.apache.org by ye...@apache.org on 2012/01/25 08:53:07 UTC
svn commit: r1235668 - in /poi/trunk/src/ooxml:
java/org/apache/poi/xslf/usermodel/ testcases/org/apache/poi/xslf/usermodel/
Author: yegor
Date: Wed Jan 25 07:53:07 2012
New Revision: 1235668
URL: http://svn.apache.org/viewvc?rev=1235668&view=rev
Log:
support kerning in XSLF text runs
Added:
poi/trunk/src/ooxml/testcases/org/apache/poi/xslf/usermodel/TestXSLFTextRun.java
Modified:
poi/trunk/src/ooxml/java/org/apache/poi/xslf/usermodel/XSLFTextParagraph.java
poi/trunk/src/ooxml/java/org/apache/poi/xslf/usermodel/XSLFTextRun.java
poi/trunk/src/ooxml/testcases/org/apache/poi/xslf/usermodel/TestXSLFTextParagraph.java
Modified: poi/trunk/src/ooxml/java/org/apache/poi/xslf/usermodel/XSLFTextParagraph.java
URL: http://svn.apache.org/viewvc/poi/trunk/src/ooxml/java/org/apache/poi/xslf/usermodel/XSLFTextParagraph.java?rev=1235668&r1=1235667&r2=1235668&view=diff
==============================================================================
--- poi/trunk/src/ooxml/java/org/apache/poi/xslf/usermodel/XSLFTextParagraph.java (original)
+++ poi/trunk/src/ooxml/java/org/apache/poi/xslf/usermodel/XSLFTextParagraph.java Wed Jan 25 07:53:07 2012
@@ -117,7 +117,8 @@ public class XSLFTextParagraph implement
public XSLFTextRun addNewTextRun(){
CTRegularTextRun r = _p.addNewR();
- r.addNewRPr();
+ CTTextCharacterProperties rPr = r.addNewRPr();
+ rPr.setLang("en-US");
XSLFTextRun run = new XSLFTextRun(r, this);
_runs.add(run);
return run;
Modified: poi/trunk/src/ooxml/java/org/apache/poi/xslf/usermodel/XSLFTextRun.java
URL: http://svn.apache.org/viewvc/poi/trunk/src/ooxml/java/org/apache/poi/xslf/usermodel/XSLFTextRun.java?rev=1235668&r1=1235667&r2=1235668&view=diff
==============================================================================
--- poi/trunk/src/ooxml/java/org/apache/poi/xslf/usermodel/XSLFTextRun.java (original)
+++ poi/trunk/src/ooxml/java/org/apache/poi/xslf/usermodel/XSLFTextRun.java Wed Jan 25 07:53:07 2012
@@ -167,6 +167,10 @@ public class XSLFTextRun {
if(fontSize == -1.0) {
if(rPr.isSetSz()) rPr.unsetSz();
} else {
+ if(fontSize < 1.0) {
+ throw new IllegalArgumentException("Minimum font size is 1pt but was " + fontSize);
+ }
+
rPr.setSz((int)(100*fontSize));
}
}
@@ -213,6 +217,24 @@ public class XSLFTextRun {
}
/**
+ * Set the spacing between characters within a text run.
+ * <p>
+ * The spacing is specified in points. Positive values will cause the text to expand,
+ * negative values to condense.
+ * </p>
+ *
+ * @param spc character spacing in points.
+ */
+ public void setCharacterSpacing(double spc){
+ CTTextCharacterProperties rPr = getRpR();
+ if(spc == 0.0) {
+ if(rPr.isSetSpc()) rPr.unsetSpc();
+ } else {
+ rPr.setSpc((int)(100*spc));
+ }
+ }
+
+ /**
* Specifies the typeface, or name of the font that is to be used for this text run.
*
* @param typeface the font to apply to this text run.
Modified: poi/trunk/src/ooxml/testcases/org/apache/poi/xslf/usermodel/TestXSLFTextParagraph.java
URL: http://svn.apache.org/viewvc/poi/trunk/src/ooxml/testcases/org/apache/poi/xslf/usermodel/TestXSLFTextParagraph.java?rev=1235668&r1=1235667&r2=1235668&view=diff
==============================================================================
--- poi/trunk/src/ooxml/testcases/org/apache/poi/xslf/usermodel/TestXSLFTextParagraph.java (original)
+++ poi/trunk/src/ooxml/testcases/org/apache/poi/xslf/usermodel/TestXSLFTextParagraph.java Wed Jan 25 07:53:07 2012
@@ -27,11 +27,7 @@ import java.awt.image.BufferedImage;
import java.util.List;
/**
- * Created by IntelliJ IDEA.
- * User: yegor
- * Date: Nov 10, 2011
- * Time: 1:43:25 PM
- * To change this template use File | Settings | File Templates.
+ * @author Yegor Kozlov
*/
public class TestXSLFTextParagraph extends TestCase {
private static POILogger _logger = POILogFactory.getLogger(XSLFTextParagraph.class);
Added: poi/trunk/src/ooxml/testcases/org/apache/poi/xslf/usermodel/TestXSLFTextRun.java
URL: http://svn.apache.org/viewvc/poi/trunk/src/ooxml/testcases/org/apache/poi/xslf/usermodel/TestXSLFTextRun.java?rev=1235668&view=auto
==============================================================================
--- poi/trunk/src/ooxml/testcases/org/apache/poi/xslf/usermodel/TestXSLFTextRun.java (added)
+++ poi/trunk/src/ooxml/testcases/org/apache/poi/xslf/usermodel/TestXSLFTextRun.java Wed Jan 25 07:53:07 2012
@@ -0,0 +1,66 @@
+/*
+ * ====================================================================
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ * ====================================================================
+ */
+package org.apache.poi.xslf.usermodel;
+
+import junit.framework.TestCase;
+import org.apache.poi.util.POILogFactory;
+import org.apache.poi.util.POILogger;
+import org.apache.poi.xslf.XSLFTestDataSamples;
+
+import java.awt.*;
+import java.awt.geom.Rectangle2D;
+import java.awt.image.BufferedImage;
+import java.util.List;
+
+/**
+ * @author Yegor Kozlov
+ */
+public class TestXSLFTextRun extends TestCase {
+
+ public void testRunProperties(){
+ XMLSlideShow ppt = new XMLSlideShow();
+ XSLFSlide slide = ppt.createSlide();
+ XSLFTextShape sh = slide.createAutoShape();
+
+ XSLFTextRun r = sh.addNewTextParagraph().addNewTextRun();
+ assertEquals("en-US", r.getRpR().getLang());
+
+ assertEquals(0., r.getCharacterSpacing());
+ r.setCharacterSpacing(3);
+ assertEquals(3., r.getCharacterSpacing());
+ r.setCharacterSpacing(-3);
+ assertEquals(-3., r.getCharacterSpacing());
+ r.setCharacterSpacing(0);
+ assertEquals(0., r.getCharacterSpacing());
+ assertFalse(r.getRpR().isSetSpc());
+
+ assertEquals(Color.black, r.getFontColor());
+ r.setFontColor(Color.red);
+ assertEquals(Color.red, r.getFontColor());
+
+ assertEquals("Calibri", r.getFontFamily());
+ r.setFontFamily("Arial");
+ assertEquals("Arial", r.getFontFamily());
+
+ assertEquals(18.0, r.getFontSize());
+ r.setFontSize(13.0);
+ assertEquals(13.0, r.getFontSize());
+
+ }
+}
---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@poi.apache.org
For additional commands, e-mail: commits-help@poi.apache.org