diff options
Diffstat (limited to 'odk/examples/DevelopersGuide/OfficeDev')
17 files changed, 121 insertions, 144 deletions
diff --git a/odk/examples/DevelopersGuide/OfficeDev/Clipboard/Clipboard.java b/odk/examples/DevelopersGuide/OfficeDev/Clipboard/Clipboard.java index b4f6a469cc9f..9ad119e0bc7d 100644 --- a/odk/examples/DevelopersGuide/OfficeDev/Clipboard/Clipboard.java +++ b/odk/examples/DevelopersGuide/OfficeDev/Clipboard/Clipboard.java @@ -67,29 +67,27 @@ public class Clipboard Object oDesktop = xServiceManager.createInstanceWithContext( "com.sun.star.frame.Desktop", xOfficeContext); - XComponentLoader xCompLoader =(XComponentLoader) - UnoRuntime.queryInterface(XComponentLoader.class, oDesktop); + XComponentLoader xCompLoader =UnoRuntime.queryInterface(XComponentLoader.class, oDesktop); com.sun.star.lang.XComponent xComponent = xCompLoader.loadComponentFromURL("private:factory/swriter", "_blank", 0, new com.sun.star.beans.PropertyValue[0]); { - XTextDocument xDoc =(XTextDocument) - UnoRuntime.queryInterface(XTextDocument.class, xComponent); + XTextDocument xDoc =UnoRuntime.queryInterface(XTextDocument.class, xComponent); xDoc.getText().setString("In the first step, paste the current content of the clipboard in the document!\nThe text \"Hello world!\" shall be insert at the current cursor position below.\n\nIn the second step, please select some words and put it into the clipboard! ...\n\nCurrent clipboard content = "); // 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); // get the frame for later usage com.sun.star.frame.XFrame xFrame = xModel.getCurrentController().getFrame(); 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)); } @@ -99,15 +97,13 @@ public class Clipboard "com.sun.star.datatransfer.clipboard.SystemClipboard", xOfficeContext); - XClipboard xClipboard = (XClipboard) - UnoRuntime.queryInterface(XClipboard.class, oClipboard); + XClipboard xClipboard = UnoRuntime.queryInterface(XClipboard.class, oClipboard); //--------------------------------------------------- // registering as clipboard listener //--------------------------------------------------- - XClipboardNotifier xClipNotifier = (XClipboardNotifier) - UnoRuntime.queryInterface(XClipboardNotifier.class, oClipboard); + XClipboardNotifier xClipNotifier = UnoRuntime.queryInterface(XClipboardNotifier.class, oClipboard); ClipboardListener aClipListener= new ClipboardListener(); @@ -152,9 +148,8 @@ public class Clipboard xClipNotifier.removeClipboardListener(aClipListener); // 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); diff --git a/odk/examples/DevelopersGuide/OfficeDev/ContextMenuInterceptor.java b/odk/examples/DevelopersGuide/OfficeDev/ContextMenuInterceptor.java index d0d2c5756daf..67d0331b2c29 100644 --- a/odk/examples/DevelopersGuide/OfficeDev/ContextMenuInterceptor.java +++ b/odk/examples/DevelopersGuide/OfficeDev/ContextMenuInterceptor.java @@ -57,8 +57,8 @@ public class ContextMenuInterceptor implements XContextMenuInterceptor { // create a new test document 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", @@ -67,23 +67,22 @@ public class ContextMenuInterceptor implements XContextMenuInterceptor { // intialize the test document com.sun.star.frame.XFrame xFrame = null; { - 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); String infoMsg = new String("All context menus of the created document frame contains now a 'Help' entry with the submenus 'Content', 'Help Agent' and 'Tips'.\n\nPress 'Return' in the shell to remove the context menu interceptor and finish the example!"); xDoc.getText().setString(infoMsg); // 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); // get the frame for later usage xFrame = xModel.getCurrentController().getFrame(); 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)); } @@ -93,13 +92,13 @@ public class ContextMenuInterceptor implements XContextMenuInterceptor { com.sun.star.frame.XController xController = xFrame.getController(); if ( xController != null ) { com.sun.star.ui.XContextMenuInterception xContextMenuInterception = - (com.sun.star.ui.XContextMenuInterception)UnoRuntime.queryInterface( - com.sun.star.ui.XContextMenuInterception.class, xController ); + UnoRuntime.queryInterface( + com.sun.star.ui.XContextMenuInterception.class, xController ); if( xContextMenuInterception != null ) { ContextMenuInterceptor aContextMenuInterceptor = new ContextMenuInterceptor(); com.sun.star.ui.XContextMenuInterceptor xContextMenuInterceptor = - (com.sun.star.ui.XContextMenuInterceptor)UnoRuntime.queryInterface( - com.sun.star.ui.XContextMenuInterceptor.class, aContextMenuInterceptor ); + UnoRuntime.queryInterface( + com.sun.star.ui.XContextMenuInterceptor.class, aContextMenuInterceptor ); xContextMenuInterception.registerContextMenuInterceptor( xContextMenuInterceptor ); System.out.println( "\n ... all context menus of the created document frame contains now a 'Help' entry with the\n submenus 'Content', 'Help Agent' and 'Tips'.\n\nPress 'Return' to remove the context menu interceptor and finish the example!"); @@ -115,9 +114,8 @@ public class ContextMenuInterceptor implements XContextMenuInterceptor { } // 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); @@ -156,41 +154,41 @@ public class ContextMenuInterceptor implements XContextMenuInterceptor { // create sub menus, menu entries and separators com.sun.star.container.XIndexContainer xContextMenu = aEvent.ActionTriggerContainer; com.sun.star.lang.XMultiServiceFactory xMenuElementFactory = - (com.sun.star.lang.XMultiServiceFactory)UnoRuntime.queryInterface( - com.sun.star.lang.XMultiServiceFactory.class, xContextMenu ); + UnoRuntime.queryInterface( + com.sun.star.lang.XMultiServiceFactory.class, xContextMenu ); if ( xMenuElementFactory != null ) { // create root menu entry and sub menu com.sun.star.beans.XPropertySet xRootMenuEntry = - (XPropertySet)UnoRuntime.queryInterface( - com.sun.star.beans.XPropertySet.class, - xMenuElementFactory.createInstance( "com.sun.star.ui.ActionTrigger" )); + UnoRuntime.queryInterface( + com.sun.star.beans.XPropertySet.class, + xMenuElementFactory.createInstance( "com.sun.star.ui.ActionTrigger" )); // create a line separator for our new help sub menu com.sun.star.beans.XPropertySet xSeparator = - (com.sun.star.beans.XPropertySet)UnoRuntime.queryInterface( - com.sun.star.beans.XPropertySet.class, - xMenuElementFactory.createInstance( "com.sun.star.ui.ActionTriggerSeparator" )); + UnoRuntime.queryInterface( + com.sun.star.beans.XPropertySet.class, + xMenuElementFactory.createInstance( "com.sun.star.ui.ActionTriggerSeparator" )); Short aSeparatorType = new Short( ActionTriggerSeparatorType.LINE ); - xSeparator.setPropertyValue( "SeparatorType", (Object)aSeparatorType ); + xSeparator.setPropertyValue( "SeparatorType", aSeparatorType ); // query sub menu for index container to get access com.sun.star.container.XIndexContainer xSubMenuContainer = - (com.sun.star.container.XIndexContainer)UnoRuntime.queryInterface( - com.sun.star.container.XIndexContainer.class, - xMenuElementFactory.createInstance( - "com.sun.star.ui.ActionTriggerContainer" )); + UnoRuntime.queryInterface( + com.sun.star.container.XIndexContainer.class, + xMenuElementFactory.createInstance( + "com.sun.star.ui.ActionTriggerContainer" )); // intialize root menu entry xRootMenuEntry.setPropertyValue( "Text", new String( "Help" )); xRootMenuEntry.setPropertyValue( "CommandURL", new String( "slot:5410" )); xRootMenuEntry.setPropertyValue( "HelpURL", new String( "5410" )); - xRootMenuEntry.setPropertyValue( "SubContainer", (Object)xSubMenuContainer ); + xRootMenuEntry.setPropertyValue( "SubContainer", xSubMenuContainer ); // create menu entries for the new sub menu // intialize help/content menu entry - XPropertySet xMenuEntry = (XPropertySet)UnoRuntime.queryInterface( + XPropertySet xMenuEntry = UnoRuntime.queryInterface( XPropertySet.class, xMenuElementFactory.createInstance( "com.sun.star.ui.ActionTrigger" )); @@ -199,10 +197,10 @@ public class ContextMenuInterceptor implements XContextMenuInterceptor { xMenuEntry.setPropertyValue( "HelpURL", new String( "5401" )); // insert menu entry to sub menu - xSubMenuContainer.insertByIndex( 0, (Object)xMenuEntry ); + xSubMenuContainer.insertByIndex( 0, xMenuEntry ); // intialize help/help agent - xMenuEntry = (com.sun.star.beans.XPropertySet)UnoRuntime.queryInterface( + xMenuEntry = UnoRuntime.queryInterface( com.sun.star.beans.XPropertySet.class, xMenuElementFactory.createInstance( "com.sun.star.ui.ActionTrigger" )); @@ -211,10 +209,10 @@ public class ContextMenuInterceptor implements XContextMenuInterceptor { xMenuEntry.setPropertyValue( "HelpURL", new String( "5962" )); // insert menu entry to sub menu - xSubMenuContainer.insertByIndex( 1, (Object)xMenuEntry ); + xSubMenuContainer.insertByIndex( 1, xMenuEntry ); // intialize help/tips - xMenuEntry = (com.sun.star.beans.XPropertySet)UnoRuntime.queryInterface( + xMenuEntry = UnoRuntime.queryInterface( com.sun.star.beans.XPropertySet.class, xMenuElementFactory.createInstance( "com.sun.star.ui.ActionTrigger" )); @@ -223,13 +221,13 @@ public class ContextMenuInterceptor implements XContextMenuInterceptor { xMenuEntry.setPropertyValue( "HelpURL", new String( "5404" )); // insert menu entry to sub menu - xSubMenuContainer.insertByIndex( 2, (Object)xMenuEntry ); + xSubMenuContainer.insertByIndex( 2, xMenuEntry ); // add separator into the given context menu - xContextMenu.insertByIndex( 0, (Object)xSeparator ); + xContextMenu.insertByIndex( 0, xSeparator ); // add new sub menu into the given context menu - xContextMenu.insertByIndex( 0, (Object)xRootMenuEntry ); + xContextMenu.insertByIndex( 0, xRootMenuEntry ); // The controller should execute the modified context menu and stop notifying other // interceptors. diff --git a/odk/examples/DevelopersGuide/OfficeDev/DisableCommands/DisableCommandsTest.java b/odk/examples/DevelopersGuide/OfficeDev/DisableCommands/DisableCommandsTest.java index 963ced576d43..f81c59afca31 100644 --- a/odk/examples/DevelopersGuide/OfficeDev/DisableCommands/DisableCommandsTest.java +++ b/odk/examples/DevelopersGuide/OfficeDev/DisableCommands/DisableCommandsTest.java @@ -76,30 +76,26 @@ public class DisableCommandsTest extends java.lang.Object { Object transformer = xRemoteServiceManager.createInstanceWithContext( "com.sun.star.util.URLTransformer", xRemoteContext ); - xTransformer = (com.sun.star.util.XURLTransformer) - UnoRuntime.queryInterface(com.sun.star.util.XURLTransformer.class, - transformer ); + xTransformer = UnoRuntime.queryInterface(com.sun.star.util.XURLTransformer.class, + transformer ); Object configProvider = xRemoteServiceManager.createInstanceWithContext( "com.sun.star.configuration.ConfigurationProvider", xRemoteContext ); - xConfigProvider = (com.sun.star.lang.XMultiServiceFactory) - UnoRuntime.queryInterface( - com.sun.star.lang.XMultiServiceFactory.class, configProvider ); + xConfigProvider = UnoRuntime.queryInterface( + com.sun.star.lang.XMultiServiceFactory.class, configProvider ); // create a new test document Object oDesktop = xRemoteServiceManager.createInstanceWithContext( "com.sun.star.frame.Desktop", xRemoteContext); - XComponentLoader xCompLoader =(XComponentLoader) - UnoRuntime.queryInterface(XComponentLoader.class, oDesktop); + XComponentLoader xCompLoader =UnoRuntime.queryInterface(XComponentLoader.class, oDesktop); com.sun.star.lang.XComponent xComponent = xCompLoader.loadComponentFromURL("private:factory/swriter", "_blank", 0, new com.sun.star.beans.PropertyValue[0]); { - XTextDocument xDoc =(XTextDocument) - UnoRuntime.queryInterface(XTextDocument.class, xComponent); + XTextDocument xDoc =UnoRuntime.queryInterface(XTextDocument.class, xComponent); xDoc.getText().setString("You can now check the disabled commands. The " +"following commands are disabled:\n\n" +" Open...\n Exit\n Select All\n " @@ -112,16 +108,16 @@ public class DisableCommandsTest extends java.lang.Object { // 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); // get the frame for later usage com.sun.star.frame.XFrame xFrame = xModel.getCurrentController().getFrame(); 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)); } @@ -157,9 +153,8 @@ public class DisableCommandsTest extends java.lang.Object { waitForUserInput(); // 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); @@ -196,15 +191,14 @@ public class DisableCommandsTest extends java.lang.Object { // We need the desktop to get access to the current frame Object desktop = xRemoteServiceManager.createInstanceWithContext( "com.sun.star.frame.Desktop", xRemoteContext ); - com.sun.star.frame.XDesktop xDesktop = (com.sun.star.frame.XDesktop) - UnoRuntime.queryInterface(com.sun.star.frame.XDesktop.class, desktop ); + com.sun.star.frame.XDesktop xDesktop = UnoRuntime.queryInterface(com.sun.star.frame.XDesktop.class, desktop ); com.sun.star.frame.XFrame xFrame = xDesktop.getCurrentFrame(); com.sun.star.frame.XDispatchProvider xDispatchProvider = null; if ( xFrame != null ) { // We have a frame. Now we need access to the dispatch provider. xDispatchProvider = - (com.sun.star.frame.XDispatchProvider)UnoRuntime.queryInterface( + UnoRuntime.queryInterface( com.sun.star.frame.XDispatchProvider.class, xFrame ); if ( xDispatchProvider != null ) { @@ -272,15 +266,14 @@ public class DisableCommandsTest extends java.lang.Object { lParams ); com.sun.star.container.XNameAccess xNameAccess = - (com.sun.star.container.XNameAccess)UnoRuntime.queryInterface( - com.sun.star.container.XNameAccess.class, xAccess ); + UnoRuntime.queryInterface( + com.sun.star.container.XNameAccess.class, xAccess ); if ( xNameAccess != null ) { // We need the XNameContainer interface to remove the nodes by name com.sun.star.container.XNameContainer xNameContainer = - (com.sun.star.container.XNameContainer) UnoRuntime.queryInterface( - com.sun.star.container.XNameContainer.class, xAccess ); + com.sun.star.container.XNameContainer.class, xAccess ); // Retrieves the names of all Disabled nodes String[] aCommandsSeq = xNameAccess.getElementNames(); @@ -298,8 +291,8 @@ public class DisableCommandsTest extends java.lang.Object { // Commit our changes com.sun.star.util.XChangesBatch xFlush = - (com.sun.star.util.XChangesBatch)UnoRuntime.queryInterface( - com.sun.star.util.XChangesBatch.class, xAccess); + UnoRuntime.queryInterface( + com.sun.star.util.XChangesBatch.class, xAccess); xFlush.commitChanges(); } @@ -329,12 +322,12 @@ public class DisableCommandsTest extends java.lang.Object { lParams ); com.sun.star.lang.XSingleServiceFactory xSetElementFactory = - (com.sun.star.lang.XSingleServiceFactory)UnoRuntime.queryInterface( - com.sun.star.lang.XSingleServiceFactory.class, xAccess ); + UnoRuntime.queryInterface( + com.sun.star.lang.XSingleServiceFactory.class, xAccess ); com.sun.star.container.XNameContainer xNameContainer = - (com.sun.star.container.XNameContainer)UnoRuntime.queryInterface( - com.sun.star.container.XNameContainer.class, xAccess ); + UnoRuntime.queryInterface( + com.sun.star.container.XNameContainer.class, xAccess ); if ( xSetElementFactory != null && xNameContainer != null ) { Object[] aArgs = new Object[0]; @@ -349,10 +342,9 @@ public class DisableCommandsTest extends java.lang.Object { // We have a new node. To set the properties of the node // we need the XPropertySet interface. com.sun.star.beans.XPropertySet xPropertySet = - (com.sun.star.beans.XPropertySet) UnoRuntime.queryInterface( - com.sun.star.beans.XPropertySet.class, - xNewElement ); + com.sun.star.beans.XPropertySet.class, + xNewElement ); if ( xPropertySet != null ) { // Create a unique node name. @@ -370,8 +362,8 @@ public class DisableCommandsTest extends java.lang.Object { // Commit our changes com.sun.star.util.XChangesBatch xFlush = - (com.sun.star.util.XChangesBatch)UnoRuntime.queryInterface( - com.sun.star.util.XChangesBatch.class, xAccess); + UnoRuntime.queryInterface( + com.sun.star.util.XChangesBatch.class, xAccess); xFlush.commitChanges(); } } diff --git a/odk/examples/DevelopersGuide/OfficeDev/FilterDevelopment/AsciiFilter/AsciiReplaceFilter.java b/odk/examples/DevelopersGuide/OfficeDev/FilterDevelopment/AsciiFilter/AsciiReplaceFilter.java index 6d6db31ebe58..f62c2e54991a 100644 --- a/odk/examples/DevelopersGuide/OfficeDev/FilterDevelopment/AsciiFilter/AsciiReplaceFilter.java +++ b/odk/examples/DevelopersGuide/OfficeDev/FilterDevelopment/AsciiFilter/AsciiReplaceFilter.java @@ -257,7 +257,7 @@ public class AsciiReplaceFilter if (xDocument==null) throw new com.sun.star.lang.IllegalArgumentException("null reference detected"); - com.sun.star.lang.XServiceInfo xInfo = (com.sun.star.lang.XServiceInfo)UnoRuntime.queryInterface( + com.sun.star.lang.XServiceInfo xInfo = UnoRuntime.queryInterface( com.sun.star.lang.XServiceInfo.class, xDocument); if ( ! xInfo.supportsService("com.sun.star.text.TextDocument") ) throw new com.sun.star.lang.IllegalArgumentException( "wrong document type" ); @@ -266,7 +266,7 @@ public class AsciiReplaceFilter // Don't forget to mark this filter used for importing too synchronized(this) { - m_xDocument = (com.sun.star.text.XTextDocument)UnoRuntime.queryInterface( + m_xDocument = UnoRuntime.queryInterface( com.sun.star.text.XTextDocument.class, xDocument); m_bImport = true; } @@ -293,7 +293,7 @@ public class AsciiReplaceFilter if (xDocument==null) throw new com.sun.star.lang.IllegalArgumentException( "null reference given" ); - com.sun.star.lang.XServiceInfo xInfo = (com.sun.star.lang.XServiceInfo)UnoRuntime.queryInterface( + com.sun.star.lang.XServiceInfo xInfo = UnoRuntime.queryInterface( com.sun.star.lang.XServiceInfo.class, xDocument); if ( ! xInfo.supportsService("com.sun.star.text.TextDocument") ) throw new com.sun.star.lang.IllegalArgumentException( "wrong document type" ); @@ -302,7 +302,7 @@ public class AsciiReplaceFilter // Don't forget to mark this filter used for exporting too synchronized(this) { - m_xDocument = (com.sun.star.text.XTextDocument)UnoRuntime.queryInterface( + m_xDocument = UnoRuntime.queryInterface( com.sun.star.text.XTextDocument.class, xDocument); m_bImport = false; } @@ -413,7 +413,7 @@ public class AsciiReplaceFilter { measure("implts_import {"); - com.sun.star.text.XSimpleText xText = (com.sun.star.text.XSimpleText)UnoRuntime.queryInterface( + com.sun.star.text.XSimpleText xText = UnoRuntime.queryInterface( com.sun.star.text.XSimpleText.class, xTarget.getText()); @@ -463,7 +463,7 @@ public class AsciiReplaceFilter int nEnd = -1; int nLength = sText.length(); - com.sun.star.text.XTextRange xCursor = (com.sun.star.text.XTextRange)UnoRuntime.queryInterface( + com.sun.star.text.XTextRange xCursor = UnoRuntime.queryInterface( com.sun.star.text.XTextRange.class, xText.createTextCursor()); @@ -498,7 +498,7 @@ public class AsciiReplaceFilter measure("set on model"); // with refreshing the document we are on the safe-side, otherwise the first time the filter is used the document is not fully shown (flaw!). - com.sun.star.util.XRefreshable xRefresh = (com.sun.star.util.XRefreshable)UnoRuntime.queryInterface( + com.sun.star.util.XRefreshable xRefresh = UnoRuntime.queryInterface( com.sun.star.util.XRefreshable.class, xTarget); xRefresh.refresh(); @@ -545,7 +545,7 @@ public class AsciiReplaceFilter { measure("implts_export {"); - com.sun.star.text.XTextRange xText = (com.sun.star.text.XSimpleText)UnoRuntime.queryInterface( + com.sun.star.text.XTextRange xText = UnoRuntime.queryInterface( com.sun.star.text.XSimpleText.class, xSource.getText()); diff --git a/odk/examples/DevelopersGuide/OfficeDev/FilterDevelopment/AsciiFilter/FilterOptions.java b/odk/examples/DevelopersGuide/OfficeDev/FilterDevelopment/AsciiFilter/FilterOptions.java index e882e089b0e4..bec6966999c2 100644 --- a/odk/examples/DevelopersGuide/OfficeDev/FilterDevelopment/AsciiFilter/FilterOptions.java +++ b/odk/examples/DevelopersGuide/OfficeDev/FilterDevelopment/AsciiFilter/FilterOptions.java @@ -203,7 +203,7 @@ public class FilterOptions private void impl_openStreams( boolean bImport ) { try{ - com.sun.star.ucb.XSimpleFileAccess xHelper = (com.sun.star.ucb.XSimpleFileAccess)UnoRuntime.queryInterface( + com.sun.star.ucb.XSimpleFileAccess xHelper = UnoRuntime.queryInterface( com.sun.star.ucb.XSimpleFileAccess.class, m_xMCF.createInstanceWithContext("com.sun.star.ucb.SimpleFileAccess", m_Ctx)); if (xHelper!=null) diff --git a/odk/examples/DevelopersGuide/OfficeDev/FilterDevelopment/FlatXmlFilter_java/FlatXml.java b/odk/examples/DevelopersGuide/OfficeDev/FilterDevelopment/FlatXmlFilter_java/FlatXml.java index ea62ae19754d..3bb11f322136 100644 --- a/odk/examples/DevelopersGuide/OfficeDev/FilterDevelopment/FlatXmlFilter_java/FlatXml.java +++ b/odk/examples/DevelopersGuide/OfficeDev/FilterDevelopment/FlatXmlFilter_java/FlatXml.java @@ -133,7 +133,7 @@ public class FlatXml implements XImportFilter, XExportFilter, XServiceName, Object tmpObj=m_xServiceFactory.createInstance("com.sun.star.xml.sax.Parser"); if (tmpObj == null) return false; - XParser xParser = (XParser)UnoRuntime.queryInterface(XParser.class , tmpObj); + XParser xParser = UnoRuntime.queryInterface(XParser.class , tmpObj); if (xParser == null) return false; InputSource aInput = new InputSource(); @@ -174,13 +174,13 @@ public class FlatXml implements XImportFilter, XExportFilter, XServiceName, { tmpObj = m_xServiceFactory.createInstance("com.sun.star.xml.sax.Writer"); if (tmpObj != null) - m_xHandler = (XExtendedDocumentHandler)UnoRuntime.queryInterface(XExtendedDocumentHandler.class, tmpObj); + m_xHandler = UnoRuntime.queryInterface(XExtendedDocumentHandler.class, tmpObj); } if (m_xHandler == null) return false; // Connect the provided output stream to the writer - XActiveDataSource xADSource = (XActiveDataSource)UnoRuntime.queryInterface( + XActiveDataSource xADSource = UnoRuntime.queryInterface( XActiveDataSource.class, m_xHandler); if (xADSource != null && xos != null) diff --git a/odk/examples/DevelopersGuide/OfficeDev/Linguistic/LinguisticExamples.java b/odk/examples/DevelopersGuide/OfficeDev/Linguistic/LinguisticExamples.java index b21190d173aa..7cdf7f68b381 100644 --- a/odk/examples/DevelopersGuide/OfficeDev/Linguistic/LinguisticExamples.java +++ b/odk/examples/DevelopersGuide/OfficeDev/Linguistic/LinguisticExamples.java @@ -113,8 +113,7 @@ public class LinguisticExamples if (mxRemoteContext != null && mxRemoteServiceManager != null) { Object aObj = mxRemoteServiceManager.createInstanceWithContext( "com.sun.star.linguistic2.LinguServiceManager", mxRemoteContext ); - mxLinguSvcMgr = (XLinguServiceManager) - UnoRuntime.queryInterface(XLinguServiceManager.class, aObj); + mxLinguSvcMgr = UnoRuntime.queryInterface(XLinguServiceManager.class, aObj); } return mxLinguSvcMgr != null; } @@ -291,7 +290,7 @@ public class LinguisticExamples // get access to LinguProperties property set Object aObj = mxRemoteServiceManager.createInstanceWithContext( "com.sun.star.linguistic2.LinguProperties", mxRemoteContext); - XPropertySet aLinguProps = (XPropertySet) UnoRuntime.queryInterface( + XPropertySet aLinguProps = UnoRuntime.queryInterface( XPropertySet.class,aObj); // set a spellchecker and hyphenator property value to a defined state diff --git a/odk/examples/DevelopersGuide/OfficeDev/Linguistic/OneInstanceFactory.java b/odk/examples/DevelopersGuide/OfficeDev/Linguistic/OneInstanceFactory.java index 05f34cc6ab85..114d1bda2e94 100644 --- a/odk/examples/DevelopersGuide/OfficeDev/Linguistic/OneInstanceFactory.java +++ b/odk/examples/DevelopersGuide/OfficeDev/Linguistic/OneInstanceFactory.java @@ -90,14 +90,14 @@ public class OneInstanceFactory implements //!! workaround for services not always being created //!! via 'createInstanceWithArguments' - XInitialization xIni = (XInitialization) UnoRuntime.queryInterface( + XInitialization xIni = UnoRuntime.queryInterface( XInitialization.class, createInstance()); if (xIni != null) { Object[] aArguments = new Object[]{ null, null }; if (xMultiFactory != null) { - XPropertySet xPropSet = (XPropertySet) UnoRuntime.queryInterface( + XPropertySet xPropSet = UnoRuntime.queryInterface( XPropertySet.class , xMultiFactory.createInstance( "com.sun.star.linguistic2.LinguProperties" ) ); aArguments[0] = xPropSet; @@ -114,7 +114,7 @@ public class OneInstanceFactory implements { if (xInstantiatedService == null) { - XInitialization xIni = (XInitialization) UnoRuntime.queryInterface( + XInitialization xIni = UnoRuntime.queryInterface( XInitialization.class, createInstance()); if (xIni != null) xIni.initialize( aArguments ); diff --git a/odk/examples/DevelopersGuide/OfficeDev/Linguistic/PropChgHelper.java b/odk/examples/DevelopersGuide/OfficeDev/Linguistic/PropChgHelper.java index 498a8919b20c..2932a7791367 100644 --- a/odk/examples/DevelopersGuide/OfficeDev/Linguistic/PropChgHelper.java +++ b/odk/examples/DevelopersGuide/OfficeDev/Linguistic/PropChgHelper.java @@ -83,7 +83,7 @@ public class PropChgHelper implements for (int i = 0; i < nCnt; ++i) { XLinguServiceEventListener xLstnr = - (XLinguServiceEventListener) aLngSvcEvtListeners.get(i); + aLngSvcEvtListeners.get(i); if (xLstnr != null) xLstnr.processLinguServiceEvent( aEvt ); } @@ -105,7 +105,7 @@ public class PropChgHelper implements { try { xPropSet.addPropertyChangeListener( - aPropNames[i], (XPropertyChangeListener) this ); + aPropNames[i], this ); } catch( Exception e ) { } @@ -125,7 +125,7 @@ public class PropChgHelper implements { try { xPropSet.removePropertyChangeListener( - aPropNames[i], (XPropertyChangeListener) this ); + aPropNames[i], this ); } catch( Exception e ) { } diff --git a/odk/examples/DevelopersGuide/OfficeDev/Linguistic/SampleHyphenator.java b/odk/examples/DevelopersGuide/OfficeDev/Linguistic/SampleHyphenator.java index a81aad0e1ab6..d786d0ad98b3 100644 --- a/odk/examples/DevelopersGuide/OfficeDev/Linguistic/SampleHyphenator.java +++ b/odk/examples/DevelopersGuide/OfficeDev/Linguistic/SampleHyphenator.java @@ -84,7 +84,7 @@ public class SampleHyphenator extends ComponentBase implements "HyphMinTrailing", "HyphMinWordLength" }; - aPropChgHelper = new PropChgHelper_Hyph( (XHyphenator) this, aProps ); + aPropChgHelper = new PropChgHelper_Hyph( this, aProps ); aEvtListeners = new ArrayList<Object>();; bDisposing = false; } @@ -442,7 +442,7 @@ public class SampleHyphenator extends ComponentBase implements int nLen = aArguments.length; if (2 == nLen) { - XPropertySet xPropSet = (XPropertySet)UnoRuntime.queryInterface( + XPropertySet xPropSet = UnoRuntime.queryInterface( XPropertySet.class, aArguments[0]); // start listening to property changes aPropChgHelper.AddAsListenerTo( xPropSet ); diff --git a/odk/examples/DevelopersGuide/OfficeDev/Linguistic/SampleSpellChecker.java b/odk/examples/DevelopersGuide/OfficeDev/Linguistic/SampleSpellChecker.java index 10ec0aa9f46e..c4c61eb73beb 100644 --- a/odk/examples/DevelopersGuide/OfficeDev/Linguistic/SampleSpellChecker.java +++ b/odk/examples/DevelopersGuide/OfficeDev/Linguistic/SampleSpellChecker.java @@ -84,7 +84,7 @@ public class SampleSpellChecker extends ComponentBase implements "IsSpellWithDigits", "IsSpellCapitalization" }; - aPropChgHelper = new PropChgHelper_Spell( (XSpellChecker) this, aProps ); + aPropChgHelper = new PropChgHelper_Spell( this, aProps ); aEvtListeners = new ArrayList<Object>(); bDisposing = false; } @@ -386,7 +386,7 @@ public class SampleSpellChecker extends ComponentBase implements int nLen = aArguments.length; if (2 == nLen) { - XPropertySet xPropSet = (XPropertySet)UnoRuntime.queryInterface( + XPropertySet xPropSet = UnoRuntime.queryInterface( XPropertySet.class, aArguments[0]); // start listening to property changes aPropChgHelper.AddAsListenerTo( xPropSet ); diff --git a/odk/examples/DevelopersGuide/OfficeDev/Linguistic/SampleThesaurus.java b/odk/examples/DevelopersGuide/OfficeDev/Linguistic/SampleThesaurus.java index e33929a4b77a..fb8c96f3bcfe 100644 --- a/odk/examples/DevelopersGuide/OfficeDev/Linguistic/SampleThesaurus.java +++ b/odk/examples/DevelopersGuide/OfficeDev/Linguistic/SampleThesaurus.java @@ -80,7 +80,7 @@ public class SampleThesaurus extends ComponentBase implements // which is here basically used only to keep track of the // property set (and it's lifetime) since it gets used in the // 'GetValueToUse' function - aPropChgHelper = new PropChgHelper( (XThesaurus) this, aProps ); + aPropChgHelper = new PropChgHelper( this, aProps ); aEvtListeners = new ArrayList<Object>(); bDisposing = false; @@ -222,7 +222,7 @@ public class SampleThesaurus extends ComponentBase implements int nLen = aArguments.length; if (2 == nLen) { - XPropertySet xPropSet = (XPropertySet)UnoRuntime.queryInterface( + XPropertySet xPropSet = UnoRuntime.queryInterface( XPropertySet.class, aArguments[0]); // start listening to property changes aPropChgHelper.AddAsListenerTo( xPropSet ); diff --git a/odk/examples/DevelopersGuide/OfficeDev/MenuElement.java b/odk/examples/DevelopersGuide/OfficeDev/MenuElement.java index 6d695d5e2002..fa351f1c7f5e 100644 --- a/odk/examples/DevelopersGuide/OfficeDev/MenuElement.java +++ b/odk/examples/DevelopersGuide/OfficeDev/MenuElement.java @@ -39,16 +39,16 @@ public class MenuElement { static public boolean IsMenuEntry( com.sun.star.beans.XPropertySet xMenuElement ) { com.sun.star.lang.XServiceInfo xServiceInfo = - (com.sun.star.lang.XServiceInfo)UnoRuntime.queryInterface( - com.sun.star.lang.XServiceInfo.class, xMenuElement ); + UnoRuntime.queryInterface( + com.sun.star.lang.XServiceInfo.class, xMenuElement ); return xServiceInfo.supportsService( "com.sun.star.ui.ActionTrigger" ); } static public boolean IsMenuSeparator( com.sun.star.beans.XPropertySet xMenuElement ) { com.sun.star.lang.XServiceInfo xServiceInfo = - (com.sun.star.lang.XServiceInfo)UnoRuntime.queryInterface( - com.sun.star.lang.XServiceInfo.class, xMenuElement ); + UnoRuntime.queryInterface( + com.sun.star.lang.XServiceInfo.class, xMenuElement ); return xServiceInfo.supportsService( "com.sun.star.ui.ActionTriggerSeparator" ); } diff --git a/odk/examples/DevelopersGuide/OfficeDev/Number_Formats.java b/odk/examples/DevelopersGuide/OfficeDev/Number_Formats.java index f3369c3e0d14..eb536ce02b15 100644 --- a/odk/examples/DevelopersGuide/OfficeDev/Number_Formats.java +++ b/odk/examples/DevelopersGuide/OfficeDev/Number_Formats.java @@ -86,9 +86,8 @@ public class Number_Formats // Query the number formats supplier of the spreadsheet document com.sun.star.util.XNumberFormatsSupplier xNumberFormatsSupplier = - (com.sun.star.util.XNumberFormatsSupplier) UnoRuntime.queryInterface( - com.sun.star.util.XNumberFormatsSupplier.class, maSpreadsheetDoc ); + com.sun.star.util.XNumberFormatsSupplier.class, maSpreadsheetDoc ); // Get the number formats from the supplier com.sun.star.util.XNumberFormats xNumberFormats = @@ -96,9 +95,8 @@ public class Number_Formats // Query the XNumberFormatTypes interface com.sun.star.util.XNumberFormatTypes xNumberFormatTypes = - (com.sun.star.util.XNumberFormatTypes) UnoRuntime.queryInterface( - com.sun.star.util.XNumberFormatTypes.class, xNumberFormats ); + com.sun.star.util.XNumberFormatTypes.class, xNumberFormats ); // Get the number format index key of the default currency format, // note the empty locale for default locale @@ -112,9 +110,8 @@ public class Number_Formats // Query the property set of the cell range com.sun.star.beans.XPropertySet xCellProp = - (com.sun.star.beans.XPropertySet) UnoRuntime.queryInterface( - com.sun.star.beans.XPropertySet.class, xCellRange ); + com.sun.star.beans.XPropertySet.class, xCellRange ); // Set number format to default currency xCellProp.setPropertyValue( "NumberFormat", new Integer(nCurrencyKey) ); @@ -123,9 +120,8 @@ public class Number_Formats com.sun.star.table.XCell xCell = maSheet.getCellByPosition( 1, 2 ); // Query the property set of the cell - xCellProp = (com.sun.star.beans.XPropertySet) - UnoRuntime.queryInterface( - com.sun.star.beans.XPropertySet.class, xCell ); + xCellProp = UnoRuntime.queryInterface( + com.sun.star.beans.XPropertySet.class, xCell ); // Get the number format index key of the cell's properties int nIndexKey = ((Integer) xCellProp.getPropertyValue( "NumberFormat" )).intValue(); @@ -168,19 +164,16 @@ public class Number_Formats // Set column containing the example values to optimal width to show // the new format of cell B3 com.sun.star.table.XColumnRowRange xColRowRange = - (com.sun.star.table.XColumnRowRange) UnoRuntime.queryInterface(com.sun.star.table.XColumnRowRange.class, - maSheet); + maSheet); com.sun.star.container.XIndexAccess xIndexAccess = - (com.sun.star.container.XIndexAccess) UnoRuntime.queryInterface(com.sun.star.container.XIndexAccess.class, - xColRowRange.getColumns()); + xColRowRange.getColumns()); com.sun.star.beans.XPropertySet xColPropSet = - (com.sun.star.beans.XPropertySet) UnoRuntime.queryInterface(com.sun.star.beans.XPropertySet.class, - xIndexAccess.getByIndex(1)); + xIndexAccess.getByIndex(1)); xColPropSet.setPropertyValue( "OptimalWidth", new Boolean(true) ); } @@ -196,11 +189,11 @@ public class Number_Formats maServiceManager = maOfficeContext.getServiceManager(); // create a new spreadsheet document - XComponentLoader aLoader = (XComponentLoader) UnoRuntime.queryInterface( + XComponentLoader aLoader = UnoRuntime.queryInterface( XComponentLoader.class, maServiceManager.createInstanceWithContext( "com.sun.star.frame.Desktop", maOfficeContext) ); - maSpreadsheetDoc = (XSpreadsheetDocument) UnoRuntime.queryInterface( + maSpreadsheetDoc = UnoRuntime.queryInterface( XSpreadsheetDocument.class, aLoader.loadComponentFromURL( "private:factory/scalc", "_blank", @@ -231,14 +224,14 @@ public class Number_Formats XSpreadsheets aSheets = maSpreadsheetDoc.getSheets(); try { - XIndexAccess aSheetsIA = (XIndexAccess) UnoRuntime.queryInterface( XIndexAccess.class, aSheets ); - maSheet = (XSpreadsheet) UnoRuntime.queryInterface(XSpreadsheet.class, aSheetsIA.getByIndex( 0 )); + XIndexAccess aSheetsIA = UnoRuntime.queryInterface( XIndexAccess.class, aSheets ); + maSheet = UnoRuntime.queryInterface(XSpreadsheet.class, aSheetsIA.getByIndex( 0 )); // enter some values in B3:B11 for( int iCounter=1; iCounter < 10; iCounter++ ) { XCell aCell = maSheet.getCellByPosition( 1, 1 + iCounter ); - aCell.setValue( (double) iCounter ); + aCell.setValue( iCounter ); } } catch( Exception ex ) diff --git a/odk/examples/DevelopersGuide/OfficeDev/PathSettings/PathSettingsTest.java b/odk/examples/DevelopersGuide/OfficeDev/PathSettings/PathSettingsTest.java index 34858994f369..5fff201ef552 100644 --- a/odk/examples/DevelopersGuide/OfficeDev/PathSettings/PathSettingsTest.java +++ b/odk/examples/DevelopersGuide/OfficeDev/PathSettings/PathSettingsTest.java @@ -92,7 +92,7 @@ public class PathSettingsTest extends java.lang.Object { Object pathSubst = xRemoteServiceManager.createInstanceWithContext( "com.sun.star.comp.framework.PathSettings", xRemoteContext ); - xPathSettingsService = (XPropertySet)UnoRuntime.queryInterface( + xPathSettingsService = UnoRuntime.queryInterface( XPropertySet.class, pathSubst); /* Work with path settings */ diff --git a/odk/examples/DevelopersGuide/OfficeDev/PathSubstitution/PathSubstitutionTest.java b/odk/examples/DevelopersGuide/OfficeDev/PathSubstitution/PathSubstitutionTest.java index e878b479813a..f326a55a133e 100644 --- a/odk/examples/DevelopersGuide/OfficeDev/PathSubstitution/PathSubstitutionTest.java +++ b/odk/examples/DevelopersGuide/OfficeDev/PathSubstitution/PathSubstitutionTest.java @@ -66,7 +66,7 @@ public class PathSubstitutionTest extends java.lang.Object { Object pathSubst = xRemoteServiceManager.createInstanceWithContext( "com.sun.star.comp.framework.PathSubstitution", xRemoteContext ); - xPathSubstService = (XStringSubstitution)UnoRuntime.queryInterface( + xPathSubstService = UnoRuntime.queryInterface( XStringSubstitution.class, pathSubst); /* Work with path variables */ diff --git a/odk/examples/DevelopersGuide/OfficeDev/TerminationTest/TerminationTest.java b/odk/examples/DevelopersGuide/OfficeDev/TerminationTest/TerminationTest.java index 7ee55ab85bd4..a01fb242c9de 100644 --- a/odk/examples/DevelopersGuide/OfficeDev/TerminationTest/TerminationTest.java +++ b/odk/examples/DevelopersGuide/OfficeDev/TerminationTest/TerminationTest.java @@ -58,7 +58,7 @@ public class TerminationTest extends java.lang.Object { Object desktop = xRemoteServiceManager.createInstanceWithContext( "com.sun.star.frame.Desktop", xRemoteContext); - xDesktop = (XDesktop)UnoRuntime.queryInterface(XDesktop.class, desktop); + xDesktop = UnoRuntime.queryInterface(XDesktop.class, desktop); TerminateListener terminateListener = new TerminateListener(); xDesktop.addTerminateListener(terminateListener); |