Bug 37625 - Don`t show a grid/Borders in Calc are not affected from Basic
Summary: Don`t show a grid/Borders in Calc are not affected from Basic
Status: RESOLVED NOTABUG
Alias: None
Product: LibreOffice
Classification: Unclassified
Component: BASIC (show other bugs)
Version:
(earliest affected)
3.4.0 release
Hardware: x86-64 (AMD64) Windows (All)
: medium major
Assignee: Not Assigned
URL:
Whiteboard: bibisected35 bibisected35older
Keywords: regression
Depends on:
Blocks:
 
Reported: 2011-05-26 05:45 UTC by Ishayahu
Modified: 2012-03-09 07:25 UTC (History)
5 users (show)

See Also:
Crash report or crash signature:


Attachments
Exemple (36.52 KB, application/vnd.sun.xml.base)
2011-05-26 11:56 UTC, Ishayahu
Details

Note You need to log in before you can comment on or make changes to this bug.
Description Ishayahu 2011-05-26 05:45:20 UTC
I use macro to create a hide spreadsheet document, enter data and make a grid. But the grid does not appear. When I do F8 through the macro I see that this part of code doen`t work:

oBorder = CellRange.BottomBorder
With oBorder
	.Color = 0
    .InnerLineWidth = 10
    .OuterLineWidth = 0
    .LineDistance = 0
End With
  
CellRange.BottomBorder = oBorder
CellRange.LeftBorder = oBorder
CellRange.RightBorder = oBorder
CellRange.TopBorder = oBorder
Comment 1 Ishayahu 2011-05-26 11:54:05 UTC
I was tested this macro in LibreOffice.org 3.3 and all works properly
Comment 2 Ishayahu 2011-05-26 11:56:05 UTC
Created attachment 47196 [details]
Exemple
Comment 3 clio 2011-05-26 14:23:11 UTC
Reproducible with LibO 3.2 rc1 and rc2 (Linux, Windows Vista)
OK with LibO 3.3.2, OOo-dev300m106, OOo 3.3.0

To reproduce:
1) Open Calc
2) Select a range
3) Run this macro:
	Sub Main
	Doc=ThisComponent
	CellRange = Doc.CurrentSelection
	oBorder = CellRange.BottomBorder
	With oBorder
	    .Color = 0
	    .InnerLineWidth = 10
	    .OuterLineWidth = 0
	    .LineDistance = 0
	End With
	
	CellRange.BottomBorder = oBorder
	CellRange.LeftBorder = oBorder
	CellRange.RightBorder = oBorder
	CellRange.TopBorder = oBorder
	End Sub

Result: Nothing happens.
Comment 4 LeMoyne Castle 2011-05-29 12:18:30 UTC
dev master shows this regression against LibO 3.3.2 as well 
The failure occurs whether macro is run in the spreadsheet (no IDE) or from the open Basic IDE so dropped IDE from summary
Comment 5 Rainer Bielefeld Retired 2011-06-10 02:58:02 UTC
RC2 is bit by bit identical with release version, so separate items in the version picker are useless. Changes have been discussed with Michael Meeks.
Comment 6 Björn Michaelsen 2011-12-23 12:03:11 UTC
[This is an automated message.]
This bug was filed before the changes to Bugzilla on 2011-10-16. Thus it
started right out as NEW without ever being explicitly confirmed. The bug is
changed to state NEEDINFO for this reason. To move this bug from NEEDINFO back
to NEW please check if the bug still persists with the 3.5.0 beta1 or beta2 prereleases.
Details on how to test the 3.5.0 beta1 can be found at:
http://wiki.documentfoundation.org/QA/BugHunting_Session_3.5.0.-1

more detail on this bulk operation: http://nabble.documentfoundation.org/RFC-Operation-Spamzilla-tp3607474p3607474.html
Comment 7 August Sodora 2012-01-08 17:44:46 UTC
The following piece of code has no effect in master:

Sub Main
	Doc=ThisComponent
	CellRange = Doc.CurrentSelection
	oBorder = CellRange.BottomBorder
	With oBorder
	    .Color = 0
	    .InnerLineWidth = 10
	    .OuterLineWidth = 0
	    .LineDistance = 0
	End With

	CellRange.BottomBorder = oBorder
	CellRange.LeftBorder = oBorder
	CellRange.RightBorder = oBorder
	CellRange.TopBorder = oBorder
End Sub
Comment 8 Lionel Elie Mamane 2012-02-09 10:35:57 UTC
The following code works for Writer tables.

	Dim border As Object, ligne As new "com.sun.star.table.BorderLine"
	border = tbl.TableBorder
	ligne.OuterLineWidth = 1
	border.HorizontalLine = ligne
	border.TopLine = ligne
	border.BottomLine = ligne
	border.RightLine = ligne
	border.LeftLine = ligne
	tbl.TableBorder = border


Note the use of a *new* object that is assigned to where you want it instead of modifying directly the object you want to change.
Comment 9 sasha.libreoffice 2012-02-29 02:59:00 UTC
So, it is regression or misused object in Basic?
Comment 10 Lionel Elie Mamane 2012-02-29 03:21:47 UTC
(In reply to comment #9)
> So, it is regression or misused object in Basic?

Well, if it worked in previous versions, it is clearly a regression. The "other way" just gives a (clumsy) work-around.

I'd have thought that this is just an occurence of bug 42819, but I get bug 42819 also in OO.org 3.2, so possibly there is something more subtle at play.
Comment 11 Noel Power 2012-03-09 03:13:33 UTC
    oBorder = CellRange.BottomBorder
    With oBorder
        .Color = 0
        .InnerLineWidth = 10
        .OuterLineWidth = 0
        .LineDistance = 0
    End With

    CellRange.BottomBorder = oBorder

the pattern above should work fine, oBorder is a copy of that
css:table::BorderLine structure. And 

CellRange.BottomBorder = oBorder


will set the BottomBorder property of the CellRange object. Infact I just
slapped a debugger on the calc uno object, it does get the correct values from
basic. So... this aint a basic problem but a calc uno object problem, not sure
if this really is a regression, if this was reproducible in LibO 3.2 rc1 then I
would strongly guess this is inherited from the old openoffice code. But...
whatever it still is imo a bad bug ( I'll have a look at the calc code to see
if anything jumps out as been awfully wrong )


note: it sortof mentioned in the some of the previous comments that modifying a
member of a structure directly doesn't work. e.g

even if

  CellRange.BottomBorder = oBorder 

worked correctly then 

  CellRange.BottomBorder.InnerLineWidth = 10

will never work. This is not a limitation of Basic but rather down to UNO.
CellRange has a property BottomBorder which is struct. Structures in UNO are
returned by value, the line 'CellRange.BottomBorder.InnerLineWidth = 10'
modifies the the returned ( maybe temporary is a better term ) structure
Comment 12 Noel Power 2012-03-09 04:52:02 UTC
I'm going to close this,

but first I have to say I spent quite some time with this out of sheer stupidity, first I didn't see any change in when running the macro  Note I was using the 

    dim oBorder as new com.sun.star.table.BorderLine
    With oBorder
        .Color = 0
        .InnerLineWidth = 10
        .OuterLineWidth = 0
        .LineDistance = 0
    End With

variant of the macro.

After debugging for a while I could see no problem, then I noticed after moving the cursor the borders where in fact changed :-) the cursor which formed the selection the macro acted upon ) obscured the small increase ( for me at least ) of the changes to the linesize made by the macro. Anyway I came back for a final look to just recheck and this time I used the


    oBorder = CellRange.bottomBorder
    With oBorder
        .Color = 0
        .InnerLineWidth = 10
        .OuterLineWidth = 0
        .LineDistance = 0
    End With

approach an noticed that indeed I wasn't getting any changes :-/

Turns out that the problem here is that CellRange.bottomBorder now returns http://api.libreoffice.org/docs/common/ref/com/sun/star/table/BorderLine2.html

so the LineWidth there is picked up from 'oBorder = CellRange.bottomBorder' and it's value overwrites whatever changes were made to 'InnerLineWidth' etc.

hope that makes sense
Comment 13 Noel Power 2012-03-09 07:25:02 UTC
removed bug# 42819 from dependencies, it is unrelated