summaryrefslogtreecommitdiff
path: root/odk
diff options
context:
space:
mode:
authorStephan Bergmann <sbergman@redhat.com>2013-07-11 16:07:33 +0200
committerStephan Bergmann <sbergman@redhat.com>2013-07-11 16:07:48 +0200
commitb62d8e6b081d90d3b6e503f5cde9e70e370d671c (patch)
tree6fb9fd4987a3595c6164b587ad04b728bad4dc74 /odk
parent386af68921d8ae658b3704943b5f58603d7fbf83 (diff)
Adapt example to use retrofitted UNO service ctors
Change-Id: I85bf8e3fe76ff107cc3e611cc1103ca1f27fc00f
Diffstat (limited to 'odk')
-rw-r--r--odk/examples/DevelopersGuide/OfficeDev/Clipboard/Clipboard.java30
1 files changed, 9 insertions, 21 deletions
diff --git a/odk/examples/DevelopersGuide/OfficeDev/Clipboard/Clipboard.java b/odk/examples/DevelopersGuide/OfficeDev/Clipboard/Clipboard.java
index 9ad119e0bc7d..5dc01aa3fca1 100644
--- a/odk/examples/DevelopersGuide/OfficeDev/Clipboard/Clipboard.java
+++ b/odk/examples/DevelopersGuide/OfficeDev/Clipboard/Clipboard.java
@@ -32,15 +32,16 @@
*
*************************************************************************/
-import com.sun.star.lang.XMultiComponentFactory;
import com.sun.star.uno.XComponentContext;
import com.sun.star.uno.UnoRuntime;
-import com.sun.star.frame.XComponentLoader;
+import com.sun.star.frame.Desktop;
+import com.sun.star.frame.XDesktop2;
import com.sun.star.datatransfer.DataFlavor;
import com.sun.star.datatransfer.UnsupportedFlavorException;
import com.sun.star.datatransfer.XTransferable;
import com.sun.star.datatransfer.clipboard.XClipboard;
-import com.sun.star.datatransfer.clipboard.XClipboardNotifier;
+import com.sun.star.datatransfer.clipboard.SystemClipboard;
+import com.sun.star.datatransfer.clipboard.XSystemClipboard;
import com.sun.star.text.XTextDocument;
import com.sun.star.uno.AnyConverter;
@@ -59,18 +60,11 @@ public class Clipboard
XComponentContext xOfficeContext =
com.sun.star.comp.helper.Bootstrap.bootstrap();
System.out.println("Connected to a running office ...");
- // get the service manager from the office context
- XMultiComponentFactory xServiceManager =
- xOfficeContext.getServiceManager();
// create a new test document
- Object oDesktop = xServiceManager.createInstanceWithContext(
- "com.sun.star.frame.Desktop", xOfficeContext);
-
- XComponentLoader xCompLoader =UnoRuntime.queryInterface(XComponentLoader.class, oDesktop);
-
+ XDesktop2 xDesktop = Desktop.create(xOfficeContext);
com.sun.star.lang.XComponent xComponent =
- xCompLoader.loadComponentFromURL("private:factory/swriter",
+ xDesktop.loadComponentFromURL("private:factory/swriter",
"_blank", 0, new com.sun.star.beans.PropertyValue[0]);
{
XTextDocument xDoc =UnoRuntime.queryInterface(XTextDocument.class, xComponent);
@@ -93,21 +87,15 @@ public class Clipboard
}
// test document will be closed later
- Object oClipboard = xServiceManager.createInstanceWithContext(
- "com.sun.star.datatransfer.clipboard.SystemClipboard",
- xOfficeContext);
-
- XClipboard xClipboard = UnoRuntime.queryInterface(XClipboard.class, oClipboard);
+ XSystemClipboard xClipboard = SystemClipboard.create(xOfficeContext);
//---------------------------------------------------
// registering as clipboard listener
//---------------------------------------------------
- XClipboardNotifier xClipNotifier = UnoRuntime.queryInterface(XClipboardNotifier.class, oClipboard);
-
ClipboardListener aClipListener= new ClipboardListener();
- xClipNotifier.addClipboardListener(aClipListener);
+ xClipboard.addClipboardListener(aClipListener);
// Read ClipBoard
readClipBoard(xClipboard);
@@ -145,7 +133,7 @@ public class Clipboard
//---------------------------------------------------
// unregistering as clipboard listener
//---------------------------------------------------
- xClipNotifier.removeClipboardListener(aClipListener);
+ xClipboard.removeClipboardListener(aClipListener);
// close test document
com.sun.star.util.XCloseable xCloseable = UnoRuntime.queryInterface(com.sun.star.util.XCloseable.class,