poi-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From ye...@apache.org
Subject svn commit: r1233242 - in /poi/trunk/src/ooxml: java/org/apache/poi/xslf/usermodel/XSLFTextParagraph.java testcases/org/apache/poi/xslf/usermodel/TestXSLFSlide.java testcases/org/apache/poi/xslf/usermodel/TestXSLFTextParagraph.java
Date Thu, 19 Jan 2012 08:09:26 GMT
Author: yegor
Date: Thu Jan 19 08:09:26 2012
New Revision: 1233242

URL: http://svn.apache.org/viewvc?rev=1233242&view=rev
Log:
more XSLF tests to ensure that poi-ooxml-schemas.jar contains all used classes

Modified:
    poi/trunk/src/ooxml/java/org/apache/poi/xslf/usermodel/XSLFTextParagraph.java
    poi/trunk/src/ooxml/testcases/org/apache/poi/xslf/usermodel/TestXSLFSlide.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=1233242&r1=1233241&r2=1233242&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 Thu Jan
19 08:09:26 2012
@@ -211,6 +211,11 @@ public class XSLFTextParagraph implement
         c.setChar(str);
     }
 
+    /**
+     *
+     * @return the color of bullet characters within a given paragraph.
+     * A <code>null</code> value means to use the text font color.
+     */
     public Color getBulletFontColor(){
         final XSLFTheme theme = getParentShape().getSheet().getTheme();
         ParagraphPropertyFetcher<Color> fetcher = new ParagraphPropertyFetcher<Color>(getLevel()){
@@ -227,6 +232,11 @@ public class XSLFTextParagraph implement
         return fetcher.getValue();
     }
 
+    /**
+     * Set the color to be used on bullet characters within a given paragraph.
+     *
+     * @param color the bullet color
+     */
     public void setBulletFontColor(Color color){
         CTTextParagraphProperties pr = _p.isSetPPr() ? _p.getPPr() : _p.addNewPPr();
         CTColor c = pr.isSetBuClr() ? pr.getBuClr() : pr.addNewBuClr();
@@ -234,6 +244,16 @@ public class XSLFTextParagraph implement
         clr.setVal(new byte[]{(byte) color.getRed(), (byte) color.getGreen(), (byte) color.getBlue()});
     }
 
+    /**
+     * Returns the bullet size that is to be used within a paragraph.
+     * This may be specified in two different ways, percentage spacing and font point spacing:
+     * <p>
+     * If bulletSize >= 0, then bulletSize is a percentage of the font size.
+     * If bulletSize < 0, then it specifies the size in points
+     * </p>
+     *
+     * @return the bullet size
+     */
     public double getBulletFontSize(){
         ParagraphPropertyFetcher<Double> fetcher = new ParagraphPropertyFetcher<Double>(getLevel()){
             public boolean fetch(CTTextParagraphProperties props){
@@ -252,12 +272,29 @@ public class XSLFTextParagraph implement
         return fetcher.getValue() == null ? 100 : fetcher.getValue();
     }
 
-    public void setBulletFontSize(double size){
+    /**
+     * Sets the bullet size that is to be used within a paragraph.
+     * This may be specified in two different ways, percentage spacing and font point spacing:
+     * <p>
+     * If bulletSize >= 0, then bulletSize is a percentage of the font size.
+     * If bulletSize < 0, then it specifies the size in points
+     * </p>
+     *
+     * @return the bullet size
+     */
+    public void setBulletFontSize(double bulletSize){
         CTTextParagraphProperties pr = _p.isSetPPr() ? _p.getPPr() : _p.addNewPPr();
-        CTTextBulletSizePoint pt = pr.isSetBuSzPts() ? pr.getBuSzPts() : pr.addNewBuSzPts();
-        pt.setVal((int)(size*1000));
-        if(pr.isSetBuSzPct()) pr.unsetBuSzPct();
-    }
+
+        if(bulletSize >= 0) {
+            CTTextBulletSizePercent pt = pr.isSetBuSzPct() ? pr.getBuSzPct() : pr.addNewBuSzPct();
+            pt.setVal((int)(bulletSize*1000));
+            if(pr.isSetBuSzPts()) pr.unsetBuSzPts();
+        } else {
+            CTTextBulletSizePoint pt = pr.isSetBuSzPts() ? pr.getBuSzPts() : pr.addNewBuSzPts();
+            pt.setVal((int)(-bulletSize*100));
+            if(pr.isSetBuSzPct()) pr.unsetBuSzPct();
+        }
+   }
 
     /**
      * Specifies the indent size that will be applied to the first line of text in the paragraph.
@@ -302,7 +339,12 @@ public class XSLFTextParagraph implement
      */
     public void setLeftMargin(double value){
         CTTextParagraphProperties pr = _p.isSetPPr() ? _p.getPPr() : _p.addNewPPr();
-        pr.setMarL(Units.toEMU(value));
+        if(value == -1) {
+            if(pr.isSetMarL()) pr.unsetMarL();
+        } else {
+            pr.setMarL(Units.toEMU(value));
+        }
+
     }
 
     /**
@@ -327,7 +369,7 @@ public class XSLFTextParagraph implement
 
     /**
      *
-     * @return the default size for a tab character within this paragraph
+     * @return the default size for a tab character within this paragraph in points
      */
     public double getDefaultTabSize(){
         ParagraphPropertyFetcher<Double> fetcher = new ParagraphPropertyFetcher<Double>(getLevel()){

Modified: poi/trunk/src/ooxml/testcases/org/apache/poi/xslf/usermodel/TestXSLFSlide.java
URL: http://svn.apache.org/viewvc/poi/trunk/src/ooxml/testcases/org/apache/poi/xslf/usermodel/TestXSLFSlide.java?rev=1233242&r1=1233241&r2=1233242&view=diff
==============================================================================
--- poi/trunk/src/ooxml/testcases/org/apache/poi/xslf/usermodel/TestXSLFSlide.java (original)
+++ poi/trunk/src/ooxml/testcases/org/apache/poi/xslf/usermodel/TestXSLFSlide.java Thu Jan
19 08:09:26 2012
@@ -20,6 +20,7 @@ import junit.framework.TestCase;
 import org.apache.poi.xslf.XSLFTestDataSamples;
 
 import java.awt.Color;
+import java.io.FileInputStream;
 import java.util.Arrays;
 
 /**
@@ -159,4 +160,18 @@ public class TestXSLFSlide extends TestC
         XSLFPictureShape srcPic = (XSLFPictureShape)src.getSlides()[4].getShapes()[1];
         assertTrue(Arrays.equals(sh4.getPictureData().getData(), srcPic.getPictureData().getData()));
     }
+
+    public void testMergeSlides(){
+        XMLSlideShow ppt = new XMLSlideShow();
+        String[] pptx = {"shapes.pptx", "themes.pptx", "layouts.pptx", "backgrounds.pptx"};
+
+        for(String arg : pptx){
+            XMLSlideShow  src = XSLFTestDataSamples.openSampleDocument(arg);
+
+            for(XSLFSlide srcSlide : src.getSlides()){
+                ppt.createSlide().importContent(srcSlide);
+            }
+        }
+        assertEquals(30, ppt.getSlides().length);
+    }    
 }
\ No newline at end of file

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=1233242&r1=1233241&r2=1233242&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
Thu Jan 19 08:09:26 2012
@@ -219,7 +219,79 @@ public class TestXSLFTextParagraph exten
         XSLFTextShape sh3 = (XSLFTextShape)shapes[2];
         assertEquals("Foundation", sh3.getText());
         assertEquals(TextAlign.CENTER, sh3.getTextParagraphs().get(0).getTextAlign());
+    }
+
+    public void testParagraphProperties(){
+        XMLSlideShow ppt = new XMLSlideShow();
+        XSLFSlide slide = ppt.createSlide();
+        XSLFTextShape sh = slide.createAutoShape();
+
+        XSLFTextParagraph p = sh.addNewTextParagraph();
+        assertFalse(p.isBullet());
+        p.setBullet(true);
+        assertTrue(p.isBullet());
+
+        assertEquals("\u2022", p.getBulletCharacter());
+        p.setBulletCharacter("*");
+        assertEquals("*", p.getBulletCharacter());
+
+        assertEquals("Arial", p.getBulletFont());
+        p.setBulletFont("Calibri");
+        assertEquals("Calibri", p.getBulletFont());
+
+        assertEquals(null, p.getBulletFontColor());
+        p.setBulletFontColor(Color.red);
+        assertEquals(Color.red, p.getBulletFontColor());
+
+        assertEquals(100.0, p.getBulletFontSize());
+        p.setBulletFontSize(200.);
+        assertEquals(200., p.getBulletFontSize());
+        p.setBulletFontSize(-20.);
+        assertEquals(-20.0, p.getBulletFontSize());
+
+        assertEquals(72.0, p.getDefaultTabSize());
+        
+        assertEquals(0.0, p.getIndent());
+        p.setIndent(72.0);
+        assertEquals(72.0, p.getIndent());
+        p.setIndent(-1.0); // the value of -1.0 resets to the defaults
+        assertEquals(0.0, p.getIndent());
+
+        assertEquals(0.0, p.getLeftMargin());
+        p.setLeftMargin(72.0);
+        assertEquals(72.0, p.getLeftMargin());
+        p.setLeftMargin(-1.0); // the value of -1.0 resets to the defaults
+        assertEquals(0.0, p.getLeftMargin());
+
+        assertEquals(0, p.getLevel());
+        p.setLevel(1);
+        assertEquals(1, p.getLevel());
+        p.setLevel(2);
+        assertEquals(2, p.getLevel());
+
+        assertEquals(100., p.getLineSpacing());
+        p.setLineSpacing(200.);
+        assertEquals(200.0, p.getLineSpacing());
+        p.setLineSpacing(-15.);
+        assertEquals(-15.0, p.getLineSpacing());
+
+        assertEquals(0., p.getSpaceAfter());
+        p.setSpaceAfter(200.);
+        assertEquals(200.0, p.getSpaceAfter());
+        p.setSpaceAfter(-15.);
+        assertEquals(-15.0, p.getSpaceAfter());
+
+        assertEquals(0., p.getSpaceBefore());
+        p.setSpaceBefore(200.);
+        assertEquals(200.0, p.getSpaceBefore());
+        p.setSpaceBefore(-15.);
+        assertEquals(-15.0, p.getSpaceBefore());
 
+        assertEquals(TextAlign.LEFT, p.getTextAlign());
+        p.setTextAlign(TextAlign.RIGHT);
+        assertEquals(TextAlign.RIGHT, p.getTextAlign());
 
+        p.setBullet(false);
+        assertFalse(p.isBullet());
     }
 }



---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@poi.apache.org
For additional commands, e-mail: commits-help@poi.apache.org


Mime
View raw message