use of org.apache.poi.hslf.record.Document in project poi by apache.
the class ActiveXShape method getExControl.
/**
* Document-level container that specifies information about an ActiveX control
*
* @return container that specifies information about an ActiveX control
*/
public ExControl getExControl() {
int idx = getControlIndex();
Document doc = getSheet().getSlideShow().getDocumentRecord();
ExObjList lst = (ExObjList) doc.findFirstOfType(RecordTypes.ExObjList.typeID);
if (lst == null) {
return null;
}
for (Record ch : lst.getChildRecords()) {
if (ch instanceof ExControl) {
ExControl c = (ExControl) ch;
if (c.getExOleObjAtom().getObjID() == idx) {
return c;
}
}
}
return null;
}
use of org.apache.poi.hslf.record.Document in project poi by apache.
the class SLWTListing method main.
public static void main(String[] args) throws IOException {
if (args.length < 1) {
System.err.println("Need to give a filename");
System.exit(1);
}
HSLFSlideShowImpl ss = new HSLFSlideShowImpl(args[0]);
// Find the documents, and then their SLWT
Record[] records = ss.getRecords();
for (int i = 0; i < records.length; i++) {
if (records[i] instanceof Document) {
Document doc = (Document) records[i];
SlideListWithText[] slwts = doc.getSlideListWithTexts();
System.out.println("Document at " + i + " had " + slwts.length + " SlideListWithTexts");
if (slwts.length == 0) {
System.err.println("** Warning: Should have had at least 1! **");
}
if (slwts.length > 3) {
System.err.println("** Warning: Shouldn't have more than 3!");
}
// Check the SLWTs contain what we'd expect
for (int j = 0; j < slwts.length; j++) {
SlideListWithText slwt = slwts[j];
Record[] children = slwt.getChildRecords();
System.out.println(" - SLWT at " + j + " had " + children.length + " children:");
// Should only have SlideAtomSets if the second one
int numSAS = slwt.getSlideAtomsSets().length;
if (j == 1) {
if (numSAS == 0) {
System.err.println(" ** 2nd SLWT didn't have any SlideAtomSets!");
} else {
System.out.println(" - Contains " + numSAS + " SlideAtomSets");
}
} else {
if (numSAS > 0) {
System.err.println(" ** SLWT " + j + " had " + numSAS + " SlideAtomSets! (expected 0)");
}
}
// Report the first 5 children, to give a flavour
int upTo = 5;
if (children.length < 5) {
upTo = children.length;
}
for (int k = 0; k < upTo; k++) {
Record r = children[k];
int typeID = (int) r.getRecordType();
String typeName = RecordTypes.forTypeID(typeID).name();
System.out.println(" - " + typeID + " (" + typeName + ")");
}
}
}
}
ss.close();
}
use of org.apache.poi.hslf.record.Document in project poi by apache.
the class TestBugs method bug56260.
@Test
public void bug56260() throws IOException {
HSLFSlideShow ppt = open("56260.ppt");
List<HSLFSlide> _slides = ppt.getSlides();
assertEquals(13, _slides.size());
// Check the number of TextHeaderAtoms on Slide 1
Document dr = ppt.getDocumentRecord();
SlideListWithText slidesSLWT = dr.getSlideSlideListWithText();
SlideAtomsSet s1 = slidesSLWT.getSlideAtomsSets()[0];
int tha = 0;
for (Record r : s1.getSlideRecords()) {
if (r instanceof TextHeaderAtom) {
tha++;
}
}
assertEquals(2, tha);
// Check to see that we have a pair next to each other
assertEquals(TextHeaderAtom.class, s1.getSlideRecords()[0].getClass());
assertEquals(TextHeaderAtom.class, s1.getSlideRecords()[1].getClass());
// Check the number of text runs based on the slide (not textbox)
// Will have skipped the empty one
int str = 0;
for (List<HSLFTextParagraph> tr : _slides.get(0).getTextParagraphs()) {
if (!tr.get(0).isDrawingBased()) {
str++;
}
}
assertEquals(2, str);
ppt.close();
}
use of org.apache.poi.hslf.record.Document in project poi by apache.
the class HSLFPictureShape method getEscherBSERecord.
@SuppressWarnings("resource")
protected EscherBSERecord getEscherBSERecord() {
HSLFSlideShow ppt = getSheet().getSlideShow();
Document doc = ppt.getDocumentRecord();
EscherContainerRecord dggContainer = doc.getPPDrawingGroup().getDggContainer();
EscherContainerRecord bstore = HSLFShape.getEscherChild(dggContainer, EscherContainerRecord.BSTORE_CONTAINER);
if (bstore == null) {
LOG.log(POILogger.DEBUG, "EscherContainerRecord.BSTORE_CONTAINER was not found ");
return null;
}
List<EscherRecord> lst = bstore.getChildRecords();
int idx = getPictureIndex();
if (idx == 0) {
LOG.log(POILogger.DEBUG, "picture index was not found, returning ");
return null;
}
return (EscherBSERecord) lst.get(idx - 1);
}
use of org.apache.poi.hslf.record.Document in project poi by apache.
the class HSLFFill method getPictureData.
/**
* <code>PictureData</code> object used in a texture, pattern of picture fill.
*/
@SuppressWarnings("resource")
public HSLFPictureData getPictureData() {
AbstractEscherOptRecord opt = shape.getEscherOptRecord();
EscherSimpleProperty p = HSLFShape.getEscherProperty(opt, EscherProperties.FILL__PATTERNTEXTURE);
if (p == null) {
return null;
}
HSLFSlideShow ppt = shape.getSheet().getSlideShow();
List<HSLFPictureData> pict = ppt.getPictureData();
Document doc = ppt.getDocumentRecord();
EscherContainerRecord dggContainer = doc.getPPDrawingGroup().getDggContainer();
EscherContainerRecord bstore = HSLFShape.getEscherChild(dggContainer, EscherContainerRecord.BSTORE_CONTAINER);
java.util.List<EscherRecord> lst = bstore.getChildRecords();
int idx = p.getPropertyValue();
if (idx == 0) {
LOG.log(POILogger.WARN, "no reference to picture data found ");
} else {
EscherBSERecord bse = (EscherBSERecord) lst.get(idx - 1);
for (HSLFPictureData pd : pict) {
if (pd.getOffset() == bse.getOffset()) {
return pd;
}
}
}
return null;
}
Aggregations