c.setChar(str);\r
}\r
\r
+ /**\r
+ *\r
+ * @return the color of bullet characters within a given paragraph.\r
+ * A <code>null</code> value means to use the text font color.\r
+ */\r
public Color getBulletFontColor(){\r
final XSLFTheme theme = getParentShape().getSheet().getTheme();\r
ParagraphPropertyFetcher<Color> fetcher = new ParagraphPropertyFetcher<Color>(getLevel()){\r
return fetcher.getValue();\r
}\r
\r
+ /**\r
+ * Set the color to be used on bullet characters within a given paragraph.\r
+ *\r
+ * @param color the bullet color\r
+ */\r
public void setBulletFontColor(Color color){\r
CTTextParagraphProperties pr = _p.isSetPPr() ? _p.getPPr() : _p.addNewPPr();\r
CTColor c = pr.isSetBuClr() ? pr.getBuClr() : pr.addNewBuClr();\r
clr.setVal(new byte[]{(byte) color.getRed(), (byte) color.getGreen(), (byte) color.getBlue()});\r
}\r
\r
+ /**\r
+ * Returns the bullet size that is to be used within a paragraph.\r
+ * This may be specified in two different ways, percentage spacing and font point spacing:\r
+ * <p>\r
+ * If bulletSize >= 0, then bulletSize is a percentage of the font size.\r
+ * If bulletSize < 0, then it specifies the size in points\r
+ * </p>\r
+ *\r
+ * @return the bullet size\r
+ */\r
public double getBulletFontSize(){\r
ParagraphPropertyFetcher<Double> fetcher = new ParagraphPropertyFetcher<Double>(getLevel()){\r
public boolean fetch(CTTextParagraphProperties props){\r
return fetcher.getValue() == null ? 100 : fetcher.getValue();\r
}\r
\r
- public void setBulletFontSize(double size){\r
+ /**\r
+ * Sets the bullet size that is to be used within a paragraph.\r
+ * This may be specified in two different ways, percentage spacing and font point spacing:\r
+ * <p>\r
+ * If bulletSize >= 0, then bulletSize is a percentage of the font size.\r
+ * If bulletSize < 0, then it specifies the size in points\r
+ * </p>\r
+ *\r
+ * @return the bullet size\r
+ */\r
+ public void setBulletFontSize(double bulletSize){\r
CTTextParagraphProperties pr = _p.isSetPPr() ? _p.getPPr() : _p.addNewPPr();\r
- CTTextBulletSizePoint pt = pr.isSetBuSzPts() ? pr.getBuSzPts() : pr.addNewBuSzPts();\r
- pt.setVal((int)(size*1000));\r
- if(pr.isSetBuSzPct()) pr.unsetBuSzPct();\r
- }\r
+\r
+ if(bulletSize >= 0) {\r
+ CTTextBulletSizePercent pt = pr.isSetBuSzPct() ? pr.getBuSzPct() : pr.addNewBuSzPct();\r
+ pt.setVal((int)(bulletSize*1000));\r
+ if(pr.isSetBuSzPts()) pr.unsetBuSzPts();\r
+ } else {\r
+ CTTextBulletSizePoint pt = pr.isSetBuSzPts() ? pr.getBuSzPts() : pr.addNewBuSzPts();\r
+ pt.setVal((int)(-bulletSize*100));\r
+ if(pr.isSetBuSzPct()) pr.unsetBuSzPct();\r
+ }\r
+ }\r
\r
/**\r
* Specifies the indent size that will be applied to the first line of text in the paragraph.\r
*/\r
public void setLeftMargin(double value){\r
CTTextParagraphProperties pr = _p.isSetPPr() ? _p.getPPr() : _p.addNewPPr();\r
- pr.setMarL(Units.toEMU(value));\r
+ if(value == -1) {\r
+ if(pr.isSetMarL()) pr.unsetMarL();\r
+ } else {\r
+ pr.setMarL(Units.toEMU(value));\r
+ }\r
+\r
}\r
\r
/**\r
\r
/**\r
*\r
- * @return the default size for a tab character within this paragraph\r
+ * @return the default size for a tab character within this paragraph in points\r
*/\r
public double getDefaultTabSize(){\r
ParagraphPropertyFetcher<Double> fetcher = new ParagraphPropertyFetcher<Double>(getLevel()){\r
import org.apache.poi.xslf.XSLFTestDataSamples;\r
\r
import java.awt.Color;\r
+import java.io.FileInputStream;\r
import java.util.Arrays;\r
\r
/**\r
XSLFPictureShape srcPic = (XSLFPictureShape)src.getSlides()[4].getShapes()[1];\r
assertTrue(Arrays.equals(sh4.getPictureData().getData(), srcPic.getPictureData().getData()));\r
}\r
+\r
+ public void testMergeSlides(){\r
+ XMLSlideShow ppt = new XMLSlideShow();\r
+ String[] pptx = {"shapes.pptx", "themes.pptx", "layouts.pptx", "backgrounds.pptx"};\r
+\r
+ for(String arg : pptx){\r
+ XMLSlideShow src = XSLFTestDataSamples.openSampleDocument(arg);\r
+\r
+ for(XSLFSlide srcSlide : src.getSlides()){\r
+ ppt.createSlide().importContent(srcSlide);\r
+ }\r
+ }\r
+ assertEquals(30, ppt.getSlides().length);\r
+ } \r
}
\ No newline at end of file
XSLFTextShape sh3 = (XSLFTextShape)shapes[2];\r
assertEquals("Foundation", sh3.getText());\r
assertEquals(TextAlign.CENTER, sh3.getTextParagraphs().get(0).getTextAlign());\r
+ }\r
\r
+ public void testParagraphProperties(){\r
+ XMLSlideShow ppt = new XMLSlideShow();\r
+ XSLFSlide slide = ppt.createSlide();\r
+ XSLFTextShape sh = slide.createAutoShape();\r
\r
+ XSLFTextParagraph p = sh.addNewTextParagraph();\r
+ assertFalse(p.isBullet());\r
+ p.setBullet(true);\r
+ assertTrue(p.isBullet());\r
+\r
+ assertEquals("\u2022", p.getBulletCharacter());\r
+ p.setBulletCharacter("*");\r
+ assertEquals("*", p.getBulletCharacter());\r
+\r
+ assertEquals("Arial", p.getBulletFont());\r
+ p.setBulletFont("Calibri");\r
+ assertEquals("Calibri", p.getBulletFont());\r
+\r
+ assertEquals(null, p.getBulletFontColor());\r
+ p.setBulletFontColor(Color.red);\r
+ assertEquals(Color.red, p.getBulletFontColor());\r
+\r
+ assertEquals(100.0, p.getBulletFontSize());\r
+ p.setBulletFontSize(200.);\r
+ assertEquals(200., p.getBulletFontSize());\r
+ p.setBulletFontSize(-20.);\r
+ assertEquals(-20.0, p.getBulletFontSize());\r
+\r
+ assertEquals(72.0, p.getDefaultTabSize());\r
+ \r
+ assertEquals(0.0, p.getIndent());\r
+ p.setIndent(72.0);\r
+ assertEquals(72.0, p.getIndent());\r
+ p.setIndent(-1.0); // the value of -1.0 resets to the defaults\r
+ assertEquals(0.0, p.getIndent());\r
+\r
+ assertEquals(0.0, p.getLeftMargin());\r
+ p.setLeftMargin(72.0);\r
+ assertEquals(72.0, p.getLeftMargin());\r
+ p.setLeftMargin(-1.0); // the value of -1.0 resets to the defaults\r
+ assertEquals(0.0, p.getLeftMargin());\r
+\r
+ assertEquals(0, p.getLevel());\r
+ p.setLevel(1);\r
+ assertEquals(1, p.getLevel());\r
+ p.setLevel(2);\r
+ assertEquals(2, p.getLevel());\r
+\r
+ assertEquals(100., p.getLineSpacing());\r
+ p.setLineSpacing(200.);\r
+ assertEquals(200.0, p.getLineSpacing());\r
+ p.setLineSpacing(-15.);\r
+ assertEquals(-15.0, p.getLineSpacing());\r
+\r
+ assertEquals(0., p.getSpaceAfter());\r
+ p.setSpaceAfter(200.);\r
+ assertEquals(200.0, p.getSpaceAfter());\r
+ p.setSpaceAfter(-15.);\r
+ assertEquals(-15.0, p.getSpaceAfter());\r
+\r
+ assertEquals(0., p.getSpaceBefore());\r
+ p.setSpaceBefore(200.);\r
+ assertEquals(200.0, p.getSpaceBefore());\r
+ p.setSpaceBefore(-15.);\r
+ assertEquals(-15.0, p.getSpaceBefore());\r
+\r
+ assertEquals(TextAlign.LEFT, p.getTextAlign());\r
+ p.setTextAlign(TextAlign.RIGHT);\r
+ assertEquals(TextAlign.RIGHT, p.getTextAlign());\r
+\r
+ p.setBullet(false);\r
+ assertFalse(p.isBullet());\r
}\r
}\r