import org.apache.poi.sl.usermodel.Placeholder;\r
import org.apache.poi.util.Beta;\r
import org.apache.xmlbeans.XmlCursor;\r
+import org.apache.xmlbeans.XmlException;\r
import org.apache.xmlbeans.XmlObject;\r
import org.openxmlformats.schemas.drawingml.x2006.main.CTBlip;\r
import org.openxmlformats.schemas.drawingml.x2006.main.CTBlipFillProperties;\r
if (rel != null) {\r
try {\r
PackagePart imgPart = p.getRelatedPart(rel);\r
- _data = new XSLFPictureData(imgPart, rel);\r
+ _data = new XSLFPictureData(imgPart);\r
}\r
catch (Exception e) {\r
throw new POIXMLException(e);\r
return null;\r
}\r
\r
- protected CTBlip getBlip(){\r
+ protected CTBlipFillProperties getBlipFill() {\r
CTPicture ct = (CTPicture)getXmlObject();\r
- return ct.getBlipFill().getBlip();\r
+ CTBlipFillProperties bfp = ct.getBlipFill();\r
+ if (bfp != null) {\r
+ return bfp;\r
+ }\r
+ \r
+ String xquery =\r
+ "declare namespace p='http://schemas.openxmlformats.org/presentationml/2006/main'; "\r
+ + "declare namespace mc='http://schemas.openxmlformats.org/markup-compatibility/2006' "\r
+ + ".//mc:Fallback/p:blipFill"\r
+ ;\r
+ XmlObject xo = selectProperty(XmlObject.class, xquery);\r
+ try {\r
+ xo = CTPicture.Factory.parse(xo.getDomNode());\r
+ } catch (XmlException xe) {\r
+ return null;\r
+ }\r
+ return ((CTPicture)xo).getBlipFill();\r
+ }\r
+ \r
+ protected CTBlip getBlip(){\r
+ return getBlipFill().getBlip();\r
}\r
\r
protected String getBlipLink(){\r
\r
@Override\r
public Insets getClipping(){\r
- CTPicture ct = (CTPicture)getXmlObject();\r
- CTRelativeRect r = ct.getBlipFill().getSrcRect();\r
+ CTRelativeRect r = getBlipFill().getSrcRect();\r
return (r == null) ? null : new Insets(r.getT(), r.getL(), r.getB(), r.getR());\r
}\r
\r
String relId = getSheet().importBlip(blipId, p.getSheet().getPackagePart());\r
\r
CTPicture ct = (CTPicture)getXmlObject();\r
- CTBlip blip = ct.getBlipFill().getBlip();\r
+ CTBlip blip = getBlipFill().getBlip();\r
blip.setEmbed(relId);\r
\r
CTApplicationNonVisualDrawingProps nvPr = ct.getNvPicPr().getNvPr();\r
}\r
\r
}\r
-}\r
+}
\ No newline at end of file
import static junit.framework.TestCase.assertEquals;
import static org.apache.poi.POITestCase.assertContains;
-import static org.junit.Assert.*;
+import static org.junit.Assert.assertArrayEquals;
+import static org.junit.Assert.assertNotNull;
+import static org.junit.Assert.assertTrue;
+import static org.junit.Assert.fail;
import java.awt.Color;
import java.awt.Dimension;
import org.apache.poi.POIXMLDocumentPart;
import org.apache.poi.POIXMLDocumentPart.RelationPart;
+import org.apache.poi.sl.usermodel.PaintStyle;
import org.apache.poi.sl.usermodel.PictureData.PictureType;
import org.apache.poi.xslf.usermodel.DrawingParagraph;
import org.apache.poi.xslf.usermodel.DrawingTextBody;
ppt.removeSlide(1);
assertNotNull(ppt.createSlide());
}
+
+ @Test
+ public void blibFillAlternateContent() throws IOException {
+ XMLSlideShow ppt = XSLFTestDataSamples.openSampleDocument("2411-Performance_Up.pptx");
+ XSLFPictureShape ps = (XSLFPictureShape)ppt.getSlides().get(4).getShapes().get(0);
+ assertNotNull(ps.getPictureData());
+ ppt.close();
+ }
}
assertTrue(sameColor(new Color(148, 198, 0), run2.getFontColor()));\r
assertNull(sh2.getFillColor()); // no fill\r
\r
- assertTrue(slide.getSlideLayout().getFollowMasterGraphics());\r
+ assertFalse(slide.getSlideLayout().getFollowMasterGraphics());\r
}\r
\r
void slide5(XSLFSlide slide){\r
// font size is 40pt and scale factor is 90%\r
assertEquals(36.0, run2.getFontSize(), 0);\r
\r
- assertTrue(slide.getSlideLayout().getFollowMasterGraphics());\r
+ assertFalse(slide.getSlideLayout().getFollowMasterGraphics());\r
}\r
\r
void slide6(XSLFSlide slide){\r