The demo consists of a UNO-component, that supports the
com.sun.star.lang.XMain
interface. The component can be started
using the uno.exe tool, which can be found in the binary output tree ( it is
not installed with OpenOffice ).
- Install an openoffice.
- Before program start, please open the
share/config/registry/instance/org/openoffice/Setup.xml file.
You need to modify the tag ooSetupConnectionURL.
Here's an example:
<ooSetupConnectionURL cfg:type="string" >socket,host=localhost,port=2002;urp;StarOffice.NamingService</ooSetupConnectionURL>
Alternatively you can start the office with the following commandline :
soffice "-accept=socket,host=localhost,port=2002;urp;StarOffice.NamingService"
- Start the office ( after starting the office, netstat -a | fgrep 2002 should signal,
that the port is being listened to ).
- Install the binary output tree of the current build.
- Checkout (toplevel) the api/odk module from openoffice.org.
- Build the api/odk/examples/cpp/officeclient directory (formerly api/odk/examples/officeclient).
- Make the api/odk/wntmsci3/bin (on unix api/odk/unxsols3/lib)
your current directory.
- Copy from the binary output tree the file wntmsci3/bin/applicat.rdb to the current
directory.
- Now execute the following :
Windows :
uno -l officeclientsample.dll -c com.sun.star.comp.odk.example.OfficeClientSample -r applicat.rdb -- uno:socket,host=localhost,port=2002;urp;StarOffice.NamingService
Unix :
uno -l libofficeclientsample.so -c com.sun.star.comp.odk.example.OfficeClientSample -r applicat.rdb -- 'uno:socket,host=localhost,port=2002;urp;StarOffice.NamingService'
The component now is instantiated by the uno.exe tool and connects to the
office. Please press any key when asked to do so. You should get the following
output on the shell :
OStorePageBIOS::verify(): close pending.
Connecting ....
Creating Socket. Family: 2 Type: 1 Protocol: 0
got the remote NamingService
press any key to open a new writer document ...
pasting some text into the writer document
press any key to close the document
press any key to open a new draw document ...
press any key to close the document
press any key to open a new schedule document ...
press any key to close the document
press any key to open a new calc document ...
press any key to close the document
|
|
The demo is implemented as component to show the usage of uno-exe. The advantage
(compared to writing an own executable, which would have been possible also) is,
that you do not have to care about the UNO bootstrapping.
The component first takes care, that all necessary shared libraries are
registered (registerServices) method. Afterwards it uses the
com.sun.star.bridge.UnoUrlResolver service to establish an
interprocess-bridge to the office.
Then it retrieves the remote servicemanager and furtheron the
com.sun.star.frame.Desktop service (which is a oneinstance
service).
Now it queries for the XComponentLoader interface and opens the
four empty documents on demand.
|