summaryrefslogtreecommitdiff
path: root/odk/examples/java/Text/WriterSelector.java
diff options
context:
space:
mode:
Diffstat (limited to 'odk/examples/java/Text/WriterSelector.java')
-rw-r--r--odk/examples/java/Text/WriterSelector.java48
1 files changed, 22 insertions, 26 deletions
diff --git a/odk/examples/java/Text/WriterSelector.java b/odk/examples/java/Text/WriterSelector.java
index 6fd00189d657..1343293a968a 100644
--- a/odk/examples/java/Text/WriterSelector.java
+++ b/odk/examples/java/Text/WriterSelector.java
@@ -57,32 +57,30 @@ public class WriterSelector {
xContext.getServiceManager();
// get a new instance of the desktop
- com.sun.star.frame.XDesktop xDesktop = (com.sun.star.frame.XDesktop)
- UnoRuntime.queryInterface(com.sun.star.frame.XDesktop.class,
- xMCF.createInstanceWithContext("com.sun.star.frame.Desktop",
- xContext ) );
+ com.sun.star.frame.XDesktop xDesktop = UnoRuntime.queryInterface(com.sun.star.frame.XDesktop.class,
+ xMCF.createInstanceWithContext("com.sun.star.frame.Desktop",
+ xContext ) );
com.sun.star.frame.XComponentLoader xCompLoader =
- (com.sun.star.frame.XComponentLoader)UnoRuntime.queryInterface(
- com.sun.star.frame.XComponentLoader.class, xDesktop);
+ UnoRuntime.queryInterface(
+ com.sun.star.frame.XComponentLoader.class, xDesktop);
com.sun.star.lang.XComponent xComponent =
xCompLoader.loadComponentFromURL("private:factory/swriter",
"_blank", 0, new com.sun.star.beans.PropertyValue[0]);
{
- com.sun.star.text.XTextDocument xDoc =(com.sun.star.text.XTextDocument)
- UnoRuntime.queryInterface(com.sun.star.text.XTextDocument.class,
- xComponent);
+ com.sun.star.text.XTextDocument xDoc =UnoRuntime.queryInterface(com.sun.star.text.XTextDocument.class,
+ xComponent);
xDoc.getText().setString("Please select something in this text and press then \"return\" in the shell where you have started the example.\n");
// ensure that the document content is optimal visible
com.sun.star.frame.XModel xModel =
- (com.sun.star.frame.XModel)UnoRuntime.queryInterface(
- com.sun.star.frame.XModel.class, xDoc);
+ UnoRuntime.queryInterface(
+ com.sun.star.frame.XModel.class, xDoc);
com.sun.star.view.XViewSettingsSupplier xViewSettings =
- (com.sun.star.view.XViewSettingsSupplier)UnoRuntime.queryInterface(
- com.sun.star.view.XViewSettingsSupplier.class, xModel.getCurrentController());
+ UnoRuntime.queryInterface(
+ com.sun.star.view.XViewSettingsSupplier.class, xModel.getCurrentController());
xViewSettings.getViewSettings().setPropertyValue(
"ZoomType", new Short((short)0));
}
@@ -101,28 +99,27 @@ public class WriterSelector {
com.sun.star.frame.XController xController = xframe.getController();
com.sun.star.view.XSelectionSupplier xSelSupplier =
- (com.sun.star.view.XSelectionSupplier)UnoRuntime.queryInterface(
- com.sun.star.view.XSelectionSupplier.class, xController );
+ UnoRuntime.queryInterface(
+ com.sun.star.view.XSelectionSupplier.class, xController );
Object oSelection = xSelSupplier.getSelection();
com.sun.star.lang.XServiceInfo xServInfo =
- (com.sun.star.lang.XServiceInfo)UnoRuntime.queryInterface(
- com.sun.star.lang.XServiceInfo.class, oSelection );
+ UnoRuntime.queryInterface(
+ com.sun.star.lang.XServiceInfo.class, oSelection );
if ( xServInfo.supportsService("com.sun.star.text.TextRanges") )
{
com.sun.star.container.XIndexAccess xIndexAccess =
- (com.sun.star.container.XIndexAccess)UnoRuntime.queryInterface(
- com.sun.star.container.XIndexAccess.class, oSelection);
+ UnoRuntime.queryInterface(
+ com.sun.star.container.XIndexAccess.class, oSelection);
int count = xIndexAccess.getCount();
com.sun.star.text.XTextRange xTextRange = null;
for ( int i = 0; i < count; i++ ) {
- xTextRange = (com.sun.star.text.XTextRange)
- UnoRuntime.queryInterface(
- com.sun.star.text.XTextRange.class,
- xIndexAccess.getByIndex(i));
+ xTextRange = UnoRuntime.queryInterface(
+ com.sun.star.text.XTextRange.class,
+ xIndexAccess.getByIndex(i));
System.out.println( "You have selected a text range: \""
+ xTextRange.getString() + "\"." );
@@ -141,9 +138,8 @@ public class WriterSelector {
// close test document
- com.sun.star.util.XCloseable xCloseable = (com.sun.star.util.XCloseable)
- UnoRuntime.queryInterface(com.sun.star.util.XCloseable.class,
- xComponent );
+ com.sun.star.util.XCloseable xCloseable = UnoRuntime.queryInterface(com.sun.star.util.XCloseable.class,
+ xComponent );
if (xCloseable != null ) {
xCloseable.close(false);