<li><link href="#Shapes">Drawing a shape on a slide</link></li>\r
<li><link href="#Pictures">How to work with pictures</link></li>\r
<li><link href="#SlideTitle">How to set slide title</link></li>\r
+ <li><link href="#Fill">How to work with slide/shape background</link></li>\r
</ul>\r
</section>\r
<section><title>Features</title>\r
myDocument.Shapes.AddTitle.TextFrame.TextRange.Text = "Hello, World!"\r
</source>\r
</section>\r
+ <anchor id="Fill"/>\r
+ <section><title>How to modify background of a slide master</title>\r
+ <source>\r
+ SlideShow ppt = new SlideShow();\r
+ SlideMaster master = ppt.getSlidesMasters()[0];\r
+\r
+ Fill fill = master.getBackground().getFill();\r
+ int idx = ppt.addPicture(new File("background.png"), Picture.PNG);\r
+ fill.setFillType(Fill.FILL_PICTURE);\r
+ fill.setPictureData(idx);\r
+ </source>\r
+ </section>\r
+ <section><title>How to modify background of a slide</title>\r
+ <source>\r
+ SlideShow ppt = new SlideShow();\r
+ Slide slide = ppt.createSlide();\r
+ \r
+ //This slide has its own background. \r
+ //Without this line it will use master's background.\r
+ slide.setFollowMasterBackground(false);\r
+ Fill fill = slide.getBackground().getFill();\r
+ int idx = ppt.addPicture(new File("background.png"), Picture.PNG);\r
+ fill.setFillType(Fill.FILL_PATTERN);\r
+ fill.setPictureData(idx);\r
+ </source>\r
+ </section>\r
+ <section><title>How to modify background of a shape</title>\r
+ <source>\r
+ SlideShow ppt = new SlideShow();\r
+ Slide slide = ppt.createSlide();\r
+ \r
+ Shape shape = new AutoShape(ShapeTypes.Rectangle);\r
+ shape.setAnchor(new java.awt.Rectangle(100, 100, 200, 200));\r
+ Fill fill = shape.getFill();\r
+ fill.setFillType(Fill.FILL_SHADE);\r
+ fill.setBackgroundColor(Color.red);\r
+ fill.setForegroundColor(Color.green);\r
+ \r
+ slide.addShape(shape);\r
+ </source>\r
+ </section>\r
\r
</section>\r
</section>\r
--- /dev/null
+\r
+/* ====================================================================\r
+ Copyright 2002-2004 Apache Software Foundation\r
+\r
+ Licensed under the Apache License, Version 2.0 (the "License");\r
+ you may not use this file except in compliance with the License.\r
+ 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.hslf.model;\r
+\r
+import org.apache.poi.ddf.EscherContainerRecord;\r
+\r
+/**\r
+ * Background shape\r
+ * \r
+ * @author Yegor Kozlov\r
+ */\r
+public class Background extends Shape {\r
+\r
+ protected Background(EscherContainerRecord escherRecord, Shape parent){\r
+ super(escherRecord, parent);\r
+ }\r
+\r
+ protected EscherContainerRecord createSpContainer(boolean isChild){\r
+ return null;\r
+ }\r
+\r
+}\r
--- /dev/null
+\r
+/* ====================================================================\r
+ Copyright 2002-2004 Apache Software Foundation\r
+\r
+ Licensed under the Apache License, Version 2.0 (the "License");\r
+ you may not use this file except in compliance with the License.\r
+ 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.hslf.model;\r
+\r
+import org.apache.poi.ddf.*;\r
+import org.apache.poi.hslf.record.*;\r
+import org.apache.poi.hslf.usermodel.PictureData;\r
+import org.apache.poi.hslf.usermodel.SlideShow;\r
+\r
+import java.awt.*;\r
+import java.util.*;\r
+\r
+/**\r
+ * Represents functionality provided by the 'Fill Effects' dialog in PowerPoint.\r
+ *\r
+ * @author Yegor Kozlov\r
+ */\r
+public class Fill {\r
+ /**\r
+ * Fill with a solid color\r
+ */\r
+ public static final int FILL_SOLID = 0;\r
+\r
+ /**\r
+ * Fill with a pattern (bitmap)\r
+ */\r
+ public static final int FILL_PATTERN = 1;\r
+\r
+ /**\r
+ * A texture (pattern with its own color map)\r
+ */\r
+ public static final int FILL_TEXTURE = 2;\r
+\r
+ /**\r
+ * Center a picture in the shape\r
+ */\r
+ public static final int FILL_PICTURE = 3;\r
+\r
+ /**\r
+ * Shade from start to end points\r
+ */\r
+ public static final int FILL_SHADE = 4;\r
+\r
+ /**\r
+ * Shade from bounding rectangle to end point\r
+ */\r
+ public static final int FILL_SHADE_CENTER = 5;\r
+\r
+ /**\r
+ * Shade from shape outline to end point\r
+ */\r
+ public static final int FILL_SHADE_SHAPE = 6;\r
+\r
+ /**\r
+ * Similar to FILL_SHADE, but the fill angle\r
+ * is additionally scaled by the aspect ratio of\r
+ * the shape. If shape is square, it is the same as FILL_SHADE\r
+ */\r
+ public static final int FILL_SHADE_SCALE = 7;\r
+\r
+ /**\r
+ * shade to title\r
+ */\r
+ public static final int FILL_SHADE_TITLE = 8;\r
+\r
+ /**\r
+ * Use the background fill color/pattern\r
+ */\r
+ public static final int FILL_BACKGROUND = 9;\r
+\r
+\r
+\r
+ /**\r
+ * The shape this background applies to\r
+ */\r
+ protected Shape shape;\r
+\r
+ /**\r
+ * Construct a <code>Fill</code> object for a shape.\r
+ * Fill information will be read from shape's escher properties.\r
+ *\r
+ * @param shape the shape this background applies to\r
+ */\r
+ public Fill(Shape shape){\r
+ this.shape = shape;\r
+ }\r
+\r
+ /**\r
+ * Returns fill type.\r
+ * Must be one of the <code>FILL_*</code> constants defined in this class.\r
+ *\r
+ * @return type of fill\r
+ */\r
+ public int getFillType(){\r
+ EscherOptRecord opt = (EscherOptRecord)Shape.getEscherChild(shape.getSpContainer(), EscherOptRecord.RECORD_ID);\r
+ EscherSimpleProperty prop = (EscherSimpleProperty)Shape.getEscherProperty(opt, EscherProperties.FILL__FILLTYPE);\r
+ return prop == null ? FILL_SOLID : prop.getPropertyValue();\r
+ }\r
+\r
+ /**\r
+ * Sets fill type.\r
+ * Must be one of the <code>FILL_*</code> constants defined in this class.\r
+ *\r
+ * @param type type of the fill\r
+ */\r
+ public void setFillType(int type){\r
+ EscherOptRecord opt = (EscherOptRecord)Shape.getEscherChild(shape.getSpContainer(), EscherOptRecord.RECORD_ID);\r
+ Shape.setEscherProperty(opt, EscherProperties.FILL__FILLTYPE, type);\r
+ }\r
+\r
+ /**\r
+ * Foreground color\r
+ */\r
+ public Color getForegroundColor(){\r
+ EscherOptRecord opt = (EscherOptRecord)Shape.getEscherChild(shape.getSpContainer(), EscherOptRecord.RECORD_ID);\r
+ EscherSimpleProperty p1 = (EscherSimpleProperty)Shape.getEscherProperty(opt, EscherProperties.FILL__FILLCOLOR);\r
+ EscherSimpleProperty p2 = (EscherSimpleProperty)Shape.getEscherProperty(opt, EscherProperties.FILL__NOFILLHITTEST);\r
+\r
+ int p2val = p2 == null ? 0 : p2.getPropertyValue();\r
+\r
+ Color clr = null;\r
+ if (p1 != null && (p2val & 0x10) != 0){\r
+ int rgb = p1.getPropertyValue();\r
+ clr = shape.getColor(rgb);\r
+ }\r
+ return clr;\r
+ }\r
+\r
+ /**\r
+ * Foreground color\r
+ */\r
+ public void setForegroundColor(Color color){\r
+ EscherOptRecord opt = (EscherOptRecord)Shape.getEscherChild(shape.getSpContainer(), EscherOptRecord.RECORD_ID);\r
+ if (color == null) {\r
+ Shape.setEscherProperty(opt, EscherProperties.FILL__FILLCOLOR, -1);\r
+ }\r
+ else {\r
+ int rgb = new Color(color.getBlue(), color.getGreen(), color.getRed(), 0).getRGB();\r
+ Shape.setEscherProperty(opt, EscherProperties.FILL__FILLCOLOR, rgb);\r
+ }\r
+ }\r
+\r
+ /**\r
+ * Background color\r
+ */\r
+ public Color getBackgroundColor(){\r
+ EscherOptRecord opt = (EscherOptRecord)Shape.getEscherChild(shape.getSpContainer(), EscherOptRecord.RECORD_ID);\r
+ EscherSimpleProperty p1 = (EscherSimpleProperty)Shape.getEscherProperty(opt, EscherProperties.FILL__FILLBACKCOLOR);\r
+ EscherSimpleProperty p2 = (EscherSimpleProperty)Shape.getEscherProperty(opt, EscherProperties.FILL__NOFILLHITTEST);\r
+\r
+ int p2val = p2 == null ? 0 : p2.getPropertyValue();\r
+\r
+ Color clr = null;\r
+ if (p1 != null && (p2val & 0x10) != 0){\r
+ int rgb = p1.getPropertyValue();\r
+ clr = shape.getColor(rgb);\r
+ }\r
+ return clr;\r
+ }\r
+\r
+ /**\r
+ * Background color\r
+ */\r
+ public void setBackgroundColor(Color color){\r
+ EscherOptRecord opt = (EscherOptRecord)Shape.getEscherChild(shape.getSpContainer(), EscherOptRecord.RECORD_ID);\r
+ if (color == null) {\r
+ Shape.setEscherProperty(opt, EscherProperties.FILL__FILLBACKCOLOR, -1);\r
+ }\r
+ else {\r
+ int rgb = new Color(color.getBlue(), color.getGreen(), color.getRed(), 0).getRGB();\r
+ Shape.setEscherProperty(opt, EscherProperties.FILL__FILLBACKCOLOR, rgb);\r
+ }\r
+ }\r
+\r
+ /**\r
+ * <code>PictureData</code> object used in a texture, pattern of picture fill.\r
+ */\r
+ public PictureData getPictureData(){\r
+ EscherOptRecord opt = (EscherOptRecord)Shape.getEscherChild(shape.getSpContainer(), EscherOptRecord.RECORD_ID);\r
+ EscherSimpleProperty p = (EscherSimpleProperty)Shape.getEscherProperty(opt, EscherProperties.FILL__PATTERNTEXTURE);\r
+ if (p == null) return null;\r
+\r
+ SlideShow ppt = shape.getSheet().getSlideShow();\r
+ PictureData[] pict = ppt.getPictureData();\r
+ Document doc = ppt.getDocumentRecord();\r
+\r
+ EscherContainerRecord dggContainer = doc.getPPDrawingGroup().getDggContainer();\r
+ EscherContainerRecord bstore = (EscherContainerRecord)Shape.getEscherChild(dggContainer, EscherContainerRecord.BSTORE_CONTAINER);\r
+\r
+ java.util.List lst = bstore.getChildRecords();\r
+ int idx = p.getPropertyValue();\r
+ EscherBSERecord bse = (EscherBSERecord)lst.get(idx);\r
+ for ( int i = 0; i < pict.length; i++ ) {\r
+ if (pict[i].getOffset() == bse.getOffset()){\r
+ return pict[i];\r
+ }\r
+ }\r
+ throw new RuntimeException("Picture data not found: \n" +\r
+ " bse: " + bse + " at " + bse.getOffset() );\r
+\r
+ }\r
+\r
+ /**\r
+ * Assign picture used to fill the underlying shape.\r
+ *\r
+ * @param idx 0-based index of the picture added to this ppt by <code>SlideShow.addPicture</code> method. \r
+ */\r
+ public void setPictureData(int idx){\r
+ EscherOptRecord opt = (EscherOptRecord)Shape.getEscherChild(shape.getSpContainer(), EscherOptRecord.RECORD_ID);\r
+ Shape.setEscherProperty(opt, (short)(EscherProperties.FILL__PATTERNTEXTURE + 0x4000), idx);\r
+ }\r
+\r
+}\r
\r
import org.apache.poi.ddf.*;\r
import org.apache.poi.hslf.model.ShapeTypes;\r
+import org.apache.poi.hslf.record.ColorSchemeAtom;\r
+\r
import java.util.Iterator;\r
+import java.awt.*;\r
\r
/**\r
* <p>\r
_sheet = sheet;\r
}\r
\r
+ protected Color getColor(int rgb){\r
+ if (rgb >= 0x8000000) {\r
+ int idx = rgb - 0x8000000;\r
+ ColorSchemeAtom ca = getSheet().getColorScheme();\r
+ if(idx >= 0 && idx <= 7) rgb = ca.getColor(idx);\r
+ }\r
+ Color tmp = new Color(rgb, true);\r
+ return new Color(tmp.getBlue(), tmp.getGreen(), tmp.getRed());\r
+ }\r
+\r
+ /**\r
+ * Fill properties of this shape\r
+ *\r
+ * @return fill properties of this shape\r
+ */\r
+ public Fill getFill(){\r
+ return new Fill(this);\r
+ }\r
+\r
}\r
package org.apache.poi.hslf.model;
import java.util.Vector;
+import java.util.List;
+import java.util.Iterator;
+import java.util.ArrayList;
import org.apache.poi.hslf.record.PPDrawing;
import org.apache.poi.hslf.record.SlideAtom;
import org.apache.poi.hslf.record.TextHeaderAtom;
import org.apache.poi.hslf.record.ColorSchemeAtom;
import org.apache.poi.hslf.record.SlideListWithText.SlideAtomsSet;
+import org.apache.poi.ddf.EscherContainerRecord;
+import org.apache.poi.ddf.EscherRecord;
/**
* This class represents a slide in a PowerPoint Document. It allows
* the text side of things though
*
* @author Nick Burch
+ * @author Yegor Kozlov
*/
public class Slide extends Sheet
private TextRun[] _runs;
private TextRun[] _otherRuns; // Any from the PPDrawing, shouldn't really be any though
private Notes _notes; // usermodel needs to set this
+ private Background _background;
/**
* Constructs a Slide from the Slide record, and the SlideAtomsSet
return _slide.getColorScheme();
}
+ /**
+ * Returns the background shape for this sheet.
+ *
+ * @return the background shape for this sheet.
+ */
+ public Background getBackground(){
+ if (_background == null){
+ PPDrawing ppdrawing = getPPDrawing();
+
+ EscherContainerRecord dg = (EscherContainerRecord)ppdrawing.getEscherRecords()[0];
+ EscherContainerRecord spContainer = null;
+ List ch = dg.getChildRecords();
+
+ for (Iterator it = ch.iterator(); it.hasNext();) {
+ EscherRecord rec = (EscherRecord)it.next();
+ if (rec.getRecordId() == EscherContainerRecord.SP_CONTAINER){
+ spContainer = (EscherContainerRecord)rec;
+ break;
+ }
+ }
+ _background = new Background(spContainer, null);
+ _background.setSheet(this);
+ }
+ return _background;
+ }
+
+ /**
+ * Sets whether this slide follows master background
+ *
+ * @param flag <code>true</code> if the slide follows master,
+ * <code>false</code> otherwise
+ */
+ public void setFollowMasterBackground(boolean flag){
+ SlideAtom sa = _slide.getSlideAtom();
+ sa.setFollowMasterBackground(flag);
+ }
+
+ /**
+ * Whether this slide follows master sheet background
+ *
+ * @return <code>true</code> if the slide follows master background,
+ * <code>false</code> otherwise
+ */
+ public boolean getFollowMasterBackground(){
+ SlideAtom sa = _slide.getSlideAtom();
+ return sa.getFollowMasterBackground();
+ }
}
import org.apache.poi.hslf.record.*;
import org.apache.poi.hslf.usermodel.SlideShow;
import org.apache.poi.hslf.record.StyleTextPropAtom.*;
+import org.apache.poi.ddf.EscherContainerRecord;
+import org.apache.poi.ddf.EscherRecord;
+
+import java.util.List;
+import java.util.Iterator;
/**
* SlideMaster determines the graphics, layout, and formatting for all the slides in a given presentation.
private int _sheetNo;
private MainMaster _master;
private TextRun[] _runs;
+ private Background _background;
/**
* all TxMasterStyleAtoms available in this master
return _master.getColorScheme();
}
+ /**
+ * Returns the background shape for this sheet.
+ *
+ * @return the background shape for this sheet.
+ */
+ public Background getBackground(){
+ if (_background == null){
+ PPDrawing ppdrawing = getPPDrawing();
+
+ EscherContainerRecord dg = (EscherContainerRecord)ppdrawing.getEscherRecords()[0];
+ EscherContainerRecord spContainer = null;
+ List ch = dg.getChildRecords();
+
+ for (Iterator it = ch.iterator(); it.hasNext();) {
+ EscherRecord rec = (EscherRecord)it.next();
+ if (rec.getRecordId() == EscherContainerRecord.SP_CONTAINER){
+ spContainer = (EscherContainerRecord)rec;
+ break;
+ }
+ }
+ _background = new Background(spContainer, null);
+ _background.setSheet(this);
+ }
+ return _background;
+ }
+
}
--- /dev/null
+/* ====================================================================\r
+ Copyright 2002-2004 Apache Software Foundation\r
+\r
+ Licensed under the Apache License, Version 2.0 (the "License");\r
+ you may not use this file except in compliance with the License.\r
+ 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
+package org.apache.poi.hslf.model;\r
+\r
+import junit.framework.TestCase;\r
+\r
+import java.io.*;\r
+import java.awt.*;\r
+\r
+import org.apache.poi.hslf.usermodel.SlideShow;\r
+import org.apache.poi.hslf.HSLFSlideShow;\r
+\r
+/**\r
+ * Test <code>Fill</code> object.\r
+ * \r
+ * @author Yegor Kozlov\r
+ */\r
+public class TestBackground extends TestCase {\r
+\r
+ /**\r
+ * Default background for slide, shape and slide master.\r
+ */\r
+ public void testDefaults() throws Exception {\r
+ SlideShow ppt = new SlideShow();\r
+\r
+ assertEquals(Fill.FILL_SOLID, ppt.getSlidesMasters()[0].getBackground().getFill().getFillType());\r
+\r
+ Slide slide = ppt.createSlide();\r
+ assertTrue(slide.getFollowMasterBackground());\r
+ assertEquals(Fill.FILL_SOLID, slide.getBackground().getFill().getFillType());\r
+\r
+ Shape shape = new AutoShape(ShapeTypes.Rectangle);\r
+ assertEquals(Fill.FILL_SOLID, shape.getFill().getFillType());\r
+ }\r
+\r
+ /**\r
+ * Read fill information from an reference ppt file\r
+ */\r
+ public void testReadBackground() throws Exception {\r
+ SlideShow ppt = new SlideShow(new HSLFSlideShow(System.getProperty("HSLF.testdata.path") + "/backgrounds.ppt"));\r
+ Fill fill;\r
+ Shape shape;\r
+\r
+ Slide[] slide = ppt.getSlides();\r
+\r
+ fill = slide[0].getBackground().getFill();\r
+ assertEquals(Fill.FILL_PICTURE, fill.getFillType());\r
+ shape = slide[0].getShapes()[0];\r
+ assertEquals(Fill.FILL_SOLID, shape.getFill().getFillType());\r
+\r
+ fill = slide[1].getBackground().getFill();\r
+ assertEquals(Fill.FILL_PATTERN, fill.getFillType());\r
+ shape = slide[1].getShapes()[0];\r
+ assertEquals(Fill.FILL_BACKGROUND, shape.getFill().getFillType());\r
+\r
+ fill = slide[2].getBackground().getFill();\r
+ assertEquals(Fill.FILL_TEXTURE, fill.getFillType());\r
+ shape = slide[2].getShapes()[0];\r
+ assertEquals(Fill.FILL_PICTURE, shape.getFill().getFillType());\r
+\r
+ fill = slide[3].getBackground().getFill();\r
+ assertEquals(Fill.FILL_SHADE_CENTER, fill.getFillType());\r
+ shape = slide[3].getShapes()[0];\r
+ assertEquals(Fill.FILL_SHADE, shape.getFill().getFillType());\r
+ }\r
+\r
+ /**\r
+ * Create a ppt with various fill effects\r
+ */\r
+ public void testBackgroundPicture() throws Exception {\r
+ SlideShow ppt = new SlideShow();\r
+ Slide slide;\r
+ Fill fill;\r
+ Shape shape;\r
+ int idx;\r
+\r
+ //slide 1\r
+ slide = ppt.createSlide();\r
+ slide.setFollowMasterBackground(false);\r
+ fill = slide.getBackground().getFill();\r
+ idx = ppt.addPicture(new File(System.getProperty("HSLF.testdata.path") + "/tomcat.png"), Picture.PNG);\r
+ fill.setFillType(Fill.FILL_PICTURE);\r
+ fill.setPictureData(idx);\r
+\r
+ shape = new AutoShape(ShapeTypes.Rectangle);\r
+ shape.setAnchor(new java.awt.Rectangle(100, 100, 200, 200));\r
+ fill = shape.getFill();\r
+ fill.setFillType(Fill.FILL_SOLID);\r
+ slide.addShape(shape);\r
+\r
+ //slide 2\r
+ slide = ppt.createSlide();\r
+ slide.setFollowMasterBackground(false);\r
+ fill = slide.getBackground().getFill();\r
+ idx = ppt.addPicture(new File(System.getProperty("HSLF.testdata.path") + "/tomcat.png"), Picture.PNG);\r
+ fill.setFillType(Fill.FILL_PATTERN);\r
+ fill.setPictureData(idx);\r
+ fill.setBackgroundColor(Color.green);\r
+ fill.setForegroundColor(Color.red);\r
+\r
+ shape = new AutoShape(ShapeTypes.Rectangle);\r
+ shape.setAnchor(new java.awt.Rectangle(100, 100, 200, 200));\r
+ fill = shape.getFill();\r
+ fill.setFillType(Fill.FILL_BACKGROUND);\r
+ slide.addShape(shape);\r
+\r
+ //slide 3\r
+ slide = ppt.createSlide();\r
+ slide.setFollowMasterBackground(false);\r
+ fill = slide.getBackground().getFill();\r
+ idx = ppt.addPicture(new File(System.getProperty("HSLF.testdata.path") + "/tomcat.png"), Picture.PNG);\r
+ fill.setFillType(Fill.FILL_TEXTURE);\r
+ fill.setPictureData(idx);\r
+\r
+ shape = new AutoShape(ShapeTypes.Rectangle);\r
+ shape.setAnchor(new java.awt.Rectangle(100, 100, 200, 200));\r
+ fill = shape.getFill();\r
+ fill.setFillType(Fill.FILL_PICTURE);\r
+ idx = ppt.addPicture(new File(System.getProperty("HSLF.testdata.path") + "/clock.jpg"), Picture.JPEG);\r
+ fill.setPictureData(idx);\r
+ slide.addShape(shape);\r
+\r
+ // slide 4\r
+ slide = ppt.createSlide();\r
+ slide.setFollowMasterBackground(false);\r
+ fill = slide.getBackground().getFill();\r
+ fill.setFillType(Fill.FILL_SHADE_CENTER);\r
+ fill.setBackgroundColor(Color.white);\r
+ fill.setForegroundColor(Color.darkGray);\r
+\r
+ shape = new AutoShape(ShapeTypes.Rectangle);\r
+ shape.setAnchor(new java.awt.Rectangle(100, 100, 200, 200));\r
+ fill = shape.getFill();\r
+ fill.setFillType(Fill.FILL_SHADE);\r
+ fill.setBackgroundColor(Color.red);\r
+ fill.setForegroundColor(Color.green);\r
+ slide.addShape(shape);\r
+\r
+ //serialize and read again\r
+ ByteArrayOutputStream out = new ByteArrayOutputStream();\r
+ ppt.write(out);\r
+ out.close();\r
+\r
+ ppt = new SlideShow(new HSLFSlideShow(new ByteArrayInputStream(out.toByteArray())));\r
+ Slide[] slides = ppt.getSlides();\r
+\r
+ fill = slides[0].getBackground().getFill();\r
+ assertEquals(Fill.FILL_PICTURE, fill.getFillType());\r
+ shape = slides[0].getShapes()[0];\r
+ assertEquals(Fill.FILL_SOLID, shape.getFill().getFillType());\r
+\r
+ fill = slides[1].getBackground().getFill();\r
+ assertEquals(Fill.FILL_PATTERN, fill.getFillType());\r
+ shape = slides[1].getShapes()[0];\r
+ assertEquals(Fill.FILL_BACKGROUND, shape.getFill().getFillType());\r
+\r
+ fill = slides[2].getBackground().getFill();\r
+ assertEquals(Fill.FILL_TEXTURE, fill.getFillType());\r
+ shape = slides[2].getShapes()[0];\r
+ assertEquals(Fill.FILL_PICTURE, shape.getFill().getFillType());\r
+\r
+ fill = slides[3].getBackground().getFill();\r
+ assertEquals(Fill.FILL_SHADE_CENTER, fill.getFillType());\r
+ shape = slides[3].getShapes()[0];\r
+ assertEquals(Fill.FILL_SHADE, shape.getFill().getFillType());\r
+\r
+ }\r
+\r
+}\r