diff options
author | Noel Grandin <noel@peralex.com> | 2013-04-17 14:59:35 +0200 |
---|---|---|
committer | Fridrich Strba <fridrich@documentfoundation.org> | 2013-04-19 07:52:08 +0000 |
commit | 8d87758d65e4a03271f76e354dfc84c1fcd5fe21 (patch) | |
tree | bc8f4f0df6981ad10fe1333db1a2b015ea079709 /odk/examples/DevelopersGuide/GUI | |
parent | d62425cc27e04a3237cfec2ea2663b8b11284ec8 (diff) |
Java cleanup, remove the rest of the unnecessary casts
Change-Id: Ia61d250f6b3711abc29569c5ece38a6f87e38daa
Reviewed-on: https://gerrit.libreoffice.org/3432
Reviewed-by: Fridrich Strba <fridrich@documentfoundation.org>
Tested-by: Fridrich Strba <fridrich@documentfoundation.org>
Diffstat (limited to 'odk/examples/DevelopersGuide/GUI')
9 files changed, 153 insertions, 154 deletions
diff --git a/odk/examples/DevelopersGuide/GUI/DialogDocument.java b/odk/examples/DevelopersGuide/GUI/DialogDocument.java index 27d3d80f3348..9db851852006 100644 --- a/odk/examples/DevelopersGuide/GUI/DialogDocument.java +++ b/odk/examples/DevelopersGuide/GUI/DialogDocument.java @@ -68,7 +68,7 @@ public class DialogDocument extends UnoDialogSample { new Object[] { new Integer(400), Boolean.TRUE, "Dialog1", new Integer(102),new Integer(41), new Integer(1), new Short((short) 0), "Document-Dialog", new Integer(300)}); oDialogDocument.createWindowPeer(); Object oFTHeaderModel = oDialogDocument.m_xMSFDialogModel.createInstance("com.sun.star.awt.UnoControlFixedTextModel"); - XMultiPropertySet xFTHeaderModelMPSet = (XMultiPropertySet) UnoRuntime.queryInterface(XMultiPropertySet.class, oFTHeaderModel); + XMultiPropertySet xFTHeaderModelMPSet = UnoRuntime.queryInterface(XMultiPropertySet.class, oFTHeaderModel); xFTHeaderModelMPSet.setPropertyValues( new String[] {"Height", "Label", "Name", "PositionX", "PositionY", "Width"}, new Object[] { new Integer(8), "This code-sample demonstrates how to display an office document in a dialog window", "HeaderLabel", new Integer(6), new Integer(6), new Integer(300)}); @@ -96,7 +96,7 @@ public class DialogDocument extends UnoDialogSample { try { // The Toolkit is the creator of all windows... Object oToolkit = m_xMCF.createInstanceWithContext("com.sun.star.awt.Toolkit", m_xContext); - XToolkit xToolkit = (XToolkit) UnoRuntime.queryInterface(XToolkit.class, oToolkit); + XToolkit xToolkit = UnoRuntime.queryInterface(XToolkit.class, oToolkit); // set up a window description and create the window. A parent window is always necessary for this... com.sun.star.awt.WindowDescriptor aWindowDescriptor = new com.sun.star.awt.WindowDescriptor(); @@ -112,17 +112,17 @@ public class DialogDocument extends UnoDialogSample { // The attribute CLIPCHILDREN causes the parent to not repaint the areas of the children... aWindowDescriptor.WindowAttributes = VclWindowPeerAttribute.CLIPCHILDREN + WindowAttribute.BORDER + WindowAttribute.SHOW; XWindowPeer xWindowPeer = xToolkit.createWindow(aWindowDescriptor); - XWindow xWindow = (XWindow) UnoRuntime.queryInterface(XWindow.class, xWindowPeer); - XView xView = (XView) UnoRuntime.queryInterface(XView.class, xWindow); + XWindow xWindow = UnoRuntime.queryInterface(XWindow.class, xWindowPeer); + XView xView = UnoRuntime.queryInterface(XView.class, xWindow); // create a frame and initialize it with the created window... Object oFrame = m_xMCF.createInstanceWithContext("com.sun.star.frame.Frame", m_xContext); // The frame should be of global scope because it's within the responsibility to dispose it after usage - m_xFrame = (XFrame) UnoRuntime.queryInterface(XFrame.class, oFrame); + m_xFrame = UnoRuntime.queryInterface(XFrame.class, oFrame); m_xFrame.initialize(xWindow); // load the document and open it in preview mode - XComponentLoader xComponentLoader = (XComponentLoader) UnoRuntime.queryInterface(XComponentLoader.class, m_xFrame); + XComponentLoader xComponentLoader = UnoRuntime.queryInterface(XComponentLoader.class, m_xFrame); PropertyValue[] aPropertyValues = new PropertyValue[2]; PropertyValue aPropertyValue = new PropertyValue(); aPropertyValue.Name = "Preview"; diff --git a/odk/examples/DevelopersGuide/GUI/ImageControlSample.java b/odk/examples/DevelopersGuide/GUI/ImageControlSample.java index ac890e8aee1a..2e61fb25622d 100644 --- a/odk/examples/DevelopersGuide/GUI/ImageControlSample.java +++ b/odk/examples/DevelopersGuide/GUI/ImageControlSample.java @@ -71,7 +71,7 @@ public class ImageControlSample extends UnoDialogSample{ oImageControlSample.initialize( new String[] {"Height", "Moveable", "Name","PositionX","PositionY", "Step", "TabIndex","Title","Width"}, new Object[] { new Integer(100), Boolean.TRUE, "MyTestDialog", new Integer(102),new Integer(41), new Integer(0), new Short((short) 0), "OpenOffice", new Integer(230)}); Object oFTHeaderModel = oImageControlSample.m_xMSFDialogModel.createInstance("com.sun.star.awt.UnoControlFixedTextModel"); - XMultiPropertySet xFTHeaderModelMPSet = (XMultiPropertySet) UnoRuntime.queryInterface(XMultiPropertySet.class, oFTHeaderModel); + XMultiPropertySet xFTHeaderModelMPSet = UnoRuntime.queryInterface(XMultiPropertySet.class, oFTHeaderModel); xFTHeaderModelMPSet.setPropertyValues( new String[] {"Height", "Label", "MultiLine", "Name", "PositionX", "PositionY", "Width"}, new Object[] { new Integer(16), "This code-sample demonstrates how to create an ImageControlSample within a dialog", Boolean.TRUE, "HeaderLabel", new Integer(6), new Integer(6), new Integer(210)}); @@ -84,7 +84,7 @@ public class ImageControlSample extends UnoDialogSample{ // may not be set before the peer of the dialog has been created. XGraphic xGraphic = oImageControlSample.getGraphic(oImageControlSample.m_xMCF, args[0]); xICModelPropertySet.setPropertyValue("Graphic", xGraphic); - oImageControlSample.xDialog = (XDialog) UnoRuntime.queryInterface(XDialog.class, oImageControlSample.m_xDialogControl); + oImageControlSample.xDialog = UnoRuntime.queryInterface(XDialog.class, oImageControlSample.m_xDialogControl); oImageControlSample.executeDialog(); }catch( Exception e ) { System.err.println( e + e.getMessage()); @@ -110,8 +110,8 @@ public class ImageControlSample extends UnoDialogSample{ // create a controlmodel at the multiservicefactory of the dialog model... Object oICModel = m_xMSFDialogModel.createInstance("com.sun.star.awt.UnoControlImageControlModel"); - XMultiPropertySet xICModelMPSet = (XMultiPropertySet) UnoRuntime.queryInterface(XMultiPropertySet.class, oICModel); - xICModelPropertySet =(XPropertySet) UnoRuntime.queryInterface(XPropertySet.class, oICModel); + XMultiPropertySet xICModelMPSet = UnoRuntime.queryInterface(XMultiPropertySet.class, oICModel); + xICModelPropertySet =UnoRuntime.queryInterface(XPropertySet.class, oICModel); // Set the properties at the model - keep in mind to pass the property names in alphabetical order! // The image is not scaled xICModelMPSet.setPropertyValues( @@ -143,12 +143,12 @@ public class ImageControlSample extends UnoDialogSample{ try{ java.io.File oFile = new java.io.File(_sImageSystemPath); Object oFCProvider = _xMCF.createInstanceWithContext("com.sun.star.ucb.FileContentProvider", this.m_xContext); - XFileIdentifierConverter xFileIdentifierConverter = (XFileIdentifierConverter) UnoRuntime.queryInterface(XFileIdentifierConverter.class, oFCProvider); + XFileIdentifierConverter xFileIdentifierConverter = UnoRuntime.queryInterface(XFileIdentifierConverter.class, oFCProvider); String sImageUrl = xFileIdentifierConverter.getFileURLFromSystemPath(_sImageSystemPath, oFile.getAbsolutePath()); // create a GraphicProvider at the global service manager... Object oGraphicProvider = m_xMCF.createInstanceWithContext("com.sun.star.graphic.GraphicProvider", m_xContext); - XGraphicProvider xGraphicProvider = (XGraphicProvider) UnoRuntime.queryInterface(XGraphicProvider.class, oGraphicProvider); + XGraphicProvider xGraphicProvider = UnoRuntime.queryInterface(XGraphicProvider.class, oGraphicProvider); // create the graphic object PropertyValue[] aPropertyValues = new PropertyValue[1]; PropertyValue aPropertyValue = new PropertyValue(); diff --git a/odk/examples/DevelopersGuide/GUI/MessageBox.java b/odk/examples/DevelopersGuide/GUI/MessageBox.java index b9b3903e5b54..90cf5c862315 100644 --- a/odk/examples/DevelopersGuide/GUI/MessageBox.java +++ b/odk/examples/DevelopersGuide/GUI/MessageBox.java @@ -77,7 +77,7 @@ public class MessageBox { XWindowPeer xWindowPeer = oMessageBox.getWindowPeerOfFrame(xComp); if (xWindowPeer != null) { - XVclWindowPeer xVclWindowPeer = (XVclWindowPeer) UnoRuntime.queryInterface(XVclWindowPeer.class, xWindowPeer); + XVclWindowPeer xVclWindowPeer = UnoRuntime.queryInterface(XVclWindowPeer.class, xWindowPeer); boolean bisHighContrast = oMessageBox.isHighContrastModeActivated(xVclWindowPeer); oMessageBox.showErrorMessageBox(xWindowPeer, "My Sampletitle", "HighContrastMode is enabled: " + bisHighContrast); } else{ @@ -90,7 +90,7 @@ public class MessageBox { } finally { if (xComp != null) { try { - XCloseable xClose = (XCloseable)UnoRuntime.queryInterface(XCloseable.class, xComp); + XCloseable xClose = UnoRuntime.queryInterface(XCloseable.class, xComp); if (xClose != null) { xClose.close(false); } else { @@ -114,21 +114,21 @@ public class MessageBox { XFrame xFrame = null; if (xComp != null) { - XModel xModel = (XModel)UnoRuntime.queryInterface(XModel.class, xComp); + XModel xModel = UnoRuntime.queryInterface(XModel.class, xComp); xFrame = xModel.getCurrentController().getFrame(); } else { // Note: This method is potentially dangerous and should only be used for debugging // purposes as it relies on the platform dependent window handler.. Object oDesktop = m_xMCF.createInstanceWithContext("com.sun.star.frame.Desktop", m_xContext); - XFramesSupplier xFramesSupplier = (XFramesSupplier) UnoRuntime.queryInterface(XFramesSupplier.class, oDesktop); + XFramesSupplier xFramesSupplier = UnoRuntime.queryInterface(XFramesSupplier.class, oDesktop); xFrame = xFramesSupplier.getActiveFrame(); } if (xFrame != null){ XWindow xWindow = xFrame.getContainerWindow(); if (xWindow != null){ - XWindowPeer xWindowPeer = (XWindowPeer) UnoRuntime.queryInterface(XWindowPeer.class, xWindow); + XWindowPeer xWindowPeer = UnoRuntime.queryInterface(XWindowPeer.class, xWindow); return xWindowPeer; } } @@ -147,8 +147,7 @@ public class MessageBox { // get the component laoder from the desktop to create a new // text document - com.sun.star.frame.XComponentLoader xCLoader =(com.sun.star.frame.XComponentLoader) - UnoRuntime.queryInterface(com.sun.star.frame.XComponentLoader.class,oDesktop); + com.sun.star.frame.XComponentLoader xCLoader =UnoRuntime.queryInterface(com.sun.star.frame.XComponentLoader.class,oDesktop); com.sun.star.beans.PropertyValue[] args = new com.sun.star.beans.PropertyValue [1]; args[0] = new com.sun.star.beans.PropertyValue(); @@ -173,11 +172,11 @@ public class MessageBox { XComponent xComponent = null; try { Object oToolkit = m_xMCF.createInstanceWithContext("com.sun.star.awt.Toolkit", m_xContext); - XMessageBoxFactory xMessageBoxFactory = (XMessageBoxFactory) UnoRuntime.queryInterface(XMessageBoxFactory.class, oToolkit); + XMessageBoxFactory xMessageBoxFactory = UnoRuntime.queryInterface(XMessageBoxFactory.class, oToolkit); // rectangle may be empty if position is in the center of the parent peer Rectangle aRectangle = new Rectangle(); XMessageBox xMessageBox = xMessageBoxFactory.createMessageBox(_xParentWindowPeer, aRectangle, "errorbox", com.sun.star.awt.MessageBoxButtons.BUTTONS_OK, _sTitle, _sMessage); - xComponent = (XComponent) UnoRuntime.queryInterface(XComponent.class, xMessageBox); + xComponent = UnoRuntime.queryInterface(XComponent.class, xMessageBox); if (xMessageBox != null){ short nResult = xMessageBox.execute(); } @@ -217,25 +216,25 @@ public class MessageBox { } public static int getRedColorShare(int _nColor) { - int nRed = (int) _nColor/65536; + int nRed = _nColor/65536; int nRedModulo = _nColor % 65536; - int nGreen = (int) (nRedModulo / 256); + int nGreen = nRedModulo / 256; int nGreenModulo = (nRedModulo % 256); int nBlue = nGreenModulo; return nRed; } public static int getGreenColorShare(int _nColor) { - int nRed = (int) _nColor/65536; + int nRed = _nColor/65536; int nRedModulo = _nColor % 65536; - int nGreen = (int) (nRedModulo / 256); + int nGreen = nRedModulo / 256; return nGreen; } public static int getBlueColorShare(int _nColor) { - int nRed = (int) _nColor/65536; + int nRed = _nColor/65536; int nRedModulo = _nColor % 65536; - int nGreen = (int) (nRedModulo / 256); + int nGreen = nRedModulo / 256; int nGreenModulo = (nRedModulo % 256); int nBlue = nGreenModulo; return nBlue; diff --git a/odk/examples/DevelopersGuide/GUI/RoadmapItemStateChangeListener.java b/odk/examples/DevelopersGuide/GUI/RoadmapItemStateChangeListener.java index 6f2a82453d62..69a7f77d4cab 100644 --- a/odk/examples/DevelopersGuide/GUI/RoadmapItemStateChangeListener.java +++ b/odk/examples/DevelopersGuide/GUI/RoadmapItemStateChangeListener.java @@ -49,7 +49,7 @@ public class RoadmapItemStateChangeListener implements XItemListener { try { // get the new ID of the roadmap that is supposed to refer to the new step of the dialogmodel int nNewID = itemEvent.ItemId; - XPropertySet xDialogModelPropertySet = (XPropertySet) UnoRuntime.queryInterface(XPropertySet.class, m_xMSFDialogModel); + XPropertySet xDialogModelPropertySet = UnoRuntime.queryInterface(XPropertySet.class, m_xMSFDialogModel); int nOldStep = ((Integer) xDialogModelPropertySet.getPropertyValue("Step")).intValue(); // in the following line "ID" and "Step" are mixed together. // In fact in this case they denot the same diff --git a/odk/examples/DevelopersGuide/GUI/SystemDialog.java b/odk/examples/DevelopersGuide/GUI/SystemDialog.java index 861d075a1df2..bad6a8f0db9f 100644 --- a/odk/examples/DevelopersGuide/GUI/SystemDialog.java +++ b/odk/examples/DevelopersGuide/GUI/SystemDialog.java @@ -80,36 +80,36 @@ public class SystemDialog { try { // the filepicker is instantiated with the global Multicomponentfactory... Object oFilePicker = m_xMCF.createInstanceWithContext("com.sun.star.ui.dialogs.FilePicker", m_xContext); - XFilePicker xFilePicker = (XFilePicker) UnoRuntime.queryInterface(XFilePicker.class, oFilePicker); + XFilePicker xFilePicker = UnoRuntime.queryInterface(XFilePicker.class, oFilePicker); // the defaultname is the initially proposed filename.. xFilePicker.setDefaultName("MyExampleDocument"); // set the initial displaydirectory. In this example the user template directory is used Object oPathSettings = m_xMCF.createInstanceWithContext("com.sun.star.util.PathSettings",m_xContext); - XPropertySet xPropertySet = (XPropertySet) com.sun.star.uno.UnoRuntime.queryInterface(XPropertySet.class, oPathSettings); + XPropertySet xPropertySet = com.sun.star.uno.UnoRuntime.queryInterface(XPropertySet.class, oPathSettings); String sTemplateUrl = (String) xPropertySet.getPropertyValue("Template_writable"); xFilePicker.setDisplayDirectory(sTemplateUrl); // set the filters of the dialog. The filternames may be retrieved from // http://wiki.services.openoffice.org/wiki/Framework/Article/Filter - XFilterManager xFilterManager = (XFilterManager) UnoRuntime.queryInterface(XFilterManager.class, xFilePicker); + XFilterManager xFilterManager = UnoRuntime.queryInterface(XFilterManager.class, xFilePicker); xFilterManager.appendFilter("OpenDocument Text Template", "writer8_template"); xFilterManager.appendFilter("OpenDocument Text", "writer8"); // choose the template that defines the capabilities of the filepicker dialog - XInitialization xInitialize = (XInitialization) UnoRuntime.queryInterface(XInitialization.class, xFilePicker); + XInitialization xInitialize = UnoRuntime.queryInterface(XInitialization.class, xFilePicker); Short[] listAny = new Short[] { new Short(com.sun.star.ui.dialogs.TemplateDescription.FILESAVE_AUTOEXTENSION)}; xInitialize.initialize(listAny); // add a control to the dialog to add the extension automatically to the filename... - XFilePickerControlAccess xFilePickerControlAccess = (XFilePickerControlAccess) UnoRuntime.queryInterface(XFilePickerControlAccess.class, xFilePicker); + XFilePickerControlAccess xFilePickerControlAccess = UnoRuntime.queryInterface(XFilePickerControlAccess.class, xFilePicker); xFilePickerControlAccess.setValue(com.sun.star.ui.dialogs.ExtendedFilePickerElementIds.CHECKBOX_AUTOEXTENSION, (short) 0, new Boolean(true)); - xComponent = (XComponent) UnoRuntime.queryInterface(XComponent.class, xFilePicker); + xComponent = UnoRuntime.queryInterface(XComponent.class, xFilePicker); // execute the dialog... - XExecutableDialog xExecutable = (XExecutableDialog) UnoRuntime.queryInterface(XExecutableDialog.class, xFilePicker); + XExecutableDialog xExecutable = UnoRuntime.queryInterface(XExecutableDialog.class, xFilePicker); short nResult = xExecutable.execute(); // query the resulting path of the dialog... @@ -135,7 +135,7 @@ public class SystemDialog { try{ // retrieve the configured Work path... Object oPathSettings = m_xMCF.createInstanceWithContext("com.sun.star.util.PathSettings",m_xContext); - XPropertySet xPropertySet = (XPropertySet) com.sun.star.uno.UnoRuntime.queryInterface(XPropertySet.class, oPathSettings); + XPropertySet xPropertySet = com.sun.star.uno.UnoRuntime.queryInterface(XPropertySet.class, oPathSettings); sWorkUrl = (String) xPropertySet.getPropertyValue("Work"); } catch (com.sun.star.uno.Exception exception) { exception.printStackTrace(); @@ -158,8 +158,8 @@ public class SystemDialog { // instantiate the folder picker and retrieve the necessary interfaces... Object oFolderPicker = m_xMCF.createInstanceWithContext("com.sun.star.ui.dialogs.FolderPicker", m_xContext); XFolderPicker2 xFolderPicker = UnoRuntime.queryInterface(XFolderPicker2.class, oFolderPicker); - XExecutableDialog xExecutable = (XExecutableDialog) UnoRuntime.queryInterface(XExecutableDialog.class, oFolderPicker); - xComponent = (XComponent) UnoRuntime.queryInterface(XComponent.class, oFolderPicker); + XExecutableDialog xExecutable = UnoRuntime.queryInterface(XExecutableDialog.class, oFolderPicker); + xComponent = UnoRuntime.queryInterface(XComponent.class, oFolderPicker); xFolderPicker.setDisplayDirectory(_sDisplayDirectory); // set the dialog title... xFolderPicker.setTitle(_sTitle); diff --git a/odk/examples/DevelopersGuide/GUI/UnoDialogSample.java b/odk/examples/DevelopersGuide/GUI/UnoDialogSample.java index 6db2ef162e63..2b47e82e8975 100644 --- a/odk/examples/DevelopersGuide/GUI/UnoDialogSample.java +++ b/odk/examples/DevelopersGuide/GUI/UnoDialogSample.java @@ -139,7 +139,7 @@ public class UnoDialogSample implements XTextListener, XSpinListener, XActionLis oUnoDialogSample.initialize( new String[] {"Height", "Moveable", "Name","PositionX","PositionY", "Step", "TabIndex","Title","Width"}, new Object[] { new Integer(380), Boolean.TRUE, "MyTestDialog", new Integer(102),new Integer(41), new Integer(0), new Short((short) 0), "OpenOffice", new Integer(380)}); Object oFTHeaderModel = oUnoDialogSample.m_xMSFDialogModel.createInstance("com.sun.star.awt.UnoControlFixedTextModel"); - XMultiPropertySet xFTHeaderModelMPSet = (XMultiPropertySet) UnoRuntime.queryInterface(XMultiPropertySet.class, oFTHeaderModel); + XMultiPropertySet xFTHeaderModelMPSet = UnoRuntime.queryInterface(XMultiPropertySet.class, oFTHeaderModel); xFTHeaderModelMPSet.setPropertyValues( new String[] {"Height", "Label", "Name", "PositionX", "PositionY", "Width"}, new Object[] { new Integer(8), "This code-sample demonstrates how to create various controls in a dialog", "HeaderLabel", new Integer(106), new Integer(6), new Integer(300)}); @@ -167,7 +167,7 @@ public class UnoDialogSample implements XTextListener, XSpinListener, XActionLis oUnoDialogSample.addRoadmap(oUnoDialogSample.getRoadmapItemStateChangeListener()); oUnoDialogSample.insertRoadmapItem(0, true, "Introduction", 1); oUnoDialogSample.insertRoadmapItem(1, true, "Documents", 2); - oUnoDialogSample.xDialog = (XDialog) UnoRuntime.queryInterface(XDialog.class, oUnoDialogSample.m_xDialogControl); + oUnoDialogSample.xDialog = UnoRuntime.queryInterface(XDialog.class, oUnoDialogSample.m_xDialogControl); oUnoDialogSample.executeDialog(); }catch( Exception e ) { System.err.println( e + e.getMessage()); @@ -197,9 +197,9 @@ public class UnoDialogSample implements XTextListener, XSpinListener, XActionLis aNodePath[0] = new PropertyValue(); aNodePath[0].Name = "nodepath"; aNodePath[0].Value = _sKeyName; - XMultiServiceFactory xMSFConfig = (XMultiServiceFactory) UnoRuntime.queryInterface(XMultiServiceFactory.class, oConfigProvider); + XMultiServiceFactory xMSFConfig = UnoRuntime.queryInterface(XMultiServiceFactory.class, oConfigProvider); Object oNode = xMSFConfig.createInstanceWithArguments("com.sun.star.configuration.ConfigurationAccess", aNodePath); - XNameAccess xNameAccess = (XNameAccess) UnoRuntime.queryInterface(XNameAccess.class, oNode); + XNameAccess xNameAccess = UnoRuntime.queryInterface(XNameAccess.class, oNode); return xNameAccess; } catch (Exception exception) { exception.printStackTrace(System.err); @@ -222,7 +222,7 @@ public class UnoDialogSample implements XTextListener, XSpinListener, XActionLis // get the Image Url and process the Url by the macroexpander... sImageUrl = (String) xNameAccess.getByName(_sImageName); Object oMacroExpander = this.m_xContext.getValueByName("/singletons/com.sun.star.util.theMacroExpander"); - XMacroExpander xMacroExpander = (XMacroExpander) UnoRuntime.queryInterface(XMacroExpander.class, oMacroExpander); + XMacroExpander xMacroExpander = UnoRuntime.queryInterface(XMacroExpander.class, oMacroExpander); sImageUrl = xMacroExpander.expandMacros(sImageUrl); sImageUrl = sImageUrl.substring(new String("vnd.sun.star.expand:").length(), sImageUrl.length()); sImageUrl = sImageUrl.trim(); @@ -245,22 +245,22 @@ public class UnoDialogSample implements XTextListener, XSpinListener, XActionLis Object oDialogModel = _xMCF.createInstanceWithContext("com.sun.star.awt.UnoControlDialogModel", m_xContext); // The XMultiServiceFactory of the dialogmodel is needed to instantiate the controls... - m_xMSFDialogModel = (XMultiServiceFactory) UnoRuntime.queryInterface(XMultiServiceFactory.class, oDialogModel); + m_xMSFDialogModel = UnoRuntime.queryInterface(XMultiServiceFactory.class, oDialogModel); // The named container is used to insert the created controls into... - m_xDlgModelNameContainer = (XNameContainer) UnoRuntime.queryInterface(XNameContainer.class, oDialogModel); + m_xDlgModelNameContainer = UnoRuntime.queryInterface(XNameContainer.class, oDialogModel); // create the dialog... Object oUnoDialog = _xMCF.createInstanceWithContext("com.sun.star.awt.UnoControlDialog", m_xContext); - m_xDialogControl = (XControl) UnoRuntime.queryInterface(XControl.class, oUnoDialog); + m_xDialogControl = UnoRuntime.queryInterface(XControl.class, oUnoDialog); // The scope of the control container is public... - m_xDlgContainer = (XControlContainer) UnoRuntime.queryInterface(XControlContainer.class, oUnoDialog); + m_xDlgContainer = UnoRuntime.queryInterface(XControlContainer.class, oUnoDialog); - m_xTopWindow = (XTopWindow) UnoRuntime.queryInterface(XTopWindow.class, m_xDlgContainer); + m_xTopWindow = UnoRuntime.queryInterface(XTopWindow.class, m_xDlgContainer); // link the dialog and its model... - XControlModel xControlModel = (XControlModel) UnoRuntime.queryInterface(XControlModel.class, oDialogModel); + XControlModel xControlModel = UnoRuntime.queryInterface(XControlModel.class, oDialogModel); m_xDialogControl.setModel(xControlModel); } catch (com.sun.star.uno.Exception exception) { exception.printStackTrace(System.err); @@ -276,7 +276,7 @@ public class UnoDialogSample implements XTextListener, XSpinListener, XActionLis addRoadmap(getRoadmapItemStateChangeListener()); insertRoadmapItem(0, true, "Introduction", 1); insertRoadmapItem(1, true, "Documents", 2); - xDialog = (XDialog) UnoRuntime.queryInterface(XDialog.class, m_xDialogControl); + xDialog = UnoRuntime.queryInterface(XDialog.class, m_xDialogControl); return xDialog.execute(); } @@ -285,8 +285,8 @@ public class UnoDialogSample implements XTextListener, XSpinListener, XActionLis if (m_xWindowPeer == null) { createWindowPeer(); } - xDialog = (XDialog) UnoRuntime.queryInterface(XDialog.class, m_xDialogControl); - m_xComponent = (XComponent) UnoRuntime.queryInterface(XComponent.class, m_xDialogControl); + xDialog = UnoRuntime.queryInterface(XDialog.class, m_xDialogControl); + m_xComponent = UnoRuntime.queryInterface(XComponent.class, m_xDialogControl); return xDialog.execute(); } @@ -300,7 +300,7 @@ public class UnoDialogSample implements XTextListener, XSpinListener, XActionLis public void initialize(String[] PropertyNames, Object[] PropertyValues) throws com.sun.star.script.BasicErrorException{ try{ - XMultiPropertySet xMultiPropertySet = (XMultiPropertySet) UnoRuntime.queryInterface(XMultiPropertySet.class, m_xDlgModelNameContainer); + XMultiPropertySet xMultiPropertySet = UnoRuntime.queryInterface(XMultiPropertySet.class, m_xDlgModelNameContainer); xMultiPropertySet.setPropertyValues(PropertyNames, PropertyValues); } catch (com.sun.star.uno.Exception ex) { ex.printStackTrace(System.err); @@ -319,11 +319,11 @@ public class UnoDialogSample implements XTextListener, XSpinListener, XActionLis public XWindowPeer createWindowPeer(XWindowPeer _xWindowParentPeer) throws com.sun.star.script.BasicErrorException{ try{ if (_xWindowParentPeer == null){ - XWindow xWindow = (XWindow) UnoRuntime.queryInterface(XWindow.class, m_xDlgContainer); + XWindow xWindow = UnoRuntime.queryInterface(XWindow.class, m_xDlgContainer); xWindow.setVisible(false); Object tk = m_xMCF.createInstanceWithContext("com.sun.star.awt.Toolkit", m_xContext); - XToolkit xToolkit = (XToolkit) UnoRuntime.queryInterface(XToolkit.class, tk); - mxReschedule = (XReschedule) UnoRuntime.queryInterface(XReschedule.class, xToolkit); + XToolkit xToolkit = UnoRuntime.queryInterface(XToolkit.class, tk); + mxReschedule = UnoRuntime.queryInterface(XReschedule.class, xToolkit); m_xDialogControl.createPeer(xToolkit, _xWindowParentPeer); m_xWindowPeer = m_xDialogControl.getPeer(); return m_xWindowPeer; @@ -368,7 +368,7 @@ public class UnoDialogSample implements XTextListener, XSpinListener, XActionLis public Object insertControlModel(String ServiceName, String sName, String[] sProperties, Object[] sValues) throws com.sun.star.script.BasicErrorException{ try { Object oControlModel = m_xMSFDialogModel.createInstance(ServiceName); - XMultiPropertySet xControlMultiPropertySet = (XMultiPropertySet) UnoRuntime.queryInterface(XMultiPropertySet.class, oControlModel); + XMultiPropertySet xControlMultiPropertySet = UnoRuntime.queryInterface(XMultiPropertySet.class, oControlModel); xControlMultiPropertySet.setPropertyValues(sProperties, sValues); m_xDlgModelNameContainer.insertByName(sName, oControlModel); return oControlModel; @@ -387,7 +387,7 @@ public class UnoDialogSample implements XTextListener, XSpinListener, XActionLis // create a controlmodel at the multiservicefactory of the dialog model... Object oFTModel = m_xMSFDialogModel.createInstance("com.sun.star.awt.UnoControlFixedTextModel"); - XMultiPropertySet xFTModelMPSet = (XMultiPropertySet) UnoRuntime.queryInterface(XMultiPropertySet.class, oFTModel); + XMultiPropertySet xFTModelMPSet = UnoRuntime.queryInterface(XMultiPropertySet.class, oFTModel); // Set the properties at the model - keep in mind to pass the property names in alphabetical order! xFTModelMPSet.setPropertyValues( @@ -398,13 +398,13 @@ public class UnoDialogSample implements XTextListener, XSpinListener, XActionLis // The following property may also be set with XMultiPropertySet but we // use the XPropertySet interface merely for reasons of demonstration - XPropertySet xFTPSet = (XPropertySet) UnoRuntime.queryInterface(XPropertySet.class, oFTModel); + XPropertySet xFTPSet = UnoRuntime.queryInterface(XPropertySet.class, oFTModel); xFTPSet.setPropertyValue("Label", _sLabel); // reference the control by the Name XControl xFTControl = m_xDlgContainer.getControl(sName); - xFixedText = (XFixedText) UnoRuntime.queryInterface(XFixedText.class, xFTControl); - XWindow xWindow = (XWindow) UnoRuntime.queryInterface(XWindow.class, xFTControl); + xFixedText = UnoRuntime.queryInterface(XFixedText.class, xFTControl); + XWindow xWindow = UnoRuntime.queryInterface(XWindow.class, xFTControl); xWindow.addMouseListener(_xMouseListener); } catch (com.sun.star.uno.Exception ex) { /* perform individual exception handling here. @@ -430,7 +430,7 @@ public class UnoDialogSample implements XTextListener, XSpinListener, XActionLis // create a controlmodel at the multiservicefactory of the dialog model... Object oCFModel = m_xMSFDialogModel.createInstance("com.sun.star.awt.UnoControlCurrencyFieldModel"); - XMultiPropertySet xCFModelMPSet = (XMultiPropertySet) UnoRuntime.queryInterface(XMultiPropertySet.class, oCFModel); + XMultiPropertySet xCFModelMPSet = UnoRuntime.queryInterface(XMultiPropertySet.class, oCFModel); // Set the properties at the model - keep in mind to pass the property names in alphabetical order! xCFModelMPSet.setPropertyValues( @@ -439,7 +439,7 @@ public class UnoDialogSample implements XTextListener, XSpinListener, XActionLis // The controlmodel is not really available until inserted to the Dialog container m_xDlgModelNameContainer.insertByName(sName, oCFModel); - XPropertySet xCFModelPSet = (XPropertySet) UnoRuntime.queryInterface(XPropertySet.class, oCFModel); + XPropertySet xCFModelPSet = UnoRuntime.queryInterface(XPropertySet.class, oCFModel); // The following properties may also be set with XMultiPropertySet but we // use the XPropertySet interface merely for reasons of demonstration @@ -449,7 +449,7 @@ public class UnoDialogSample implements XTextListener, XSpinListener, XActionLis // add a textlistener that is notified on each change of the controlvalue... Object oCFControl = m_xDlgContainer.getControl(sName); - xTextComponent = (XTextComponent) UnoRuntime.queryInterface(XTextComponent.class, oCFControl); + xTextComponent = UnoRuntime.queryInterface(XTextComponent.class, oCFControl); xTextComponent.addTextListener(_xTextListener); } catch (com.sun.star.uno.Exception ex) { /* perform individual exception handling here. @@ -477,7 +477,7 @@ public class UnoDialogSample implements XTextListener, XSpinListener, XActionLis // create a controlmodel at the multiservicefactory of the dialog model... Object oPBModel = m_xMSFDialogModel.createInstance("com.sun.star.awt.UnoControlProgressBarModel"); - XMultiPropertySet xPBModelMPSet = (XMultiPropertySet) UnoRuntime.queryInterface(XMultiPropertySet.class, oPBModel); + XMultiPropertySet xPBModelMPSet = UnoRuntime.queryInterface(XMultiPropertySet.class, oPBModel); // Set the properties at the model - keep in mind to pass the property names in alphabetical order! xPBModelMPSet.setPropertyValues( new String[] {"Height", "Name", "PositionX", "PositionY", "Width"}, @@ -485,7 +485,7 @@ public class UnoDialogSample implements XTextListener, XSpinListener, XActionLis // The controlmodel is not really available until inserted to the Dialog container m_xDlgModelNameContainer.insertByName(sName, oPBModel); - xPBModelPSet = (XPropertySet) UnoRuntime.queryInterface(XPropertySet.class, oPBModel); + xPBModelPSet = UnoRuntime.queryInterface(XPropertySet.class, oPBModel); // The following properties may also be set with XMultiPropertySet but we // use the XPropertySet interface merely for reasons of demonstration @@ -515,7 +515,7 @@ public class UnoDialogSample implements XTextListener, XSpinListener, XActionLis // create a controlmodel at the multiservicefactory of the dialog model... Object oFLModel = m_xMSFDialogModel.createInstance("com.sun.star.awt.UnoControlFixedLineModel"); - XMultiPropertySet xFLModelMPSet = (XMultiPropertySet) UnoRuntime.queryInterface(XMultiPropertySet.class, oFLModel); + XMultiPropertySet xFLModelMPSet = UnoRuntime.queryInterface(XMultiPropertySet.class, oFLModel); // Set the properties at the model - keep in mind to pass the property names in alphabetical order! xFLModelMPSet.setPropertyValues( @@ -527,7 +527,7 @@ public class UnoDialogSample implements XTextListener, XSpinListener, XActionLis // The following property may also be set with XMultiPropertySet but we // use the XPropertySet interface merely for reasons of demonstration - XPropertySet xFLPSet = (XPropertySet) UnoRuntime.queryInterface(XPropertySet.class, oFLModel); + XPropertySet xFLPSet = UnoRuntime.queryInterface(XPropertySet.class, oFLModel); xFLPSet.setPropertyValue("Label", _sLabel); } catch (com.sun.star.uno.Exception ex) { /* perform individual exception handling here. @@ -552,7 +552,7 @@ public class UnoDialogSample implements XTextListener, XSpinListener, XActionLis // create a controlmodel at the multiservicefactory of the dialog model... Object oGBModel = m_xMSFDialogModel.createInstance("com.sun.star.awt.UnoControlGroupBoxModel"); - XMultiPropertySet xGBModelMPSet = (XMultiPropertySet) UnoRuntime.queryInterface(XMultiPropertySet.class, oGBModel); + XMultiPropertySet xGBModelMPSet = UnoRuntime.queryInterface(XMultiPropertySet.class, oGBModel); // Set the properties at the model - keep in mind to pass the property names in alphabetical order! xGBModelMPSet.setPropertyValues( @@ -564,7 +564,7 @@ public class UnoDialogSample implements XTextListener, XSpinListener, XActionLis // The following property may also be set with XMultiPropertySet but we // use the XPropertySet interface merely for reasons of demonstration - XPropertySet xGBPSet = (XPropertySet) UnoRuntime.queryInterface(XPropertySet.class, oGBModel); + XPropertySet xGBPSet = UnoRuntime.queryInterface(XPropertySet.class, oGBModel); xGBPSet.setPropertyValue("Label", "~My GroupBox"); } catch (com.sun.star.uno.Exception ex) { /* perform individual exception handling here. @@ -590,7 +590,7 @@ public class UnoDialogSample implements XTextListener, XSpinListener, XActionLis // create a controlmodel at the multiservicefactory of the dialog model... Object oTFModel = m_xMSFDialogModel.createInstance("com.sun.star.awt.UnoControlEditModel"); - XMultiPropertySet xTFModelMPSet = (XMultiPropertySet) UnoRuntime.queryInterface(XMultiPropertySet.class, oTFModel); + XMultiPropertySet xTFModelMPSet = UnoRuntime.queryInterface(XMultiPropertySet.class, oTFModel); // Set the properties at the model - keep in mind to pass the property names in alphabetical order! xTFModelMPSet.setPropertyValues( @@ -599,7 +599,7 @@ public class UnoDialogSample implements XTextListener, XSpinListener, XActionLis // The controlmodel is not really available until inserted to the Dialog container m_xDlgModelNameContainer.insertByName(sName, oTFModel); - XPropertySet xTFModelPSet = (XPropertySet) UnoRuntime.queryInterface(XPropertySet.class, oTFModel); + XPropertySet xTFModelPSet = UnoRuntime.queryInterface(XPropertySet.class, oTFModel); // The following property may also be set with XMultiPropertySet but we // use the XPropertySet interface merely for reasons of demonstration @@ -607,8 +607,8 @@ public class UnoDialogSample implements XTextListener, XSpinListener, XActionLis XControl xTFControl = m_xDlgContainer.getControl(sName); // add a textlistener that is notified on each change of the controlvalue... - xTextComponent = (XTextComponent) UnoRuntime.queryInterface(XTextComponent.class, xTFControl); - XWindow xTFWindow = (XWindow) UnoRuntime.queryInterface(XWindow.class, xTFControl); + xTextComponent = UnoRuntime.queryInterface(XTextComponent.class, xTFControl); + XWindow xTFWindow = UnoRuntime.queryInterface(XWindow.class, xTFControl); xTFWindow.addFocusListener(_xFocusListener); xTextComponent.addTextListener(_xTextListener); xTFWindow.addKeyListener(this); @@ -635,7 +635,7 @@ public class UnoDialogSample implements XTextListener, XSpinListener, XActionLis // create a controlmodel at the multiservicefactory of the dialog model... Object oTFModel = m_xMSFDialogModel.createInstance("com.sun.star.awt.UnoControlTimeFieldModel"); - XMultiPropertySet xTFModelMPSet = (XMultiPropertySet) UnoRuntime.queryInterface(XMultiPropertySet.class, oTFModel); + XMultiPropertySet xTFModelMPSet = UnoRuntime.queryInterface(XMultiPropertySet.class, oTFModel); // Set the properties at the model - keep in mind to pass the property names in alphabetical order! xTFModelMPSet.setPropertyValues( @@ -644,7 +644,7 @@ public class UnoDialogSample implements XTextListener, XSpinListener, XActionLis // The controlmodel is not really available until inserted to the Dialog container m_xDlgModelNameContainer.insertByName(sName, oTFModel); - xTFModelPSet = (XPropertySet) UnoRuntime.queryInterface(XPropertySet.class, oTFModel); + xTFModelPSet = UnoRuntime.queryInterface(XPropertySet.class, oTFModel); // The following properties may also be set with XMultiPropertySet but we // use the XPropertySet interface merely for reasons of demonstration @@ -677,7 +677,7 @@ public class UnoDialogSample implements XTextListener, XSpinListener, XActionLis // create a controlmodel at the multiservicefactory of the dialog model... Object oDFModel = m_xMSFDialogModel.createInstance("com.sun.star.awt.UnoControlDateFieldModel"); - XMultiPropertySet xDFModelMPSet = (XMultiPropertySet) UnoRuntime.queryInterface(XMultiPropertySet.class, oDFModel); + XMultiPropertySet xDFModelMPSet = UnoRuntime.queryInterface(XMultiPropertySet.class, oDFModel); // Set the properties at the model - keep in mind to pass the property names in alphabetical order! xDFModelMPSet.setPropertyValues( @@ -686,7 +686,7 @@ public class UnoDialogSample implements XTextListener, XSpinListener, XActionLis // The controlmodel is not really available until inserted to the Dialog container m_xDlgModelNameContainer.insertByName(sName, oDFModel); - xDFModelPSet = (XPropertySet) UnoRuntime.queryInterface(XPropertySet.class, oDFModel); + xDFModelPSet = UnoRuntime.queryInterface(XPropertySet.class, oDFModel); // The following properties may also be set with XMultiPropertySet but we // use the XPropertySet interface merely for reasons of demonstration @@ -697,7 +697,7 @@ public class UnoDialogSample implements XTextListener, XSpinListener, XActionLis Object oDFControl = m_xDlgContainer.getControl(sName); // add a SpinListener that is notified on each change of the controlvalue... - XSpinField xSpinField = (XSpinField) UnoRuntime.queryInterface(XSpinField.class, oDFControl); + XSpinField xSpinField = UnoRuntime.queryInterface(XSpinField.class, oDFControl); xSpinField.addSpinListener(_xSpinListener); } catch (com.sun.star.uno.Exception ex) { /* perform individual exception handling here. @@ -723,7 +723,7 @@ public class UnoDialogSample implements XTextListener, XSpinListener, XActionLis // create a controlmodel at the multiservicefactory of the dialog model... Object oPFModel = m_xMSFDialogModel.createInstance("com.sun.star.awt.UnoControlPatternFieldModel"); - XMultiPropertySet xPFModelMPSet = (XMultiPropertySet) UnoRuntime.queryInterface(XMultiPropertySet.class, oPFModel); + XMultiPropertySet xPFModelMPSet = UnoRuntime.queryInterface(XMultiPropertySet.class, oPFModel); // Set the properties at the model - keep in mind to pass the property names in alphabetical order! xPFModelMPSet.setPropertyValues( @@ -732,7 +732,7 @@ public class UnoDialogSample implements XTextListener, XSpinListener, XActionLis // The controlmodel is not really available until inserted to the Dialog container m_xDlgModelNameContainer.insertByName(sName, oPFModel); - xPFModelPSet = (XPropertySet) UnoRuntime.queryInterface(XPropertySet.class, oPFModel); + xPFModelPSet = UnoRuntime.queryInterface(XPropertySet.class, oPFModel); // The following properties may also be set with XMultiPropertySet but we // use the XPropertySet interface merely for reasons of demonstration @@ -767,7 +767,7 @@ public class UnoDialogSample implements XTextListener, XSpinListener, XActionLis // create a controlmodel at the multiservicefactory of the dialog model... Object oNFModel = m_xMSFDialogModel.createInstance("com.sun.star.awt.UnoControlNumericFieldModel"); - XMultiPropertySet xNFModelMPSet = (XMultiPropertySet) UnoRuntime.queryInterface(XMultiPropertySet.class, oNFModel); + XMultiPropertySet xNFModelMPSet = UnoRuntime.queryInterface(XMultiPropertySet.class, oNFModel); // Set the properties at the model - keep in mind to pass the property names in alphabetical order! xNFModelMPSet.setPropertyValues( new String[] {"Height", "Name", "PositionX", "PositionY", "Spin", "StrictFormat", "Width"}, @@ -775,7 +775,7 @@ public class UnoDialogSample implements XTextListener, XSpinListener, XActionLis // The controlmodel is not really available until inserted to the Dialog container m_xDlgModelNameContainer.insertByName(sName, oNFModel); - xNFModelPSet = (XPropertySet) UnoRuntime.queryInterface(XPropertySet.class, oNFModel); + xNFModelPSet = UnoRuntime.queryInterface(XPropertySet.class, oNFModel); // The following properties may also be set with XMultiPropertySet but we // use the XPropertySet interface merely for reasons of demonstration xNFModelPSet.setPropertyValue("ValueMin", new Double(_fValueMin)); @@ -811,7 +811,7 @@ public class UnoDialogSample implements XTextListener, XSpinListener, XActionLis // create a controlmodel at the multiservicefactory of the dialog model... Object oSBModel = m_xMSFDialogModel.createInstance("com.sun.star.awt.UnoControlScrollBarModel"); - XMultiPropertySet xSBModelMPSet = (XMultiPropertySet) UnoRuntime.queryInterface(XMultiPropertySet.class, oSBModel); + XMultiPropertySet xSBModelMPSet = UnoRuntime.queryInterface(XMultiPropertySet.class, oSBModel); // Set the properties at the model - keep in mind to pass the property names in alphabetical order! xSBModelMPSet.setPropertyValues( new String[] {"Height", "Name", "Orientation", "PositionX", "PositionY", "Width"}, @@ -820,7 +820,7 @@ public class UnoDialogSample implements XTextListener, XSpinListener, XActionLis // The controlmodel is not really available until inserted to the Dialog container m_xDlgModelNameContainer.insertByName(sName, oSBModel); - xSBModelPSet = (XPropertySet) UnoRuntime.queryInterface(XPropertySet.class, oSBModel); + xSBModelPSet = UnoRuntime.queryInterface(XPropertySet.class, oSBModel); // The following properties may also be set with XMultiPropertySet but we // use the XPropertySet interface merely for reasons of demonstration xSBModelPSet.setPropertyValue("ScrollValueMin", new Integer(0)); @@ -831,7 +831,7 @@ public class UnoDialogSample implements XTextListener, XSpinListener, XActionLis // Add an Adjustment that will listen to changes of the scrollbar... XControl xSBControl = m_xDlgContainer.getControl(sName); - XScrollBar xScrollBar = (XScrollBar) UnoRuntime.queryInterface(XScrollBar.class, xSBControl); + XScrollBar xScrollBar = UnoRuntime.queryInterface(XScrollBar.class, xSBControl); xScrollBar.addAdjustmentListener(_xAdjustmentListener); } catch (com.sun.star.uno.Exception ex) { /* perform individual exception handling here. @@ -880,21 +880,21 @@ public class UnoDialogSample implements XTextListener, XSpinListener, XActionLis Object oCBModel = m_xMSFDialogModel.createInstance("com.sun.star.awt.UnoControlCheckBoxModel"); // Set the properties at the model - keep in mind to pass the property names in alphabetical order! - XMultiPropertySet xCBMPSet = (XMultiPropertySet) UnoRuntime.queryInterface(XMultiPropertySet.class, oCBModel); + XMultiPropertySet xCBMPSet = UnoRuntime.queryInterface(XMultiPropertySet.class, oCBModel); xCBMPSet.setPropertyValues( new String[] {"Height", "Label", "Name", "PositionX", "PositionY", "Width" } , new Object[] {new Integer(8), "~Include page number", sName, new Integer(_nPosX), new Integer(_nPosY), new Integer(_nWidth)}); // The following property may also be set with XMultiPropertySet but we // use the XPropertySet interface merely for reasons of demonstration - XPropertySet xCBModelPSet = (XPropertySet) UnoRuntime.queryInterface(XPropertySet.class, xCBMPSet); + XPropertySet xCBModelPSet = UnoRuntime.queryInterface(XPropertySet.class, xCBMPSet); xCBModelPSet.setPropertyValue("TriState", Boolean.TRUE); xCBModelPSet.setPropertyValue("State", new Short((short) 1)); // add the model to the NameContainer of the dialog model m_xDlgModelNameContainer.insertByName(sName, oCBModel); XControl xCBControl = m_xDlgContainer.getControl(sName); - xCheckBox = (XCheckBox) UnoRuntime.queryInterface(XCheckBox.class, xCBControl); + xCheckBox = UnoRuntime.queryInterface(XCheckBox.class, xCBControl); // An ActionListener will be notified on the activation of the button... xCheckBox.addItemListener(_xItemListener); } catch (com.sun.star.uno.Exception ex) { @@ -922,7 +922,7 @@ public class UnoDialogSample implements XTextListener, XSpinListener, XActionLis // create a controlmodel at the multiservicefactory of the dialog model... Object oRBModel = m_xMSFDialogModel.createInstance("com.sun.star.awt.UnoControlRadioButtonModel"); - XMultiPropertySet xRBMPSet = (XMultiPropertySet) UnoRuntime.queryInterface(XMultiPropertySet.class, oRBModel); + XMultiPropertySet xRBMPSet = UnoRuntime.queryInterface(XMultiPropertySet.class, oRBModel); // Set the properties at the model - keep in mind to pass the property names in alphabetical order! xRBMPSet.setPropertyValues( new String[] {"Height", "Label", "Name", "PositionX", "PositionY", "State", "TabIndex", "Width" } , @@ -934,7 +934,7 @@ public class UnoDialogSample implements XTextListener, XSpinListener, XActionLis sName = createUniqueName(m_xDlgModelNameContainer, "OptionButton"); oRBModel = m_xMSFDialogModel.createInstance("com.sun.star.awt.UnoControlRadioButtonModel"); - xRBMPSet = (XMultiPropertySet) UnoRuntime.queryInterface(XMultiPropertySet.class, oRBModel); + xRBMPSet = UnoRuntime.queryInterface(XMultiPropertySet.class, oRBModel); // Set the properties at the model - keep in mind to pass the property names in alphabetical order! xRBMPSet.setPropertyValues( new String[] {"Height", "Label", "Name", "PositionX", "PositionY", "TabIndex", "Width" } , @@ -964,14 +964,14 @@ public class UnoDialogSample implements XTextListener, XSpinListener, XActionLis // create a controlmodel at the multiservicefactory of the dialog model... Object oListBoxModel = m_xMSFDialogModel.createInstance("com.sun.star.awt.UnoControlListBoxModel"); - XMultiPropertySet xLBModelMPSet = (XMultiPropertySet) UnoRuntime.queryInterface(XMultiPropertySet.class, oListBoxModel); + XMultiPropertySet xLBModelMPSet = UnoRuntime.queryInterface(XMultiPropertySet.class, oListBoxModel); // Set the properties at the model - keep in mind to pass the property names in alphabetical order! xLBModelMPSet.setPropertyValues( new String[] {"Dropdown", "Height", "Name", "PositionX", "PositionY", "Step", "StringItemList", "Width" } , new Object[] {Boolean.TRUE, new Integer(12), sName, new Integer(_nPosX), new Integer(_nPosY), new Integer(_nStep), _sStringItemList, new Integer(_nWidth)}); // The following property may also be set with XMultiPropertySet but we // use the XPropertySet interface merely for reasons of demonstration - XPropertySet xLBModelPSet = (XPropertySet) UnoRuntime.queryInterface(XPropertySet.class, xLBModelMPSet); + XPropertySet xLBModelPSet = UnoRuntime.queryInterface(XPropertySet.class, xLBModelMPSet); xLBModelPSet.setPropertyValue("MultiSelection", Boolean.TRUE); short[] nSelItems = new short[] {(short) 1, (short) 3}; xLBModelPSet.setPropertyValue("SelectedItems", nSelItems); @@ -979,7 +979,7 @@ public class UnoDialogSample implements XTextListener, XSpinListener, XActionLis m_xDlgModelNameContainer.insertByName(sName, xLBModelMPSet); XControl xControl = m_xDlgContainer.getControl(sName); // retrieve a ListBox that is more convenient to work with than the Model of the ListBox... - xListBox = (XListBox) UnoRuntime.queryInterface(XListBox.class, xControl); + xListBox = UnoRuntime.queryInterface(XListBox.class, xControl); } catch (com.sun.star.uno.Exception ex) { /* perform individual exception handling here. * Possible exception types are: @@ -1006,7 +1006,7 @@ public class UnoDialogSample implements XTextListener, XSpinListener, XActionLis // create a controlmodel at the multiservicefactory of the dialog model... Object oComboBoxModel = m_xMSFDialogModel.createInstance("com.sun.star.awt.UnoControlComboBoxModel"); - XMultiPropertySet xCbBModelMPSet = (XMultiPropertySet) UnoRuntime.queryInterface(XMultiPropertySet.class, oComboBoxModel); + XMultiPropertySet xCbBModelMPSet = UnoRuntime.queryInterface(XMultiPropertySet.class, oComboBoxModel); // Set the properties at the model - keep in mind to pass the property names in alphabetical order! xCbBModelMPSet.setPropertyValues( new String[] {"Dropdown", "Height", "Name", "PositionX", "PositionY", "StringItemList", "Width" } , @@ -1014,7 +1014,7 @@ public class UnoDialogSample implements XTextListener, XSpinListener, XActionLis // The following property may also be set with XMultiPropertySet but we // use the XPropertySet interface merely for reasons of demonstration - XPropertySet xCbBModelPSet = (XPropertySet) UnoRuntime.queryInterface(XPropertySet.class, xCbBModelMPSet); + XPropertySet xCbBModelPSet = UnoRuntime.queryInterface(XPropertySet.class, xCbBModelMPSet); xCbBModelPSet.setPropertyValue("MaxTextLen", new Short((short) 10)); xCbBModelPSet.setPropertyValue("ReadOnly", Boolean.FALSE); @@ -1023,7 +1023,7 @@ public class UnoDialogSample implements XTextListener, XSpinListener, XActionLis XControl xControl = m_xDlgContainer.getControl(sName); // retrieve a ListBox that is more convenient to work with than the Model of the ListBox... - xComboBox = (XComboBox) UnoRuntime.queryInterface(XComboBox.class, xControl); + xComboBox = UnoRuntime.queryInterface(XComboBox.class, xControl); } catch (com.sun.star.uno.Exception ex) { /* perform individual exception handling here. * Possible exception types are: @@ -1049,13 +1049,13 @@ public class UnoDialogSample implements XTextListener, XSpinListener, XActionLis // create a controlmodel at the multiservicefactory of the dialog model... Object oFFModel = m_xMSFDialogModel.createInstance("com.sun.star.awt.UnoControlFormattedFieldModel"); - XMultiPropertySet xFFModelMPSet = (XMultiPropertySet) UnoRuntime.queryInterface(XMultiPropertySet.class, oFFModel); + XMultiPropertySet xFFModelMPSet = UnoRuntime.queryInterface(XMultiPropertySet.class, oFFModel); // Set the properties at the model - keep in mind to pass the property names in alphabetical order! xFFModelMPSet.setPropertyValues( new String[] {"EffectiveValue", "Height", "Name", "PositionX", "PositionY", "StrictFormat", "Spin", "Width"}, new Object[] { new Double(12348), new Integer(12), sName, new Integer(_nPosX), new Integer(_nPosY), Boolean.TRUE, Boolean.TRUE, new Integer(_nWidth)}); - xFFModelPSet = (XPropertySet) UnoRuntime.queryInterface(XPropertySet.class, oFFModel); + xFFModelPSet = UnoRuntime.queryInterface(XPropertySet.class, oFFModel); // to define a numberformat you always need a locale... com.sun.star.lang.Locale aLocale = new com.sun.star.lang.Locale(); aLocale.Country = "US"; @@ -1065,7 +1065,7 @@ public class UnoDialogSample implements XTextListener, XSpinListener, XActionLis // a NumberFormatsSupplier has to be created first "in the open countryside"... Object oNumberFormatsSupplier = m_xMCF.createInstanceWithContext("com.sun.star.util.NumberFormatsSupplier", m_xContext); - XNumberFormatsSupplier xNumberFormatsSupplier = (XNumberFormatsSupplier) UnoRuntime.queryInterface(XNumberFormatsSupplier.class, oNumberFormatsSupplier); + XNumberFormatsSupplier xNumberFormatsSupplier = UnoRuntime.queryInterface(XNumberFormatsSupplier.class, oNumberFormatsSupplier); XNumberFormats xNumberFormats = xNumberFormatsSupplier.getNumberFormats(); // is the numberformat already defined? int nFormatKey = xNumberFormats.queryKey(sFormatString, aLocale, true); @@ -1085,7 +1085,7 @@ public class UnoDialogSample implements XTextListener, XSpinListener, XActionLis // finally we add a Spin-Listener to the control XControl xFFControl = m_xDlgContainer.getControl(sName); // add a SpinListener that is notified on each change of the controlvalue... - XSpinField xSpinField = (XSpinField) UnoRuntime.queryInterface(XSpinField.class, xFFControl); + XSpinField xSpinField = UnoRuntime.queryInterface(XSpinField.class, xFFControl); xSpinField.addSpinListener(_xSpinListener); } catch (com.sun.star.uno.Exception ex) { @@ -1116,31 +1116,31 @@ public class UnoDialogSample implements XTextListener, XSpinListener, XActionLis // retrieve the configured Work path... Object oPathSettings = m_xMCF.createInstanceWithContext("com.sun.star.util.PathSettings",m_xContext); - XPropertySet xPropertySet = (XPropertySet) com.sun.star.uno.UnoRuntime.queryInterface(XPropertySet.class, oPathSettings); + XPropertySet xPropertySet = com.sun.star.uno.UnoRuntime.queryInterface(XPropertySet.class, oPathSettings); String sWorkUrl = (String) xPropertySet.getPropertyValue("Work"); // convert the Url to a system path that is "human readable"... Object oFCProvider = m_xMCF.createInstanceWithContext("com.sun.star.ucb.FileContentProvider", m_xContext); - XFileIdentifierConverter xFileIdentifierConverter = (XFileIdentifierConverter) UnoRuntime.queryInterface(XFileIdentifierConverter.class, oFCProvider); + XFileIdentifierConverter xFileIdentifierConverter = UnoRuntime.queryInterface(XFileIdentifierConverter.class, oFCProvider); String sSystemWorkPath = xFileIdentifierConverter.getSystemPathFromFileURL(sWorkUrl); // create a controlmodel at the multiservicefactory of the dialog model... Object oFCModel = m_xMSFDialogModel.createInstance("com.sun.star.awt.UnoControlFileControlModel"); // Set the properties at the model - keep in mind to pass the property names in alphabetical order! - XMultiPropertySet xFCModelMPSet = (XMultiPropertySet) UnoRuntime.queryInterface(XMultiPropertySet.class, oFCModel); + XMultiPropertySet xFCModelMPSet = UnoRuntime.queryInterface(XMultiPropertySet.class, oFCModel); xFCModelMPSet.setPropertyValues( new String[] {"Height", "Name", "PositionX", "PositionY", "Text", "Width"}, new Object[] { new Integer(14), sName, new Integer(_nPosX), new Integer(_nPosY), sSystemWorkPath, new Integer(_nWidth)}); // The controlmodel is not really available until inserted to the Dialog container m_xDlgModelNameContainer.insertByName(sName, oFCModel); - XPropertySet xFCModelPSet = (XPropertySet) UnoRuntime.queryInterface(XPropertySet.class, oFCModel); + XPropertySet xFCModelPSet = UnoRuntime.queryInterface(XPropertySet.class, oFCModel); // add a textlistener that is notified on each change of the controlvalue... XControl xFCControl = m_xDlgContainer.getControl(sName); - xTextComponent = (XTextComponent) UnoRuntime.queryInterface(XTextComponent.class, xFCControl); - XWindow xFCWindow = (XWindow) UnoRuntime.queryInterface(XWindow.class, xFCControl); + xTextComponent = UnoRuntime.queryInterface(XTextComponent.class, xFCControl); + XWindow xFCWindow = UnoRuntime.queryInterface(XWindow.class, xFCControl); xTextComponent.addTextListener(_xTextListener); } catch (com.sun.star.uno.Exception ex) { /* perform individual exception handling here. @@ -1166,7 +1166,7 @@ public class UnoDialogSample implements XTextListener, XSpinListener, XActionLis // create a controlmodel at the multiservicefactory of the dialog model... Object oButtonModel = m_xMSFDialogModel.createInstance("com.sun.star.awt.UnoControlButtonModel"); - XMultiPropertySet xButtonMPSet = (XMultiPropertySet) UnoRuntime.queryInterface(XMultiPropertySet.class, oButtonModel); + XMultiPropertySet xButtonMPSet = UnoRuntime.queryInterface(XMultiPropertySet.class, oButtonModel); // Set the properties at the model - keep in mind to pass the property names in alphabetical order! xButtonMPSet.setPropertyValues( new String[] {"Height", "Label", "Name", "PositionX", "PositionY", "PushButtonType", "Width" } , @@ -1175,7 +1175,7 @@ public class UnoDialogSample implements XTextListener, XSpinListener, XActionLis // add the model to the NameContainer of the dialog model m_xDlgModelNameContainer.insertByName(sName, oButtonModel); XControl xButtonControl = m_xDlgContainer.getControl(sName); - xButton = (XButton) UnoRuntime.queryInterface(XButton.class, xButtonControl); + xButton = UnoRuntime.queryInterface(XButton.class, xButtonControl); // An ActionListener will be notified on the activation of the button... xButton.addActionListener(_xActionListener); } catch (com.sun.star.uno.Exception ex) { @@ -1198,10 +1198,10 @@ public class UnoDialogSample implements XTextListener, XSpinListener, XActionLis * @return the windowpeer of the frame */ public XWindowPeer getWindowPeer(XTextDocument _xTextDocument){ - XModel xModel = (XModel) UnoRuntime.queryInterface(XModel.class, _xTextDocument); + XModel xModel = UnoRuntime.queryInterface(XModel.class, _xTextDocument); XFrame xFrame = xModel.getCurrentController().getFrame(); XWindow xWindow = xFrame.getContainerWindow(); - XWindowPeer xWindowPeer = (XWindowPeer) UnoRuntime.queryInterface(XWindowPeer.class, xWindow); + XWindowPeer xWindowPeer = UnoRuntime.queryInterface(XWindowPeer.class, xWindow); return xWindowPeer; } @@ -1209,7 +1209,7 @@ public class UnoDialogSample implements XTextListener, XSpinListener, XActionLis XFrame xRetFrame = null; try { Object oDesktop = m_xMCF.createInstanceWithContext("com.sun.star.frame.Desktop", m_xContext); - XDesktop xDesktop = (XDesktop) UnoRuntime.queryInterface(XDesktop.class, oDesktop); + XDesktop xDesktop = UnoRuntime.queryInterface(XDesktop.class, oDesktop); xRetFrame = xDesktop.getCurrentFrame(); } catch (com.sun.star.uno.Exception ex) { ex.printStackTrace(); @@ -1221,9 +1221,9 @@ public class UnoDialogSample implements XTextListener, XSpinListener, XActionLis public void textChanged(TextEvent textEvent) { try { // get the control that has fired the event, - XControl xControl = (XControl) UnoRuntime.queryInterface(XControl.class, textEvent.Source); + XControl xControl = UnoRuntime.queryInterface(XControl.class, textEvent.Source); XControlModel xControlModel = xControl.getModel(); - XPropertySet xPSet = (XPropertySet) UnoRuntime.queryInterface(XPropertySet.class, xControlModel); + XPropertySet xPSet = UnoRuntime.queryInterface(XPropertySet.class, xControlModel); String sName = (String) xPSet.getPropertyValue("Name"); // just in case the listener has been added to several controls, // we make sure we refer to the right one @@ -1248,9 +1248,9 @@ public class UnoDialogSample implements XTextListener, XSpinListener, XActionLis public void up(SpinEvent spinEvent) { try { // get the control that has fired the event, - XControl xControl = (XControl) UnoRuntime.queryInterface(XControl.class, spinEvent.Source); + XControl xControl = UnoRuntime.queryInterface(XControl.class, spinEvent.Source); XControlModel xControlModel = xControl.getModel(); - XPropertySet xPSet = (XPropertySet) UnoRuntime.queryInterface(XPropertySet.class, xControlModel); + XPropertySet xPSet = UnoRuntime.queryInterface(XPropertySet.class, xControlModel); String sName = (String) xPSet.getPropertyValue("Name"); // just in case the listener has been added to several controls, // we make sure we refer to the right one @@ -1287,9 +1287,9 @@ public class UnoDialogSample implements XTextListener, XSpinListener, XActionLis public void actionPerformed(ActionEvent rEvent) { try{ // get the control that has fired the event, - XControl xControl = (XControl) UnoRuntime.queryInterface(XControl.class, rEvent.Source); + XControl xControl = UnoRuntime.queryInterface(XControl.class, rEvent.Source); XControlModel xControlModel = xControl.getModel(); - XPropertySet xPSet = (XPropertySet) UnoRuntime.queryInterface(XPropertySet.class, xControlModel); + XPropertySet xPSet = UnoRuntime.queryInterface(XPropertySet.class, xControlModel); String sName = (String) xPSet.getPropertyValue("Name"); // just in case the listener has been added to several controls, // we make sure we refer to the right one @@ -1315,7 +1315,7 @@ public class UnoDialogSample implements XTextListener, XSpinListener, XActionLis // get the window of the Window that has gained the Focus... // Note that the xWindow is just a representation of the controlwindow // but not of the control itself - XWindow xWindow = (XWindow) UnoRuntime.queryInterface(XWindow.class, _focusEvent.NextFocus); + XWindow xWindow = UnoRuntime.queryInterface(XWindow.class, _focusEvent.NextFocus); } } @@ -1335,15 +1335,15 @@ public class UnoDialogSample implements XTextListener, XSpinListener, XActionLis public void mouseEntered(MouseEvent _mouseEvent) { try { // retrieve the control that the event has been invoked at... - XControl xControl = (XControl) UnoRuntime.queryInterface(XControl.class, _mouseEvent.Source); + XControl xControl = UnoRuntime.queryInterface(XControl.class, _mouseEvent.Source); Object tk = m_xMCF.createInstanceWithContext("com.sun.star.awt.Toolkit", m_xContext); - XToolkit xToolkit = (XToolkit) UnoRuntime.queryInterface(XToolkit.class, tk); + XToolkit xToolkit = UnoRuntime.queryInterface(XToolkit.class, tk); // create the peer of the control by passing the windowpeer of the parent // in this case the windowpeer of the control xControl.createPeer(xToolkit, m_xWindowPeer); // create a pointer object "in the open countryside" and set the type accordingly... Object oPointer = this.m_xMCF.createInstanceWithContext("com.sun.star.awt.Pointer", this.m_xContext); - XPointer xPointer = (XPointer) UnoRuntime.queryInterface(XPointer.class, oPointer); + XPointer xPointer = UnoRuntime.queryInterface(XPointer.class, oPointer); xPointer.setType(com.sun.star.awt.SystemPointer.REFHAND); // finally set the created pointer at the windowpeer of the control xControl.getPeer().setPointer(xPointer); @@ -1357,10 +1357,10 @@ public class UnoDialogSample implements XTextListener, XSpinListener, XActionLis public void itemStateChanged(ItemEvent itemEvent) { try{ // retrieve the control that the event has been invoked at... - XCheckBox xCheckBox = (XCheckBox) UnoRuntime.queryInterface(XCheckBox.class, itemEvent.Source); + XCheckBox xCheckBox = UnoRuntime.queryInterface(XCheckBox.class, itemEvent.Source); // retrieve the control that we want to disable or enable - XControl xControl = (XControl) UnoRuntime.queryInterface(XControl.class, m_xDlgContainer.getControl("CommandButton1")); - XPropertySet xModelPropertySet = (XPropertySet) UnoRuntime.queryInterface(XPropertySet.class, xControl.getModel()); + XControl xControl = UnoRuntime.queryInterface(XControl.class, m_xDlgContainer.getControl("CommandButton1")); + XPropertySet xModelPropertySet = UnoRuntime.queryInterface(XPropertySet.class, xControl.getModel()); short nState = xCheckBox.getState(); boolean bdoEnable = true; switch (nState){ @@ -1417,7 +1417,7 @@ public class UnoDialogSample implements XTextListener, XSpinListener, XActionLis // create a unique name by means of an own implementation... String sRoadmapName = createUniqueName(m_xDlgModelNameContainer, "Roadmap"); - xDialogModelPropertySet = (XPropertySet) UnoRuntime.queryInterface(XPropertySet.class, m_xMSFDialogModel); + xDialogModelPropertySet = UnoRuntime.queryInterface(XPropertySet.class, m_xMSFDialogModel); // Similar to the office assistants the roadmap is adjusted to the height of the dialog // where a certain space is left at the bottom for the buttons... int nDialogHeight = ((Integer) xDialogModelPropertySet.getPropertyValue("Height")).intValue(); @@ -1426,21 +1426,21 @@ public class UnoDialogSample implements XTextListener, XSpinListener, XActionLis Object oRoadmapModel = m_xMSFDialogModel.createInstance("com.sun.star.awt.UnoControlRoadmapModel"); // define the properties of the roadmapmodel - XMultiPropertySet xRMMPSet = (XMultiPropertySet) UnoRuntime.queryInterface(XMultiPropertySet.class, oRoadmapModel); + XMultiPropertySet xRMMPSet = UnoRuntime.queryInterface(XMultiPropertySet.class, oRoadmapModel); xRMMPSet.setPropertyValues( new String[] {"Complete", "Height", "Name", "PositionX", "PositionY", "Text", "Width" }, new Object[] {Boolean.FALSE, new Integer(nDialogHeight - 26), sRoadmapName, new Integer(0), new Integer(0), "Steps", new Integer(85)}); - m_xRMPSet = (XPropertySet) UnoRuntime.queryInterface(XPropertySet.class, oRoadmapModel); + m_xRMPSet = UnoRuntime.queryInterface(XPropertySet.class, oRoadmapModel); // add the roadmapmodel to the dialog container.. m_xDlgModelNameContainer.insertByName(sRoadmapName, oRoadmapModel); // the roadmapmodel is a SingleServiceFactory to instantiate the roadmapitems... - m_xSSFRoadmap = (XSingleServiceFactory) UnoRuntime.queryInterface(XSingleServiceFactory.class, oRoadmapModel); - m_xRMIndexCont = (XIndexContainer) UnoRuntime.queryInterface(XIndexContainer.class, oRoadmapModel); + m_xSSFRoadmap = UnoRuntime.queryInterface(XSingleServiceFactory.class, oRoadmapModel); + m_xRMIndexCont = UnoRuntime.queryInterface(XIndexContainer.class, oRoadmapModel); // add the itemlistener to the control... XControl xRMControl = this.m_xDlgContainer.getControl(sRoadmapName); - XItemEventBroadcaster xRMBroadcaster = (XItemEventBroadcaster) UnoRuntime.queryInterface(XItemEventBroadcaster.class, xRMControl); + XItemEventBroadcaster xRMBroadcaster = UnoRuntime.queryInterface(XItemEventBroadcaster.class, xRMControl); xRMBroadcaster.addItemListener( getRoadmapItemStateChangeListener() ); } catch (java.lang.Exception jexception) { jexception.printStackTrace(System.err); @@ -1457,7 +1457,7 @@ public class UnoDialogSample implements XTextListener, XSpinListener, XActionLis // a roadmap is a SingleServiceFactory that can only create roadmapitems that are the only possible // element types of the container Object oRoadmapItem = m_xSSFRoadmap.createInstance(); - XPropertySet xRMItemPSet = (XPropertySet) UnoRuntime.queryInterface(XPropertySet.class, oRoadmapItem); + XPropertySet xRMItemPSet = UnoRuntime.queryInterface(XPropertySet.class, oRoadmapItem); xRMItemPSet.setPropertyValue("Label", _sLabel); // sometimes steps are supposed to be set disabled depending on the program logic... xRMItemPSet.setPropertyValue("Enabled", new Boolean(_bEnabled)); diff --git a/odk/examples/DevelopersGuide/GUI/UnoDialogSample2.java b/odk/examples/DevelopersGuide/GUI/UnoDialogSample2.java index a410a16de40c..a48e46956826 100644 --- a/odk/examples/DevelopersGuide/GUI/UnoDialogSample2.java +++ b/odk/examples/DevelopersGuide/GUI/UnoDialogSample2.java @@ -70,7 +70,7 @@ public class UnoDialogSample2 extends UnoDialogSample { try { m_oUnoObject = _oUnoObject; Object o = m_xMCF.createInstanceWithContext("com.sun.star.beans.Introspection", m_xContext); - XIntrospection m_xIntrospection = ( XIntrospection ) UnoRuntime.queryInterface(XIntrospection.class, o ); + XIntrospection m_xIntrospection = UnoRuntime.queryInterface(XIntrospection.class, o ); // the variable m_xIntrospectionAccess offers functionality to access all methods and properties // of a variable m_xIntrospectionAccess = m_xIntrospection.inspect(_oUnoObject); @@ -89,11 +89,11 @@ public class UnoDialogSample2 extends UnoDialogSample { PropertyValue[] aPropertyValues = new PropertyValue[]{}; // create an arbitrary Uno-Object - in this case an empty writer document.. Object oDesktop =xMCF.createInstanceWithContext("com.sun.star.frame.Desktop", xContext); - XComponentLoader xComponentLoader = (XComponentLoader) UnoRuntime.queryInterface(XComponentLoader.class, oDesktop); + XComponentLoader xComponentLoader = UnoRuntime.queryInterface(XComponentLoader.class, oDesktop); Object oUnoObject = xComponentLoader.loadComponentFromURL("private:factory/swriter", "_default", 0, aPropertyValues); // define some coordinates where to position the controls - final int nButtonPosX = (int)((nDialogWidth/2) - (nButtonWidth/2)); + final int nButtonPosX = (nDialogWidth/2) - (nButtonWidth/2); final int nButtonPosY = nDialogHeight - nButtonHeight - nControlMargin; final int nControlPosX = nRoadmapWidth + 2*nControlMargin; final int nControlWidth = nDialogWidth - 3*nControlMargin - nRoadmapWidth; @@ -129,7 +129,7 @@ public class UnoDialogSample2 extends UnoDialogSample { oUnoDialogSample2.insertRoadmapItem(4, true, "Properties", 5); oUnoDialogSample2.m_xRMPSet.setPropertyValue("CurrentItemID", new Short((short) 1)); oUnoDialogSample2.m_xRMPSet.setPropertyValue("Complete", Boolean.TRUE); - oUnoDialogSample2.xDialog = (XDialog) UnoRuntime.queryInterface(XDialog.class, oUnoDialogSample2.m_xDialogControl); + oUnoDialogSample2.xDialog = UnoRuntime.queryInterface(XDialog.class, oUnoDialogSample2.m_xDialogControl); oUnoDialogSample2.xDialog.execute(); }catch( Exception ex ) { ex.printStackTrace(System.err); @@ -167,7 +167,7 @@ public class UnoDialogSample2 extends UnoDialogSample { String[] sSupportedServiceNames = new String[]{}; // If the Uno-Object supports "com.sun.star.lang.XServiceInfo" // this will give access to all supported servicenames - XServiceInfo xServiceInfo = ( XServiceInfo ) UnoRuntime.queryInterface( XServiceInfo.class, m_oUnoObject); + XServiceInfo xServiceInfo = UnoRuntime.queryInterface( XServiceInfo.class, m_oUnoObject); if ( xServiceInfo != null ) { sSupportedServiceNames = xServiceInfo.getSupportedServiceNames(); } @@ -196,7 +196,7 @@ public class UnoDialogSample2 extends UnoDialogSample { Type[] aTypes = new Type[]{}; String[] sTypeNames = new String[]{}; // The XTypeProvider interfaces offers access to all exported interfaces - XTypeProvider xTypeProvider = ( XTypeProvider ) UnoRuntime.queryInterface( XTypeProvider.class, m_oUnoObject); + XTypeProvider xTypeProvider = UnoRuntime.queryInterface( XTypeProvider.class, m_oUnoObject); if ( xTypeProvider != null ) { aTypes = xTypeProvider.getTypes(); sTypeNames = new String[aTypes.length]; @@ -216,7 +216,7 @@ public class UnoDialogSample2 extends UnoDialogSample { String sName = createUniqueName(m_xDlgModelNameContainer, "ListBox"); // create a controlmodel at the multiservicefactory of the dialog model... Object oListBoxModel = m_xMSFDialogModel.createInstance("com.sun.star.awt.UnoControlListBoxModel"); - XMultiPropertySet xLBModelMPSet = (XMultiPropertySet) UnoRuntime.queryInterface(XMultiPropertySet.class, oListBoxModel); + XMultiPropertySet xLBModelMPSet = UnoRuntime.queryInterface(XMultiPropertySet.class, oListBoxModel); // Set the properties at the model - keep in mind to pass the property names in alphabetical order! xLBModelMPSet.setPropertyValues( new String[] {"Dropdown", "Height", "Name", "PositionX", "PositionY", "ReadOnly", "Step", "StringItemList", "Width" } , @@ -236,7 +236,7 @@ public class UnoDialogSample2 extends UnoDialogSample { int nHeight = _nLineCount * nFixedTextHeight; // create a controlmodel at the multiservicefactory of the dialog model... Object oFTModel = m_xMSFDialogModel.createInstance("com.sun.star.awt.UnoControlFixedTextModel"); - XMultiPropertySet xFTModelMPSet = (XMultiPropertySet) UnoRuntime.queryInterface(XMultiPropertySet.class, oFTModel); + XMultiPropertySet xFTModelMPSet = UnoRuntime.queryInterface(XMultiPropertySet.class, oFTModel); // Set the properties at the model - keep in mind to pass the property names in alphabetical order! xFTModelMPSet.setPropertyValues( new String[] {"Height", "Label", "MultiLine", "Name", "PositionX", "PositionY", "Step", "Width"}, diff --git a/odk/examples/DevelopersGuide/GUI/UnoMenu.java b/odk/examples/DevelopersGuide/GUI/UnoMenu.java index c5fdbe218350..86942f91c0d6 100644 --- a/odk/examples/DevelopersGuide/GUI/UnoMenu.java +++ b/odk/examples/DevelopersGuide/GUI/UnoMenu.java @@ -65,8 +65,8 @@ public UnoMenu(XComponentContext _xContext, XMultiComponentFactory _xMCF) { try{ // create a popup menu Object oPopupMenu = m_xMCF.createInstanceWithContext("stardiv.Toolkit.VCLXPopupMenu", m_xContext); - xPopupMenu = (XPopupMenu) UnoRuntime.queryInterface(XPopupMenu.class, oPopupMenu); - XMenuExtended xMenuExtended = (XMenuExtended) UnoRuntime.queryInterface(XMenuExtended.class, xPopupMenu); + xPopupMenu = UnoRuntime.queryInterface(XPopupMenu.class, oPopupMenu); + XMenuExtended xMenuExtended = UnoRuntime.queryInterface(XMenuExtended.class, xPopupMenu); xPopupMenu.insertItem((short) 0, "~First Entry", MenuItemStyle.AUTOCHECK, (short) 0); xPopupMenu.insertItem((short) 1, "First ~Radio Entry", (short) (MenuItemStyle.RADIOCHECK + MenuItemStyle.AUTOCHECK), (short) 1); @@ -92,7 +92,7 @@ public UnoMenu(XComponentContext _xContext, XMultiComponentFactory _xMCF) { // create a menubar at the global MultiComponentFactory... Object oMenuBar = m_xMCF.createInstanceWithContext("stardiv.Toolkit.VCLXMenuBar", m_xContext); // add the menu items... - XMenuBar xMenuBar = (XMenuBar) UnoRuntime.queryInterface(XMenuBar.class, oMenuBar); + XMenuBar xMenuBar = UnoRuntime.queryInterface(XMenuBar.class, oMenuBar); xMenuBar.insertItem((short) 0, "~First MenuBar Item", com.sun.star.awt.MenuItemStyle.AUTOCHECK, (short) 0); xMenuBar.insertItem((short) 1, "~Second MenuBar Item", com.sun.star.awt.MenuItemStyle.AUTOCHECK, (short) 1); xMenuBar.setPopupMenu((short) 0, getPopupMenu()); @@ -103,7 +103,7 @@ public UnoMenu(XComponentContext _xContext, XMultiComponentFactory _xMCF) { }} protected void closeDialog(){ - XComponent xComponent = (XComponent) UnoRuntime.queryInterface(XComponent.class, mxTopWindow); + XComponent xComponent = UnoRuntime.queryInterface(XComponent.class, mxTopWindow); if (xComponent != null){ xComponent.dispose(); } @@ -117,7 +117,7 @@ public UnoMenu(XComponentContext _xContext, XMultiComponentFactory _xMCF) { try { // The Toolkit is the creator of all windows... Object oToolkit = m_xMCF.createInstanceWithContext("com.sun.star.awt.Toolkit", m_xContext); - XToolkit xToolkit = (XToolkit) UnoRuntime.queryInterface(XToolkit.class, oToolkit); + XToolkit xToolkit = UnoRuntime.queryInterface(XToolkit.class, oToolkit); // set up a window description and create the window. A parent window is always necessary for this... com.sun.star.awt.WindowDescriptor aWindowDescriptor = new com.sun.star.awt.WindowDescriptor(); @@ -130,17 +130,17 @@ public UnoMenu(XComponentContext _xContext, XMultiComponentFactory _xMCF) { // create the window... XWindowPeer xWindowPeer = xToolkit.createWindow(aWindowDescriptor); - XWindow xWindow = (XWindow) UnoRuntime.queryInterface(XWindow.class, xWindowPeer); + XWindow xWindow = UnoRuntime.queryInterface(XWindow.class, xWindowPeer); // create a frame and initialize it with the created window... Object oFrame = m_xMCF.createInstanceWithContext("com.sun.star.frame.Frame", m_xContext); - m_xFrame = (XFrame) UnoRuntime.queryInterface(XFrame.class, oFrame); + m_xFrame = UnoRuntime.queryInterface(XFrame.class, oFrame); Object oDesktop = m_xMCF.createInstanceWithContext("com.sun.star.frame.Desktop", m_xContext); - XFramesSupplier xFramesSupplier = (XFramesSupplier) UnoRuntime.queryInterface(XFramesSupplier.class, oDesktop); + XFramesSupplier xFramesSupplier = UnoRuntime.queryInterface(XFramesSupplier.class, oDesktop); m_xFrame.setCreator(xFramesSupplier); // get the XTopWindow interface.. - xTopWindow = (XTopWindow) UnoRuntime.queryInterface(XTopWindow.class, xWindow); + xTopWindow = UnoRuntime.queryInterface(XTopWindow.class, xWindow); } catch (com.sun.star.lang.IllegalArgumentException ex) { ex.printStackTrace(); } catch (com.sun.star.uno.Exception ex) { @@ -150,7 +150,7 @@ public UnoMenu(XComponentContext _xContext, XMultiComponentFactory _xMCF) { } public void addMenuBar(XWindow _xWindow){ - XTopWindow xTopWindow = (XTopWindow) UnoRuntime.queryInterface(XTopWindow.class, _xWindow); + XTopWindow xTopWindow = UnoRuntime.queryInterface(XTopWindow.class, _xWindow); addMenuBar(xTopWindow, this); } diff --git a/odk/examples/DevelopersGuide/GUI/UnoMenu2.java b/odk/examples/DevelopersGuide/GUI/UnoMenu2.java index 89643415c24e..0edae176bd71 100644 --- a/odk/examples/DevelopersGuide/GUI/UnoMenu2.java +++ b/odk/examples/DevelopersGuide/GUI/UnoMenu2.java @@ -46,7 +46,7 @@ public UnoMenu2(XComponentContext _xContext, XMultiComponentFactory _xMCF) { new Object[] { new Integer(140), Boolean.TRUE, "Dialog1", new Integer(102),new Integer(41), new Integer(1), new Short((short) 0), "Menu-Dialog", new Integer(200)}); Object oFTHeaderModel = oUnoMenu2.m_xMSFDialogModel.createInstance("com.sun.star.awt.UnoControlFixedTextModel"); - XMultiPropertySet xFTHeaderModelMPSet = (XMultiPropertySet) UnoRuntime.queryInterface(XMultiPropertySet.class, oFTHeaderModel); + XMultiPropertySet xFTHeaderModelMPSet = UnoRuntime.queryInterface(XMultiPropertySet.class, oFTHeaderModel); xFTHeaderModelMPSet.setPropertyValues( new String[] {"Height", "Label", "Name", "PositionX", "PositionY", "Width"}, new Object[] { new Integer(8), "This code-sample demonstrates the creation of a popup-menu", "HeaderLabel", new Integer(6), new Integer(6), new Integer(200)}); @@ -72,14 +72,14 @@ public UnoMenu2(XComponentContext _xContext, XMultiComponentFactory _xMCF) { try{ String sName = "lblPopup"; Object oFTModel = m_xMSFDialogModel.createInstance("com.sun.star.awt.UnoControlFixedTextModel"); - XMultiPropertySet xFTModelMPSet = (XMultiPropertySet) UnoRuntime.queryInterface(XMultiPropertySet.class, oFTModel); + XMultiPropertySet xFTModelMPSet = UnoRuntime.queryInterface(XMultiPropertySet.class, oFTModel); // Set the properties at the model - keep in mind to pass the property names in alphabetical order! xFTModelMPSet.setPropertyValues( new String[] {"Height", "Label", "Name", "PositionX", "PositionY", "Width"}, new Object[] { new Integer(8), "Right-click here", sName, new Integer(50), new Integer(50), new Integer(100)}); // add the model to the NameContainer of the dialog model m_xDlgModelNameContainer.insertByName(sName, oFTModel); - XWindow xWindow = (XWindow) UnoRuntime.queryInterface(XWindow.class, m_xDlgContainer.getControl(sName)); + XWindow xWindow = UnoRuntime.queryInterface(XWindow.class, m_xDlgContainer.getControl(sName)); xWindow.addMouseListener(this); }catch( Exception e ) { System.err.println( e + e.getMessage()); @@ -96,7 +96,7 @@ public UnoMenu2(XComponentContext _xContext, XMultiComponentFactory _xMCF) { public void mousePressed(MouseEvent mouseEvent) { if (mouseEvent.PopupTrigger){ Rectangle aRectangle = new Rectangle(mouseEvent.X, mouseEvent.Y, 0, 0); - XControl xControl = (XControl) UnoRuntime.queryInterface(XControl.class, mouseEvent.Source); + XControl xControl = UnoRuntime.queryInterface(XControl.class, mouseEvent.Source); getPopupMenu().execute( xControl.getPeer(), aRectangle, com.sun.star.awt.PopupMenuDirection.DEFAULT); } } |