use of org.apache.poi.POIXMLDocumentPart in project poi by apache.
the class XDGFPageContents method onDocumentRead.
@Override
protected void onDocumentRead() {
try {
try {
_pageContents = PageContentsDocument.Factory.parse(getPackagePart().getInputStream()).getPageContents();
} catch (XmlException e) {
throw new POIXMLException(e);
} catch (IOException e) {
throw new POIXMLException(e);
}
for (POIXMLDocumentPart part : getRelations()) {
if (!(part instanceof XDGFMasterContents))
continue;
//throw new POIXMLException("Unexpected page relation: " + part);
XDGFMaster master = ((XDGFMasterContents) part).getMaster();
_masters.put(master.getID(), master);
}
super.onDocumentRead();
for (XDGFShape shape : _shapes.values()) {
if (shape.isTopmost())
shape.setupMaster(this, null);
}
} catch (POIXMLException e) {
throw XDGFException.wrap(this, e);
}
}
use of org.apache.poi.POIXMLDocumentPart in project poi by apache.
the class XDGFPages method onDocumentRead.
@Override
protected void onDocumentRead() {
try {
try {
_pagesObject = PagesDocument.Factory.parse(getPackagePart().getInputStream()).getPages();
} catch (XmlException e) {
throw new POIXMLException(e);
} catch (IOException e) {
throw new POIXMLException(e);
}
// this iteration is ordered by page number
for (PageType pageSettings : _pagesObject.getPageArray()) {
String relId = pageSettings.getRel().getId();
POIXMLDocumentPart pageContentsPart = getRelationById(relId);
if (pageContentsPart == null)
throw new POIXMLException("PageSettings relationship for " + relId + " not found");
if (!(pageContentsPart instanceof XDGFPageContents))
throw new POIXMLException("Unexpected pages relationship for " + relId + ": " + pageContentsPart);
XDGFPageContents contents = (XDGFPageContents) pageContentsPart;
XDGFPage page = new XDGFPage(pageSettings, contents, _document, this);
contents.onDocumentRead();
_pages.add(page);
}
} catch (POIXMLException e) {
throw XDGFException.wrap(this, e);
}
}
use of org.apache.poi.POIXMLDocumentPart in project poi by apache.
the class XSLFSlideMaster method getLayouts.
private Map<String, XSLFSlideLayout> getLayouts() {
if (_layouts == null) {
_layouts = new HashMap<String, XSLFSlideLayout>();
for (POIXMLDocumentPart p : getRelations()) {
if (p instanceof XSLFSlideLayout) {
XSLFSlideLayout layout = (XSLFSlideLayout) p;
_layouts.put(layout.getName().toLowerCase(Locale.ROOT), layout);
}
}
}
return _layouts;
}
use of org.apache.poi.POIXMLDocumentPart in project poi by apache.
the class XSSFSheet method getDrawingPatriarch.
/**
* Return the sheet's existing drawing, or null if there isn't yet one.
*
* Use {@link #createDrawingPatriarch()} to get or create
*
* @return a SpreadsheetML drawing
*/
@Override
public XSSFDrawing getDrawingPatriarch() {
CTDrawing ctDrawing = getCTDrawing();
if (ctDrawing != null) {
// Search the referenced drawing in the list of the sheet's relations
for (RelationPart rp : getRelationParts()) {
POIXMLDocumentPart p = rp.getDocumentPart();
if (p instanceof XSSFDrawing) {
XSSFDrawing dr = (XSSFDrawing) p;
String drId = rp.getRelationship().getId();
if (drId.equals(ctDrawing.getId())) {
return dr;
}
break;
}
}
logger.log(POILogger.ERROR, "Can't find drawing with id=" + ctDrawing.getId() + " in the list of the sheet's relationships");
}
return null;
}
use of org.apache.poi.POIXMLDocumentPart in project poi by apache.
the class XSSFMap method getRelatedSingleXMLCell.
/**
* @return the list of Single Xml Cells that provide a map rule to this mapping.
*/
public List<XSSFSingleXmlCell> getRelatedSingleXMLCell() {
List<XSSFSingleXmlCell> relatedSimpleXmlCells = new ArrayList<XSSFSingleXmlCell>();
int sheetNumber = mapInfo.getWorkbook().getNumberOfSheets();
for (int i = 0; i < sheetNumber; i++) {
XSSFSheet sheet = mapInfo.getWorkbook().getSheetAt(i);
for (POIXMLDocumentPart p : sheet.getRelations()) {
if (p instanceof SingleXmlCells) {
SingleXmlCells singleXMLCells = (SingleXmlCells) p;
for (XSSFSingleXmlCell cell : singleXMLCells.getAllSimpleXmlCell()) {
if (cell.getMapId() == ctMap.getID()) {
relatedSimpleXmlCells.add(cell);
}
}
}
}
}
return relatedSimpleXmlCells;
}
Aggregations