[Solved] Impress tables and api

Discuss the presentation application
Post Reply
jlmargot
Posts: 8
Joined: Wed May 13, 2009 11:53 am

[Solved] Impress tables and api

Post by jlmargot »

Hello,

In OpenOffice 3.1, it is possible to insert tables under Impress, and each cell may receive a different picture.

It it possible to do the same thing from an OpenOffice macro and if yes, what api services are necessary for this ?

Thanks in advance,

Jean-Louis Margot.
Last edited by Hagar Delest on Wed Oct 21, 2009 2:55 pm, edited 1 time in total.
Reason: tagged [Solved].
OOo 3.1.X on Ms Windows XP + LINUX
FJCC
Moderator
Posts: 9280
Joined: Sat Nov 08, 2008 8:08 pm
Location: Colorado, USA

Re: Impress tables and api

Post by FJCC »

I succeeded in inserting a table into a slide with the Basic code below.

Code: Select all

Dim oSize as New com.sun.star.awt.Size
Dim oPos as New com.sun.star.awt.Point
oSize.Width = 6000
oSize.Height = 6100
oPos.X = 6000
oPos.Y = 5000
oDoc = ThisComponent
DrawPages = oDoc.DrawPages
DPage = DrawPages.getByIndex(1) 'get the DrawPage of the second slide
oTable = oDoc.createInstance("com.sun.star.drawing.TableShape")
DPage.add(oTable)  'add the table object to the chosen drawpage
oTable.Model.Rows.InsertByIndex(1,4)  'add four rows to the table
oTable.Model.Columns.InsertByIndex(1,4)  'add 4 columns
oTable.setSize(oSize)  'change the size of the table
oTable.setPosition(oPos) ' change the location 
TModel = oTable.Model
Cell = Tmodel.getCellByPosition(1,1)'get a particular cell in the table


I was not able to insert a picture into a Cell with code. I then tried to insert a picture manually and I couldn't do that either. :oops: As you might guess, I don't do much with Impress. If you tell my how you insert a picture in a cell, maybe I can figure something out.
OpenOffice 4.1 on Windows 10 and Linux Mint
If your question is answered, please go to your first post, select the Edit button, and add [Solved] to the beginning of the title.
jlmargot
Posts: 8
Joined: Wed May 13, 2009 11:53 am

Re: Impress tables and api

Post by jlmargot »

FJCC wrote:I succeeded in inserting a table into a slide with the Basic code below.

Code: Select all

Dim oSize as New com.sun.star.awt.Size
Dim oPos as New com.sun.star.awt.Point
oSize.Width = 6000
oSize.Height = 6100
oPos.X = 6000
oPos.Y = 5000
oDoc = ThisComponent
DrawPages = oDoc.DrawPages
DPage = DrawPages.getByIndex(1) 'get the DrawPage of the second slide
oTable = oDoc.createInstance("com.sun.star.drawing.TableShape")
DPage.add(oTable)  'add the table object to the chosen drawpage
oTable.Model.Rows.InsertByIndex(1,4)  'add four rows to the table
oTable.Model.Columns.InsertByIndex(1,4)  'add 4 columns
oTable.setSize(oSize)  'change the size of the table
oTable.setPosition(oPos) ' change the location 
TModel = oTable.Model
Cell = Tmodel.getCellByPosition(1,1)'get a particular cell in the table


I was not able to insert a picture into a Cell with code. I then tried to insert a picture manually and I couldn't do that either. :oops: As you might guess, I don't do much with Impress. If you tell my how you insert a picture in a cell, maybe I can figure something out.
Thank you for your message. I tried your macro and it works.

To insert a picture you must use toolbar Table.
1) select a cell with mouse left button
2) in the toolbar Table, a list box with visible "color" text. Select bitmap.
3) in the other list box, select a bitmap.

Regards,

Jean-Louis Margot
The bitmap is shown in the cell. You can use different pictures of other representations with each cell.
OOo 3.1.X on Ms Windows XP + LINUX
FJCC
Moderator
Posts: 9280
Joined: Sat Nov 08, 2008 8:08 pm
Location: Colorado, USA

Re: [Solved] Impress tables and api

Post by FJCC »

I modified the code to add a bitmap to a chosen cell

Code: Select all

Dim oSize as New com.sun.star.awt.Size
Dim oPos as New com.sun.star.awt.Point
oSize.Width = 6000
oSize.Height = 6100
oPos.X = 6000
oPos.Y = 5000
oDoc = ThisComponent
DrawPages = oDoc.DrawPages
DPage = DrawPages.getByIndex(1)
oTable = oDoc.createInstance("com.sun.star.drawing.TableShape")
DPage.add(oTable)
oTable.Model.Rows.InsertByIndex(1,4)
oTable.Model.Columns.InsertByIndex(1,4)
oTable.setSize(oSize)
oTable.setPosition(oPos)
TModel = oTable.Model
Cell = Tmodel.getCellByPosition(1,1)
Cell.FillStyle = com.sun.star.drawing.FillStyle.BITMAP
Cell.FillBitmapURL = "vnd.sun.star.GraphicObject:100000000000005E0000005EB758AAC8"
I got the URL for the Bitmap by filling in a cell by hand and using xray to determine what the FillBitmapURL was set to. There is probably a better way to do that.
OpenOffice 4.1 on Windows 10 and Linux Mint
If your question is answered, please go to your first post, select the Edit button, and add [Solved] to the beginning of the title.
jlmargot
Posts: 8
Joined: Wed May 13, 2009 11:53 am

Re: [Solved] Impress tables and api

Post by jlmargot »

FJCC wrote:I modified the code to add a bitmap to a chosen cell

Code: Select all

Dim oSize as New com.sun.star.awt.Size
Dim oPos as New com.sun.star.awt.Point
oSize.Width = 6000
oSize.Height = 6100
oPos.X = 6000
oPos.Y = 5000
oDoc = ThisComponent
DrawPages = oDoc.DrawPages
DPage = DrawPages.getByIndex(1)
oTable = oDoc.createInstance("com.sun.star.drawing.TableShape")
DPage.add(oTable)
oTable.Model.Rows.InsertByIndex(1,4)
oTable.Model.Columns.InsertByIndex(1,4)
oTable.setSize(oSize)
oTable.setPosition(oPos)
TModel = oTable.Model
Cell = Tmodel.getCellByPosition(1,1)
Cell.FillStyle = com.sun.star.drawing.FillStyle.BITMAP
Cell.FillBitmapURL = "vnd.sun.star.GraphicObject:100000000000005E0000005EB758AAC8"
I got the URL for the Bitmap by filling in a cell by hand and using xray to determine what the FillBitmapURL was set to. There is probably a better way to do that.
Thak you very much.

Instead of:
Cell.FillBitmapURL = "vnd.sun.star.GraphicObject:100000000000005E0000005EB758AAC8"
It is possible to use the bitmap name. For example:
Cell.FillBitmapName = "Flamme"
It works fine.

JLM
OOo 3.1.X on Ms Windows XP + LINUX
Post Reply