OpenOffice.org Forum at OOoForum.orgThe OpenOffice.org Forum
 
 [Home]   [FAQ]   [Search]   [Memberlist]   [Usergroups]   [Register
 [Profile]   [Log in to check your private messages]   [Log in

[java] TableBorder and Calc

 
Post new topic   Reply to topic    OOoForum.org Forum Index -> OpenOffice.org Macros and API
View previous topic :: View next topic  
Author Message
litihome
General User
General User


Joined: 27 Dec 2011
Posts: 5

PostPosted: Sun Jan 29, 2012 6:22 am    Post subject: [java] TableBorder and Calc Reply with quote

Hi,

I've encountered several trouble defining borders of XCell or XCellRange, under LibreOffice 3.4.4 : I can't set border's properties and, moreover, if some are set, they are removed by the (as simple as possible) codes below.

Code:

XCellRange cellRange = (XCellRange) sheet.getCellRangeByPosition(column, row, column, row)
XPropertySet xPropertySet = (XPropertySet) UnoRuntime.queryInterface(XPropertySet.class, cellRange);
TableBorder borders = (TableBorder) xPropertySet.getPropertyValue("TableBorder");
xPropertySet.setPropertyValue("TableBorder", borders);


or

Code:

XCell cell = (XCellRange) sheet.getCellRangeByPosition(column, row)
XPropertySet xPropertySet = (XPropertySet) UnoRuntime.queryInterface(XPropertySet.class, cell);
TableBorder borders = (TableBorder) xPropertySet.getPropertyValue("TableBorder");
xPropertySet.setPropertyValue("TableBorder", borders);


In fact, even if I don't want to use Basic, I have the same problem ; In the same manner, the following portion of code taken from an old portion of Basic code (OpenOffice V2 -> V3) doesn't work anymore.

Code:

Dim oBorder as new com.sun.star.table.BorderLine
oBorder.Color = 0
oBorder.InnerLineWidth = 0
oBorder.OuterLineWidth = 5
oBorder.LineDistance = 0
Dim oTableBorder as new com.sun.star.table.TableBorder
oTableBorder.LeftLine = oBorder
oTableBorder.RightLine = oBorder
oTableBorder.IsLeftLineValid = True
oTableBorder.IsRightLineValid = True
oSheet.getCellByPosition(column, row).TableBorder = oTableBorder


Does anyone have an Idea ?
[/code]
Back to top
View user's profile Send private message
hanya
Super User
Super User


Joined: 04 May 2005
Posts: 543
Location: Japan

PostPosted: Wed Feb 01, 2012 10:12 am    Post subject: Reply with quote

Hi,

It seems css.table.TableBorder can not be used to set table border to the cell range on LibreOffice 3.4.X now. So do it like the following:
Code:
oSheet.getCellByPosition(column, row).LeftBorder = oBorder
Back to top
View user's profile Send private message
litihome
General User
General User


Joined: 27 Dec 2011
Posts: 5

PostPosted: Wed Feb 01, 2012 12:29 pm    Post subject: Reply with quote

Thanks for your answer

After some test, it seems that It can be used in Basic to define different kind of border (left, right, ..) but not in Java ; with the code below, you can't have a cell with a thin and an hard border whith any values of top, right, left and bottom (though you can have side without border, setting thinBorderLine.OuterLineWidth = 0)

Code:

protected void setBorder(String side, boolean show)
{
   BorderLine thinBorderLine = new BorderLine();
   thinBorderLine.Color = 0;
   thinBorderLine.InnerLineWidth = 0;
   thinBorderLine.OuterLineWidth = 5;
   thinBorderLine.LineDistance = 0;

   BorderLine hardBorderLine = new BorderLine();
   hardBorderLine.Color = 0;
   hardBorderLine.InnerLineWidth = 0;
   hardBorderLine.OuterLineWidth = 50;
   hardBorderLine.LineDistance = 0;
   
   setCellProperty(side, show ? hardBorderLine : thinBorderLine);
}

public void setBorder(boolean top, boolean right, boolean bottom, boolean left)
{
   setBorder("TopBorder", top);
   setBorder("RightBorder", right);
   setBorder("BottomBorder", bottom);
   setBorder("LeftBorder", left);
}

[/code]
Back to top
View user's profile Send private message
Display posts from previous:   
Post new topic   Reply to topic    OOoForum.org Forum Index -> OpenOffice.org Macros and API All times are GMT - 8 Hours
Page 1 of 1

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum


Powered by phpBB © 2001, 2005 phpBB Group