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.
[Solved] Impress tables and api
[Solved] Impress tables and api
Last edited by Hagar Delest on Wed Oct 21, 2009 2:55 pm, edited 1 time in total.
Reason: tagged [Solved].
Reason: tagged [Solved].
OOo 3.1.X on Ms Windows XP + LINUX
Re: Impress tables and api
I succeeded in inserting a table into a slide with the Basic code below.
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. 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.
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. 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.
If your question is answered, please go to your first post, select the Edit button, and add [Solved] to the beginning of the title.
Re: Impress tables and api
Thank you for your message. I tried your macro and it works.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. 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.
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
Re: [Solved] Impress tables and api
I modified the code to add a bitmap to a chosen cell
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.
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"
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.
If your question is answered, please go to your first post, select the Edit button, and add [Solved] to the beginning of the title.
Re: [Solved] Impress tables and api
Thak you very much.FJCC wrote:I modified the code to add a bitmap to a chosen cellI 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.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"
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