Change FillColor TableShape

Creating a macro - Writing a Script - Using the API

Change FillColor TableShape

Postby kinnder » Wed Mar 29, 2017 9:15 pm

Hi!
I need help.
I use macro from book Andrew Pitonyak.

Code: Select all   Expand viewCollapse view
Sub DrawTableShape
Dim oSize as New com.sun.star.awt.Size
Dim oPos as New com.sun.star.awt.Point
Dim oPage
Dim oTable
Dim oCell
Dim oDrawDoc ' Temporary draw document.
oDrawDoc = ThisComponent
' Set a size and table position.
oSize.Width = 6000 : oSize.Height = 6100
oPos.X = 6000 : oPos.Y = 5000
' Get the first draw page
oPage = oDrawDoc.DrawPages.getByIndex(0)
oTable = oDrawDoc.createInstance("com.sun.star.drawing.TableShape")
oPage.add(oTable)
oTable.Name="TEST3"
oTable.Model.Rows.InsertByIndex(1,4)
oTable.Model.Columns.InsertByIndex(1,4)
oTable.setSize(oSize)
oTable.setPosition(oPos)
oCell = oTable.Model.getCellByPosition(0,1)
oCell.getText().setString("X")

End Sub

How i can change color this table in macro? In document i can change color table manually.example table after use this macro in attachment.
I tried code,
Code: Select all   Expand viewCollapse view
oStyle=oTable.Style
oStyle.FillColor=RGB(255,0,0)

but not work.

in the same time code
Code: Select all   Expand viewCollapse view
oStyle.ShadowColor=RGB(255,0,0)

working

Thanks!

P.S. Sorry for my English.
Attachments
Doc_1.odg
(12.53 KiB) Downloaded 10 times
LibreOffice 5.1 on Windows 7 64-bit
kinnder
 
Posts: 1
Joined: Wed Mar 29, 2017 8:51 pm

Re: Change FillColor TableShape

Postby Zizi64 » Tue Apr 04, 2017 7:43 pm

I suppose you want to change the bakground color of the CELLS:
https://forum.openoffice.org/en/forum/v ... 10&t=23812


Code: Select all   Expand viewCollapse view
oCell = oTModel.getCellByPosition(0,1)
oCell.FillColor =RGB(255,100,0)


Use one (or two nested) FOR cycle/s/ to fill all of the existing cells...


https://www.openoffice.org/api/docs/com ... html#SOLID
Tibor Kovacs, Hungary; LibreOffice4.4.7 - Portable versions: LO3.3.0-LO5.3.2 and AOO4.1.3; on Win7x64Prof.
Please, edit the topic's initial post, and add the word "[Solved]" at the beginning of the subject line - if your problem has been solved.
User avatar
Zizi64
Volunteer
 
Posts: 4983
Joined: Wed May 26, 2010 7:55 am
Location: Budapest, Hungary


Return to Macros and UNO API

Who is online

Users browsing this forum: No registered users and 6 guests