diff options
Diffstat (limited to 'odk/examples/java/Text/StyleCreation.java')
-rw-r--r-- | odk/examples/java/Text/StyleCreation.java | 34 |
1 files changed, 16 insertions, 18 deletions
diff --git a/odk/examples/java/Text/StyleCreation.java b/odk/examples/java/Text/StyleCreation.java index 91cfb3f7a8c6..f32b6672dfae 100644 --- a/odk/examples/java/Text/StyleCreation.java +++ b/odk/examples/java/Text/StyleCreation.java @@ -60,8 +60,8 @@ public class StyleCreation { // the service '..ParagraphStyle' is context dependend, you need // the multi service factory from the document to use the service com.sun.star.lang.XMultiServiceFactory xDocMSF = - (com.sun.star.lang.XMultiServiceFactory)UnoRuntime.queryInterface( - com.sun.star.lang.XMultiServiceFactory.class, xTextDocument); + UnoRuntime.queryInterface( + com.sun.star.lang.XMultiServiceFactory.class, xTextDocument); // use the service 'com.sun.star.style.ParagraphStyle' com.sun.star.uno.XInterface xInterface = (com.sun.star.uno.XInterface) @@ -69,8 +69,8 @@ public class StyleCreation { // create a supplier to get the Style family collection com.sun.star.style.XStyleFamiliesSupplier xSupplier = - (com.sun.star.style.XStyleFamiliesSupplier)UnoRuntime.queryInterface( - com.sun.star.style.XStyleFamiliesSupplier.class, xTextDocument ); + UnoRuntime.queryInterface( + com.sun.star.style.XStyleFamiliesSupplier.class, xTextDocument ); // get the NameAccess interface from the Style family collection com.sun.star.container.XNameAccess xNameAccess = @@ -78,14 +78,14 @@ public class StyleCreation { // select the Paragraph styles, you get the Paragraph style collection com.sun.star.container.XNameContainer xParaStyleCollection = - (com.sun.star.container.XNameContainer) UnoRuntime.queryInterface( - com.sun.star.container.XNameContainer.class, - xNameAccess.getByName("ParagraphStyles")); + UnoRuntime.queryInterface( + com.sun.star.container.XNameContainer.class, + xNameAccess.getByName("ParagraphStyles")); // create a PropertySet to set the properties for the new Paragraphstyle com.sun.star.beans.XPropertySet xPropertySet = - (com.sun.star.beans.XPropertySet) UnoRuntime.queryInterface( - com.sun.star.beans.XPropertySet.class, xInterface ); + UnoRuntime.queryInterface( + com.sun.star.beans.XPropertySet.class, xInterface ); System.out.println( "create a PropertySet to set the properties for the new Paragraphstyle" ); // set some properties from the Paragraph style @@ -122,8 +122,8 @@ public class StyleCreation { // get the PropertySet from the current paragraph com.sun.star.beans.XPropertySet xParagraphPropertySet = - (com.sun.star.beans.XPropertySet)UnoRuntime.queryInterface( - com.sun.star.beans.XPropertySet.class, xTextRange ); + UnoRuntime.queryInterface( + com.sun.star.beans.XPropertySet.class, xTextRange ); // change the value from the property 'ParaStyle' to apply the // Paragraph style // To run the sample with StarOffice 5.2 you'll have to change @@ -160,7 +160,7 @@ public class StyleCreation { Object oDesktop = xMCF.createInstanceWithContext( "com.sun.star.frame.Desktop", xContext); - xDesktop = (com.sun.star.frame.XDesktop) UnoRuntime.queryInterface( + xDesktop = UnoRuntime.queryInterface( com.sun.star.frame.XDesktop.class, oDesktop); } else @@ -183,9 +183,8 @@ public class StyleCreation { try { com.sun.star.lang.XComponent xComponent = CreateNewDocument(xDesktop, "swriter"); - aTextDocument = (com.sun.star.text.XTextDocument) - UnoRuntime.queryInterface( - com.sun.star.text.XTextDocument.class, xComponent); + aTextDocument = UnoRuntime.queryInterface( + com.sun.star.text.XTextDocument.class, xComponent); } catch( Exception e) { e.printStackTrace(System.err); @@ -209,9 +208,8 @@ public class StyleCreation { new com.sun.star.beans.PropertyValue[0]; try { - xComponentLoader = (com.sun.star.frame.XComponentLoader) - UnoRuntime.queryInterface( - com.sun.star.frame.XComponentLoader.class, xDesktop); + xComponentLoader = UnoRuntime.queryInterface( + com.sun.star.frame.XComponentLoader.class, xDesktop); xComponent = xComponentLoader.loadComponentFromURL( sURL, "_blank", 0, xEmptyArgs); |