Object oClipboard = xServiceManager.createInstanceWithContext(
"com.sun.star.datatransfer.clipboard.SystemClipboard",
xOfficeContext);
XClipboard xClipboard = (XClipboard)
UnoRuntime.queryInterface(XClipboard.class, oClipboard);
//---------------------------------------------------
// registering as clipboard listener
//---------------------------------------------------
XClipboardNotifier xClipNotifier = (XClipboardNotifier)
UnoRuntime.queryInterface(XClipboardNotifier.class, oClipboard);
ClipboardListener aClipListener= new ClipboardListener();
xClipNotifier.addClipboardListener(aClipListener);
// Read ClipBoard
readClipBoard(xClipboard);
//---------------------------------------------------
// becoming a clipboard owner
//---------------------------------------------------
System.out.println("Becoming a clipboard owner...");
System.out.println("");
ClipboardOwner aClipOwner = new ClipboardOwner();
xClipboard.setContents(new TextTransferable("Hello World!"), aClipOwner);
int iFirst = 0;
while (aClipOwner.isClipboardOwner())
{
if (iFirst != 2) {