| View previous topic :: View next topic |
| Author |
Message |
manishpithwa General User

Joined: 25 Oct 2007 Posts: 17
|
Posted: Sun Oct 28, 2007 8:13 pm Post subject: insert OLE object of Calc sheet in writer document |
|
|
| I want to insert OLE object of calc sheet in writer document programatically. I also want to insert page of different orientation (Portrait/Landscape) in same writer document. for example if writer is have portrait orientation then I want to insert page of Landscape orientation. How can I do this programatically? |
|
| Back to top |
|
 |
vitcaro OOo Advocate


Joined: 20 Feb 2007 Posts: 256 Location: Italy
|
Posted: Mon Oct 29, 2007 12:43 am Post subject: |
|
|
This is a simlpe example of how to insert a spreadsheet document into a writer document. I hope this can help for your problem.
| Code: | sub Main
oDoc = ThisComponent
txt=oDoc.getText
Set TextCursor = txt.createTextCursor
Set TextEmbeddedObject = oDoc.createInstance("com.sun.star.text.TextEmbeddedObject")
Dim asize As New com.sun.star.awt.Size
asize.Height =10000
asize.Width = 10000
TextEmbeddedObject.CLSID = "47BBB4CB-CE4C-4E80-a591-42d9ae74950f"
txt.insertTextContent TextCursor, TextEmbeddedObject, False
TextEmbeddedObject.setSize asize
Set SpreadSheetDoc = TextEmbeddedObject.getEmbeddedObject
oSheets=SpreadSheetDoc.getSheets
oSheet = oSheets.getByIndex(0)
oCell = oSheet.getCellByPosition(0, 0)
oCell.setString "ABCD"
end sub
|
|
|
| Back to top |
|
 |
vbms Power User


Joined: 13 Aug 2007 Posts: 63
|
Posted: Mon Oct 29, 2007 1:14 am Post subject: |
|
|
or in java for powerpoint something like this...
| Code: |
XMultiServiceFactory xmsf = (XMultiServiceFactory)
UnoRuntime.queryInterface(XMultiServiceFactory.class, documentComponent);
// create an ole2shape
XShape oleShape = (XShape)UnoRuntime.queryInterface(com.sun.star.drawing.XShape.class,
xmsf.createInstance("com.sun.star.drawing.OLE2Shape"));
// insert the shape
oleShape.setPosition(new Point(500,500));
oleShape.setSize(new Size(27000,20000));
xShapes.add(oleShape);
// make the ole2shape a spreadsheet
XPropertySet aShapeProp = (XPropertySet)
UnoRuntime.queryInterface(XPropertySet.class, oleShape);
aShapeProp.setPropertyValue("CLSID", 47BBB4CB-CE4C-4E80-a591-42d9ae74950f);
// get the spreadsheets model
XComponent xComponent = (XComponent)
UnoRuntime.queryInterface(XComponent.class,
aShapeProp.getPropertyValue("Model"));
|
Last edited by vbms on Wed Oct 31, 2007 12:52 am; edited 1 time in total |
|
| Back to top |
|
 |
manishpithwa General User

Joined: 25 Oct 2007 Posts: 17
|
Posted: Wed Oct 31, 2007 12:22 am Post subject: |
|
|
where is calc file path, name and writer file path, name? which calc file I wil insert?
can I specify how many pages to insert? |
|
| Back to top |
|
 |
manishpithwa General User

Joined: 25 Oct 2007 Posts: 17
|
Posted: Wed Oct 31, 2007 8:01 pm Post subject: |
|
|
| vitcaro wrote: | This is a simlpe example of how to insert a spreadsheet document into a writer document. I hope this can help for your problem.
| Code: | sub Main
oDoc = ThisComponent
txt=oDoc.getText
Set TextCursor = txt.createTextCursor
Set TextEmbeddedObject = oDoc.createInstance("com.sun.star.text.TextEmbeddedObject")
Dim asize As New com.sun.star.awt.Size
asize.Height =10000
asize.Width = 10000
TextEmbeddedObject.CLSID = "47BBB4CB-CE4C-4E80-a591-42d9ae74950f"
txt.insertTextContent TextCursor, TextEmbeddedObject, False
TextEmbeddedObject.setSize asize
Set SpreadSheetDoc = TextEmbeddedObject.getEmbeddedObject
oSheets=SpreadSheetDoc.getSheets
oSheet = oSheets.getByIndex(0)
oCell = oSheet.getCellByPosition(0, 0)
oCell.setString "ABCD"
end sub
|
|
Where is Calc file name and writer file name ?
How will OO know which calc file is to be inserted in which writer file?
Please give me complete code... |
|
| Back to top |
|
 |
|