diff options
author | Noel Grandin <noel@peralex.com> | 2012-06-27 15:40:17 +0200 |
---|---|---|
committer | Michael Stahl <mstahl@redhat.com> | 2012-06-29 22:03:01 +0200 |
commit | b65017a2a7af290f6681da7b197a52efe83d5185 (patch) | |
tree | 06f71a435ba200d044109469b13be7c8f5dbe950 /qadevOOo/runner/util/SOfficeFactory.java | |
parent | 33ec740d1438c3dddf8e1974757ed05bb76425ca (diff) |
Java5 update - usage generics where possible
Change-Id: I12f8c448961919e153047e28fee2a0acf3af1002
Diffstat (limited to 'qadevOOo/runner/util/SOfficeFactory.java')
-rw-r--r-- | qadevOOo/runner/util/SOfficeFactory.java | 46 |
1 files changed, 23 insertions, 23 deletions
diff --git a/qadevOOo/runner/util/SOfficeFactory.java b/qadevOOo/runner/util/SOfficeFactory.java index 27398b2f486e..327b271c946c 100644 --- a/qadevOOo/runner/util/SOfficeFactory.java +++ b/qadevOOo/runner/util/SOfficeFactory.java @@ -44,7 +44,7 @@ import com.sun.star.awt.*; public class SOfficeFactory { - private static HashMap lookup = new HashMap(10); + private static HashMap<String, SOfficeFactory> lookup = new HashMap<String, SOfficeFactory>(10); protected XComponentLoader oCLoader; private SOfficeFactory(XMultiServiceFactory xMSF) { @@ -58,16 +58,16 @@ public class SOfficeFactory { } // query the desktop interface and then it's componentloader - XDesktop oDesktop = (XDesktop) UnoRuntime.queryInterface( + XDesktop oDesktop = UnoRuntime.queryInterface( XDesktop.class, oInterface); - oCLoader = (XComponentLoader) UnoRuntime.queryInterface( + oCLoader = UnoRuntime.queryInterface( XComponentLoader.class, oDesktop); } public static SOfficeFactory getFactory(XMultiServiceFactory xMSF) { - SOfficeFactory soFactory = (SOfficeFactory) lookup.get(new Integer(xMSF.hashCode()).toString()); + SOfficeFactory soFactory = lookup.get(new Integer(xMSF.hashCode()).toString()); if (soFactory == null) { soFactory = new SOfficeFactory(xMSF); @@ -92,7 +92,7 @@ public class SOfficeFactory { if (oDoc != null) { DesktopTools.bringWindowToFront(oDoc); - return (XTextDocument) UnoRuntime.queryInterface(XTextDocument.class, oDoc); + return UnoRuntime.queryInterface(XTextDocument.class, oDoc); } else { return null; } @@ -111,7 +111,7 @@ public class SOfficeFactory { if (oDoc != null) { DesktopTools.bringWindowToFront(oDoc); - return (XTextDocument) UnoRuntime.queryInterface(XTextDocument.class, oDoc); + return UnoRuntime.queryInterface(XTextDocument.class, oDoc); } else { return null; } @@ -129,7 +129,7 @@ public class SOfficeFactory { if (oDoc != null) { DesktopTools.bringWindowToFront(oDoc); - return (XSpreadsheetDocument) UnoRuntime.queryInterface(XSpreadsheetDocument.class, oDoc); + return UnoRuntime.queryInterface(XSpreadsheetDocument.class, oDoc); } else { return null; } @@ -147,7 +147,7 @@ public class SOfficeFactory { if (oDoc != null) { DesktopTools.bringWindowToFront(oDoc); - return (XSpreadsheetDocument) UnoRuntime.queryInterface(XSpreadsheetDocument.class, oDoc); + return UnoRuntime.queryInterface(XSpreadsheetDocument.class, oDoc); } else { return null; } @@ -225,7 +225,7 @@ public class SOfficeFactory { if (oDoc != null) { DesktopTools.bringWindowToFront(oDoc); - return (XChartDocument) UnoRuntime.queryInterface(XChartDocument.class, oDoc); + return UnoRuntime.queryInterface(XChartDocument.class, oDoc); } else { return null; } @@ -290,7 +290,7 @@ public class SOfficeFactory { public static void insertString(XTextDocument xTextDoc, String cString) throws com.sun.star.uno.Exception { XText xText = xTextDoc.getText(); - XText oText = (XText) UnoRuntime.queryInterface( + XText oText = UnoRuntime.queryInterface( XText.class, xText); XTextCursor oCursor = oText.createTextCursor(); @@ -301,7 +301,7 @@ public class SOfficeFactory { XTextContent xCont) throws com.sun.star.lang.IllegalArgumentException { XText xText = xTextDoc.getText(); - XText oText = (XText) UnoRuntime.queryInterface( + XText oText = UnoRuntime.queryInterface( XText.class, xText); XTextCursor oCursor = oText.createTextCursor(); @@ -367,12 +367,12 @@ public class SOfficeFactory { public static XTextContent createIndex(XTextDocument xTextDoc, String kind) throws com.sun.star.uno.Exception { - XMultiServiceFactory oDocMSF = (XMultiServiceFactory) UnoRuntime.queryInterface(XMultiServiceFactory.class, + XMultiServiceFactory oDocMSF = UnoRuntime.queryInterface(XMultiServiceFactory.class, xTextDoc); Object oInt = oDocMSF.createInstance(kind); - XTextContent xTC = (XTextContent) UnoRuntime.queryInterface(XDocumentIndex.class, oInt); + XTextContent xTC = UnoRuntime.queryInterface(XDocumentIndex.class, oInt); return xTC; @@ -381,7 +381,7 @@ public class SOfficeFactory { public static XSpreadsheet createSpreadsheet(XSpreadsheetDocument oDoc) throws com.sun.star.uno.Exception { - XMultiServiceFactory oDocMSF = (XMultiServiceFactory) UnoRuntime.queryInterface(XMultiServiceFactory.class, oDoc); + XMultiServiceFactory oDocMSF = UnoRuntime.queryInterface(XMultiServiceFactory.class, oDoc); Object oInt = oDocMSF.createInstance( "com.sun.star.sheet.Spreadsheet"); @@ -393,10 +393,10 @@ public class SOfficeFactory { public static XIndexAccess getTableCollection(XTextDocument oDoc) { - XTextTablesSupplier oTTS = (XTextTablesSupplier) UnoRuntime.queryInterface(XTextTablesSupplier.class, oDoc); + XTextTablesSupplier oTTS = UnoRuntime.queryInterface(XTextTablesSupplier.class, oDoc); XNameAccess oNA = oTTS.getTextTables(); - XIndexAccess oIA = (XIndexAccess) UnoRuntime.queryInterface(XIndexAccess.class, oNA); + XIndexAccess oIA = UnoRuntime.queryInterface(XIndexAccess.class, oNA); return oIA; } @@ -433,11 +433,11 @@ public class SOfficeFactory { XDiagram oDiagram = null; //get LineDiagram - XMultiServiceFactory oDocMSF = (XMultiServiceFactory) UnoRuntime.queryInterface(XMultiServiceFactory.class, oDoc); + XMultiServiceFactory oDocMSF = UnoRuntime.queryInterface(XMultiServiceFactory.class, oDoc); try { oInterface = (XInterface) oDocMSF.createInstance("com.sun.star.chart." + kind); - oDiagram = (XDiagram) UnoRuntime.queryInterface(XDiagram.class, oInterface); + oDiagram = UnoRuntime.queryInterface(XDiagram.class, oInterface); } catch (Exception e) { // Some exception occures.FAILED System.out.println("Couldn't create " + kind + "-Diagram " + e); @@ -452,7 +452,7 @@ public class SOfficeFactory { XInterface oControl = null; - XMultiServiceFactory oDocMSF = (XMultiServiceFactory) UnoRuntime.queryInterface(XMultiServiceFactory.class, oDoc); + XMultiServiceFactory oDocMSF = UnoRuntime.queryInterface(XMultiServiceFactory.class, oDoc); try { oControl = (XInterface) oDocMSF.createInstance("com.sun.star.form.component." + kind); @@ -470,7 +470,7 @@ public class SOfficeFactory { Object oInstance = null; - XMultiServiceFactory oDocMSF = (XMultiServiceFactory) UnoRuntime.queryInterface(XMultiServiceFactory.class, oDoc); + XMultiServiceFactory oDocMSF = UnoRuntime.queryInterface(XMultiServiceFactory.class, oDoc); try { oInstance = (Object) oDocMSF.createInstance(kind); @@ -489,13 +489,13 @@ public class SOfficeFactory { XControlModel aControl = null; //get MSF - XMultiServiceFactory oDocMSF = (XMultiServiceFactory) UnoRuntime.queryInterface(XMultiServiceFactory.class, oDoc); + XMultiServiceFactory oDocMSF = UnoRuntime.queryInterface(XMultiServiceFactory.class, oDoc); try { Object oInt = oDocMSF.createInstance("com.sun.star.drawing.ControlShape"); Object aCon = oDocMSF.createInstance("com.sun.star.form.component." + kind); - aControl = (XControlModel) UnoRuntime.queryInterface(XControlModel.class, aCon); - oCShape = (XControlShape) UnoRuntime.queryInterface(XControlShape.class, oInt); + aControl = UnoRuntime.queryInterface(XControlModel.class, aCon); + oCShape = UnoRuntime.queryInterface(XControlShape.class, oInt); size.Height = height; size.Width = width; position.X = x; |