Spreadsheet borders
From NOA Documentation Wiki
One can easily draw borders around cells with PropertySet and TableBorder:
static final int TOP = 0;
static final int BOTTOM = 1;
static final int LEFT = 2;
static final int RIGHT = 3;
/**draws a border round a XCell
* based on http://www.mail-archive.com/dev@sc.openoffice.org/msg00908.html
* @throws IllegalArgumentException
* */
void drawBorder(XCell cell, int side) throws IllegalArgumentException
{
int color=new Integer(0x000000);
short inner=1;
short outer=0;
short distance=0;
XPropertySet propertySet = (XPropertySet) UnoRuntime.queryInterface(XPropertySet.class, cell);
TableBorder t = new TableBorder();
switch (side)
{
case TOP:
t.TopLine.Color = color;
t.TopLine.InnerLineWidth = inner;
t.TopLine.OuterLineWidth = outer;
t.TopLine.LineDistance = distance;
t.IsTopLineValid = true;
break;
case BOTTOM:
t.BottomLine.Color = color;
t.BottomLine.InnerLineWidth = inner;
t.BottomLine.OuterLineWidth = outer;
t.BottomLine.LineDistance = distance;
t.IsBottomLineValid = true;
case LEFT:
t.LeftLine.Color = color;
t.LeftLine.InnerLineWidth = inner;
t.LeftLine.OuterLineWidth = outer;
t.LeftLine.LineDistance = distance;
t.IsLeftLineValid = true;
break;
case RIGHT:
t.RightLine.Color = color;
t.RightLine.InnerLineWidth = inner;
t.RightLine.OuterLineWidth = outer;
t.RightLine.LineDistance = distance;
t.IsRightLineValid = true;
break;
default:
throw new IllegalArgumentException("call for illegal side " + side);
}
try
{
propertySet.setPropertyValue("TableBorder", t);
}
catch (UnknownPropertyException e)
{
// TODO Auto-generated catch block
e.printStackTrace();
}
catch (PropertyVetoException e)
{
// TODO Auto-generated catch block
e.printStackTrace();
}
catch (com.sun.star.lang.IllegalArgumentException e)
{
// TODO Auto-generated catch block
e.printStackTrace();
}
catch (WrappedTargetException e)
{
// TODO Auto-generated catch block
e.printStackTrace();
}
}
XCell cell=null;
try{
cell= cellCursor.getCellByPosition(0,0); // col 0 row 0
drawBorder(cell,TOP);
drawBorder(cell,RIGHT);
drawBorder(cell,BOTTOM);
drawBorder(cell,LEFT);
} catch(Exception ex) {ex.printStackTrace();}

