LibreOffice 6.3 added grid control element to the dialog editor.
I use the function (the code below) to upload tables to grid controls.
When I run the macro and use this function to put a table inside gridcontrol element for the first time, it works fine and the whole table is visible.
The issue occurs when I upload another table to the control that had been previously filled with old table. New table is either not visible (hidden under old table) or there are still parts of old table visible in the background (the effects vary). Please, see the photo below. It looks like if old content was still present in the control (and I don't know how to remove it / reset the control element before another upload).
However, this effect can be easely removed when I force control to refresh - for example by moving a scrollbar or even by dropping calc sheet into windows taskbar and then restoring it.
Is it a bug or am I doing something wrong ?
Also, do you know any examples of the code which shows how to properly use gridcontrol, created in the editor ?
Thanks for your help.
Code: Select all
Function InsertNewTable(oWindow as object, grid_headers(), grid_content())
if SafeUBound(grid_headers) = -1 then Exit function
if SafeUBound(grid_content) = -1 then Exit function
oGridModel = oWindow.Model
With oGridModel
.ShowColumnHeader = True
.ShowRowHeader = False
.Sizeable = True
.UseGridLines = true
.GridLineColor = 100
.HeaderBackgroundColor = RGB(255, 255, 0)
End with
oColumnModel = createUnoService( "com.sun.star.awt.grid.DefaultGridColumnModel")
for i=0 to UBound(grid_headers)
oColumn = createUnoService("com.sun.star.awt.grid.GridColumn")
oColumn.Title = grid_headers(i)
oColumn.Resizeable=true
oColumn.ColumnWidth = 40
oColumn.Flexibility=false
oColumnModel.addColumn(oColumn)
next
oGridModel.ColumnModel = oColumnModel
'Rows:
oDataModel = createUnoService("com.sun.star.awt.grid.DefaultGridDataModel")
if SafeUBound(grid_content, 2) > -1 then
x = 0
y = 0
dim single_row(UBound(grid_content, 2)) as string
Do
for x = 0 to UBound(grid_content, 2)
single_row(x) = grid_content(y, x)
next
oDataModel.addRow(x, single_row)
y = y+1
x = 0
Loop Until y > UBound(grid_content, 1)
elseif SafeUBound(grid_content, 2) = -1 then
x = 0
y = 0
dim single_row2(UBound(grid_content)) as string
for x = 0 to UBound(grid_content)
single_row2(x) = grid_content(x)
next
oDataModel.addRow(x, single_row2)
end if
oGridModel.GridDataModel = oDataModel
End function