/** * Format the table and apply the specified Line to all cell boundaries, * both outside and inside * * @param line the border line */ public void setAllBorders(Line line){ for (int i = 0; i < cells.length; i++) { for (int j = 0; j < cells[i].length; j++) { TableCell cell = cells[i][j]; cell.setBorderTop(cloneBorder(line)); cell.setBorderLeft(cloneBorder(line)); if(j == cells[i].length - 1) cell.setBorderRight(cloneBorder(line)); if(i == cells.length - 1) cell.setBorderBottom(cloneBorder(line)); } } }
/** * Sets the row height. * * @param row the row index (0-based) * @param height the height to set (in pixels) */ public void setRowHeight(int row, int height){ int currentHeight = cells[row][0].getAnchor().height; int dy = height - currentHeight; for (int i = row; i < cells.length; i++) { for (int j = 0; j < cells[i].length; j++) { Rectangle anchor = cells[i][j].getAnchor(); if(i == row) anchor.height = height; else anchor.y += dy; cells[i][j].setAnchor(anchor); } } Rectangle tblanchor = getAnchor(); tblanchor.height += dy; setAnchor(tblanchor); }
/** * Create a border to format this table * * @return the created border */ public Line createBorder(){ Line line = new Line(this); EscherOptRecord opt = (EscherOptRecord)getEscherChild(line.getSpContainer(), EscherOptRecord.RECORD_ID); setEscherProperty(opt, EscherProperties.GEOMETRY__SHAPEPATH, -1); setEscherProperty(opt, EscherProperties.GEOMETRY__FILLOK, -1); setEscherProperty(opt, EscherProperties.SHADOWSTYLE__SHADOWOBSURED, 0x20000); setEscherProperty(opt, EscherProperties.THREED__LIGHTFACE, 0x80000); return line; } }
protected void initTable(){ Shape[] sh = getShapes(); Arrays.sort(sh, new Comparator(){ public int compare( Object o1, Object o2 ) { for (int j = 0; j < row.size(); j++) { TextShape tx = (TextShape)row.get(j); cells[i][j] = new TableCell(tx.getSpContainer(), getParent()); cells[i][j].setSheet(tx.getSheet());
protected void afterInsert(Sheet sh){ super.afterInsert(sh); EscherContainerRecord spCont = (EscherContainerRecord) getSpContainer().getChild(0); List<EscherRecord> lst = spCont.getChildRecords(); EscherOptRecord opt = (EscherOptRecord)lst.get(lst.size()-2); EscherArrayProperty p = (EscherArrayProperty)opt.getEscherProperty(1); for (int i = 0; i < cells.length; i++) { TableCell cell = cells[i][0]; int rowHeight = cell.getAnchor().height*MASTER_DPI/POINT_DPI; byte[] val = new byte[4]; LittleEndian.putInt(val, rowHeight); p.setElement(i, val); for (int j = 0; j < cells[i].length; j++) { TableCell c = cells[i][j]; addShape(c); Line bt = c.getBorderTop(); if(bt != null) addShape(bt); Line br = c.getBorderRight(); if(br != null) addShape(br); Line bb = c.getBorderBottom(); if(bb != null) addShape(bb); Line bl = c.getBorderLeft(); if(bl != null) addShape(bl); } } }
setAnchor(new Rectangle(0, 0, tblWidth, tblHeight)); EscherContainerRecord spCont = (EscherContainerRecord) getSpContainer().getChild(0); EscherOptRecord opt = new EscherOptRecord(); opt.setRecordId((short)0xF122);
/** * Assign the <code>SlideShow</code> this shape belongs to * * @param sheet owner of this shape */ public void setSheet(Sheet sheet){ super.setSheet(sheet); if(cells == null) initTable(); }
private Line cloneBorder(Line line){ Line border = createBorder(); border.setLineWidth(line.getLineWidth()); border.setLineStyle(line.getLineStyle()); border.setLineDashing(line.getLineDashing()); border.setLineColor(line.getLineColor()); return border; }
public static ShapeGroup createShapeGroup(EscherContainerRecord spContainer, Shape parent){ ShapeGroup group = null; EscherRecord opt = Shape.getEscherChild((EscherContainerRecord)spContainer.getChild(0), (short)0xF122); if(opt != null){ try { EscherPropertyFactory f = new EscherPropertyFactory(); List props = f.createProperties( opt.serialize(), 8, opt.getInstance() ); EscherSimpleProperty p = (EscherSimpleProperty)props.get(0); if(p.getPropertyNumber() == 0x39F && p.getPropertyValue() == 1){ group = new Table(spContainer, parent); } else { group = new ShapeGroup(spContainer, parent); } } catch (Exception e){ logger.log(POILogger.WARN, e.getMessage()); group = new ShapeGroup(spContainer, parent); } } else { group = new ShapeGroup(spContainer, parent); } return group; }
/** * Sets the column width. * * @param col the column index (0-based) * @param width the width to set (in pixels) */ public void setColumnWidth(int col, int width){ int currentWidth = cells[0][col].getAnchor().width; int dx = width - currentWidth; for (int i = 0; i < cells.length; i++) { Rectangle anchor = cells[i][col].getAnchor(); anchor.width = width; cells[i][col].setAnchor(anchor); if(col < cells[i].length - 1) for (int j = col+1; j < cells[i].length; j++) { anchor = cells[i][j].getAnchor(); anchor.x += dx; cells[i][j].setAnchor(anchor); } } Rectangle tblanchor = getAnchor(); tblanchor.width += dx; setAnchor(tblanchor); }
/** * Format the outside border using the specified Line object * * @param line the border line */ public void setOutsideBorders(Line line){ for (int i = 0; i < cells.length; i++) { for (int j = 0; j < cells[i].length; j++) { TableCell cell = cells[i][j]; if(j == 0) cell.setBorderLeft(cloneBorder(line)); if(j == cells[i].length - 1) cell.setBorderRight(cloneBorder(line)); else { cell.setBorderLeft(null); cell.setBorderLeft(null); } if(i == 0) cell.setBorderTop(cloneBorder(line)); else if(i == cells.length - 1) cell.setBorderBottom(cloneBorder(line)); else { cell.setBorderTop(null); cell.setBorderBottom(null); } } } }
/** * Format the inside border using the specified Line object * * @param line the border line */ public void setInsideBorders(Line line){ for (int i = 0; i < cells.length; i++) { for (int j = 0; j < cells[i].length; j++) { TableCell cell = cells[i][j]; if(j != cells[i].length - 1) cell.setBorderRight(cloneBorder(line)); else { cell.setBorderLeft(null); cell.setBorderLeft(null); } if(i != cells.length - 1) cell.setBorderBottom(cloneBorder(line)); else { cell.setBorderTop(null); cell.setBorderBottom(null); } } } }