I'm looking for sample code writting with PowerBuilder that call OpenOffice
on a windows computer.
What I want to do is : open a existing OpenOffice document, add some text
and save it with another fileName.
Thanks for your help
I don't understand anything in the API documentation.
For exemple, I suppose that I need XComponentLoader (supports simple api for
loading components into the frame environment)
http://api.openoffice.org/docs/common/ref/com/sun/star/frame/XComponentLoader.html
But I didn't see how to create it.
I find an exemple in Java, that open a calc document, but I dont understand
how to convert this in PB script.
try {
// get the remote office component context
xRemoteContext = com.sun.star.comp.helper.Bootstrap.bootstrap();
System.out.println("Connected to a running office ...");
xRemoteServiceManager = xRemoteContext.getServiceManager();
}
catch( Exception e) {
e.printStackTrace();
System.exit(1);
}
try {
// get the Desktop, we need its XComponentLoader interface to load a
new document
Object desktop = xRemoteServiceManager.createInstanceWithContext(
"com.sun.star.frame.Desktop", xRemoteContext);
// query the XComponentLoader interface from the desktop
XComponentLoader xComponentLoader =
(XComponentLoader)UnoRuntime.queryInterface(
XComponentLoader.class, desktop);
// create empty array of PropertyValue structs, needed for
loadComponentFromURL
PropertyValue[] loadProps = new PropertyValue[0];
// load new calc file
XComponent xSpreadsheetComponent =
xComponentLoader.loadComponentFromURL(
"private:factory/scalc", "_blank", 0, loadProps);
// query its XSpreadsheetDocument interface, we want to use
getSheets()
XSpreadsheetDocument xSpreadsheetDocument =
(XSpreadsheetDocument)UnoRuntime.queryInterface(
XSpreadsheetDocument.class, xSpreadsheetComponent);
Any information that can help me?
Thanks
<Mitch> a écrit dans le message de news:
45db2ad6.193...@sybase.com...
So this is the exemple that open an existing file and save it to MS Word :
// Création du Service Manager
// -----------------------------
OLEObject objServiceManager
objServiceManager = CREATE OLEObject
IF objServiceManager.ConnectToNewObject("com.sun.star.ServiceManager") < 0
Then
messagebox("OLE Error", "Cound not connect to Open Office")
End IF
// Create the Desktop
// --------------------
OLEobject objDesktop
objDesktop= objServiceManager.createInstance("com.sun.star.frame.Desktop")
// Load File from disk
// -------------------
String args[]
String ls_url
ls_url = "file:///" + "myfile.sxw" // Specify file name correctly
on you HD
OLEobject objDoc
objDoc = objDesktop.loadComponentFromURL(ls_url, "_blank", 0, args)
// Create PropertyValue for save
// -------------------------------
OLEObject objPropertyValue[]
objPropertyValue[1] =
objServiceManager.Bridge_GetStruct("com.sun.star.beans.PropertyValue")
objPropertyValue[1].Name = "FilterName"
objPropertyValue[1].Value = "MS Word 97"
String ls_newUrl
ls_newUrl = "file:///" + "myfile.doc" // Specify new file name
correctly
objDoc.storeToURL(ls_newUrl, objPropertyValue[])
// Close file
// ---------
objDoc.dispose()
// Free object
// ------------
objServiceManager.disconnectobject()
destroy objServiceManager