diff options
Diffstat (limited to 'swext/mediawiki/src/com/sun/star/wiki/Helper.java')
-rw-r--r-- | swext/mediawiki/src/com/sun/star/wiki/Helper.java | 62 |
1 files changed, 28 insertions, 34 deletions
diff --git a/swext/mediawiki/src/com/sun/star/wiki/Helper.java b/swext/mediawiki/src/com/sun/star/wiki/Helper.java index 9601579aa798..345be2c785ab 100644 --- a/swext/mediawiki/src/com/sun/star/wiki/Helper.java +++ b/swext/mediawiki/src/com/sun/star/wiki/Helper.java @@ -55,8 +55,6 @@ import com.sun.star.uno.XComponentContext; import com.sun.star.util.XChangesBatch; import java.net.*; import java.io.*; -import java.util.Hashtable; -import java.util.Random; import javax.net.ssl.SSLException; import javax.swing.text.html.HTMLEditorKit; @@ -149,11 +147,9 @@ public class Helper private static final String sHTMLHeader = "<HTML><HEAD><meta http-equiv=\"Content-Type\" content=\"text/html; charset=utf-8\" /><TITLE></TITLE></HEAD><BODY>"; private static final String sHTMLFooter = "</BODY></HTML>"; - private static Random m_aRandom; private static MultiThreadedHttpConnectionManager m_aConnectionManager; private static HttpClient m_aClient; private static boolean m_bAllowConnection = true; - private static Hashtable m_aAcceptedUnknownCerts; private static Boolean m_bShowInBrowser = null; @@ -245,7 +241,7 @@ public class Helper XPropertySet xProps = Helper.GetConfigProps( xContext, "org.openoffice.Office.Custom.WikiExtension/Settings" ); xProps.setPropertyValue( "PreselectShowBrowser", new Boolean( bValue ) ); - XChangesBatch xBatch = ( XChangesBatch ) UnoRuntime.queryInterface( XChangesBatch.class, xProps ); + XChangesBatch xBatch = UnoRuntime.queryInterface( XChangesBatch.class, xProps ); if ( xBatch != null ) xBatch.commitChanges(); } @@ -262,7 +258,7 @@ public class Helper { XMultiComponentFactory xFactory = xContext.getServiceManager(); if ( xFactory != null ) - m_xPasswordContainer = (XPasswordContainer)UnoRuntime.queryInterface( + m_xPasswordContainer = UnoRuntime.queryInterface( XPasswordContainer.class, xFactory.createInstanceWithContext( "com.sun.star.task.PasswordContainer", xContext ) ); } @@ -280,7 +276,7 @@ public class Helper { XMultiComponentFactory xFactory = xContext.getServiceManager(); if ( xFactory != null ) - m_xInteractionHandler = ( XInteractionHandler )UnoRuntime.queryInterface( + m_xInteractionHandler = UnoRuntime.queryInterface( XInteractionHandler.class, xFactory.createInstanceWithContext( "com.sun.star.task.InteractionHandler", xContext ) ); } @@ -384,8 +380,8 @@ public class Helper try { Object oTempFile = xContext.getServiceManager().createInstanceWithContext( "com.sun.star.io.TempFile", xContext ); - XStream xStream = ( XStream ) UnoRuntime.queryInterface( XStream.class, oTempFile ); - XSeekable xSeekable = ( XSeekable ) UnoRuntime.queryInterface( XSeekable.class, oTempFile ); + XStream xStream = UnoRuntime.queryInterface( XStream.class, oTempFile ); + XSeekable xSeekable = UnoRuntime.queryInterface( XSeekable.class, oTempFile ); if ( xStream != null && xSeekable != null ) { XOutputStream xOutputStream = xStream.getOutputStream(); @@ -418,13 +414,13 @@ public class Helper try { Object oTempFile = xContext.getServiceManager().createInstanceWithContext( "com.sun.star.io.TempFile", xContext ); - XPropertySet xPropertySet = ( XPropertySet ) UnoRuntime.queryInterface( XPropertySet.class, oTempFile ); + XPropertySet xPropertySet = UnoRuntime.queryInterface( XPropertySet.class, oTempFile ); xPropertySet.setPropertyValue( "RemoveFile", Boolean.FALSE ); sURL = ( String ) xPropertySet.getPropertyValue( "Uri" ); - XInputStream xInputStream = ( XInputStream ) UnoRuntime.queryInterface( XInputStream.class, oTempFile ); + XInputStream xInputStream = UnoRuntime.queryInterface( XInputStream.class, oTempFile ); xInputStream.closeInput(); - XOutputStream xOutputStream = ( XOutputStream ) UnoRuntime.queryInterface( XOutputStream.class, oTempFile ); + XOutputStream xOutputStream = UnoRuntime.queryInterface( XOutputStream.class, oTempFile ); xOutputStream.closeOutput(); } catch ( com.sun.star.uno.Exception ex ) { @@ -454,6 +450,8 @@ public class Helper sEachLine = aBufReader.readLine(); } sText = aBuf.toString(); + + aBufReader.close(); } catch ( Exception e ) { e.printStackTrace(); @@ -489,7 +487,7 @@ public class Helper throw new com.sun.star.uno.RuntimeException(); Object oModuleManager = xFactory.createInstanceWithContext( "com.sun.star.frame.ModuleManager", xContext ); - XModuleManager xModuleManager = ( XModuleManager ) UnoRuntime.queryInterface( XModuleManager.class, oModuleManager ); + XModuleManager xModuleManager = UnoRuntime.queryInterface( XModuleManager.class, oModuleManager ); if ( xModuleManager != null ) aDocServiceName = xModuleManager.identify( xModel ); } @@ -511,7 +509,7 @@ public class Helper try { Object oFilterFactory = xContext.getServiceManager().createInstanceWithContext( "com.sun.star.document.FilterFactory", xContext ); - XContainerQuery xQuery = ( XContainerQuery )UnoRuntime.queryInterface( XContainerQuery.class, oFilterFactory ); + XContainerQuery xQuery = UnoRuntime.queryInterface( XContainerQuery.class, oFilterFactory ); if ( xQuery != null ) { NamedValue[] aRequest = new NamedValue[2]; @@ -562,7 +560,7 @@ public class Helper { XMultiComponentFactory xFactory = xContext.getServiceManager(); Object oConfigProvider = xFactory.createInstanceWithContext( "com.sun.star.configuration.ConfigurationProvider", xContext ); - xConfigurationProvider = ( XMultiServiceFactory ) UnoRuntime.queryInterface( XMultiServiceFactory.class, oConfigProvider ); + xConfigurationProvider = UnoRuntime.queryInterface( XMultiServiceFactory.class, oConfigProvider ); } if ( xConfigurationProvider == null ) @@ -592,7 +590,7 @@ public class Helper protected static XPropertySet GetConfigProps( XComponentContext xContext, String sNodepath ) throws com.sun.star.uno.Exception { - XPropertySet xProps = ( XPropertySet ) UnoRuntime.queryInterface( XPropertySet.class, GetConfig( xContext, sNodepath, true ) ); + XPropertySet xProps = UnoRuntime.queryInterface( XPropertySet.class, GetConfig( xContext, sNodepath, true ) ); if ( xProps == null ) throw new com.sun.star.uno.RuntimeException(); @@ -603,7 +601,7 @@ public class Helper protected static XNameContainer GetConfigNameContainer( XComponentContext xContext, String sNodepath ) throws com.sun.star.uno.Exception { - XNameContainer xContainer = ( XNameContainer ) UnoRuntime.queryInterface( XNameContainer.class, GetConfig( xContext, sNodepath, true ) ); + XNameContainer xContainer = UnoRuntime.queryInterface( XNameContainer.class, GetConfig( xContext, sNodepath, true ) ); if ( xContainer == null ) throw new com.sun.star.uno.RuntimeException(); @@ -613,7 +611,7 @@ public class Helper protected static XNameAccess GetConfigNameAccess( XComponentContext xContext, String sNodepath ) throws com.sun.star.uno.Exception { - XNameAccess xNameAccess = ( XNameAccess ) UnoRuntime.queryInterface( XNameAccess.class, GetConfig( xContext, sNodepath, false ) ); + XNameAccess xNameAccess = UnoRuntime.queryInterface( XNameAccess.class, GetConfig( xContext, sNodepath, false ) ); if ( xNameAccess == null ) throw new com.sun.star.uno.RuntimeException(); @@ -679,7 +677,7 @@ public class Helper try { Object oSystemShell = xContext.getServiceManager().createInstanceWithContext( "com.sun.star.system.SystemShellExecute", xContext ); - XSystemShellExecute xSystemShell = (XSystemShellExecute)UnoRuntime.queryInterface( XSystemShellExecute.class, oSystemShell ); + XSystemShellExecute xSystemShell = UnoRuntime.queryInterface( XSystemShellExecute.class, oSystemShell ); if ( xSystemShell != null ) xSystemShell.execute( sURL, "", SystemShellExecuteFlags.URIS_ONLY ); } @@ -701,7 +699,6 @@ public class Helper SetConfigurationProxy( aHostConfig, xContext ); } - boolean bNoUnknownCertNotification = false; if ( aHostConfig.getProtocol().getScheme().equals( "https" ) && AllowUnknownCert( xContext, aURI.getHost() ) ) { @@ -855,12 +852,12 @@ public class Helper private static XControl GetControlFromDialog( XDialog xDialog, String aControlName ) { XControl xResult = null; - XControlContainer xControlCont = (XControlContainer) UnoRuntime.queryInterface( XControlContainer.class, xDialog ); + XControlContainer xControlCont = UnoRuntime.queryInterface( XControlContainer.class, xDialog ); if ( xControlCont != null ) { Object oControl = xControlCont.getControl( aControlName ); - xResult = ( XControl ) UnoRuntime.queryInterface( XControl.class, oControl ); + xResult = UnoRuntime.queryInterface( XControl.class, oControl ); } return xResult; @@ -870,7 +867,7 @@ public class Helper { XControl xControl = GetControlFromDialog( xDialog, aControlName ); if ( xControl != null ) - return ( XPropertySet ) UnoRuntime.queryInterface( XPropertySet.class, xControl.getModel() ); + return UnoRuntime.queryInterface( XPropertySet.class, xControl.getModel() ); return null; } @@ -919,7 +916,7 @@ public class Helper boolean bResult = false; try { - XMasterPasswordHandling xMasterHdl = (XMasterPasswordHandling)UnoRuntime.queryInterface( XMasterPasswordHandling.class, GetPasswordContainer( xContext ) ); + XMasterPasswordHandling xMasterHdl = UnoRuntime.queryInterface( XMasterPasswordHandling.class, GetPasswordContainer( xContext ) ); if ( xMasterHdl != null ) bResult = xMasterHdl.isPersistentStoringAllowed(); } @@ -934,7 +931,7 @@ public class Helper protected static void ShowError( XComponentContext xContext, XDialog xDialog, int nTitleID, int nErrorID, String sArg, boolean bQuery ) { XWindowPeer xPeer = null; - XControl xControl = (XControl)UnoRuntime.queryInterface( XControl.class, xDialog ); + XControl xControl = UnoRuntime.queryInterface( XControl.class, xDialog ); if ( xControl != null ) xPeer = xControl.getPeer(); ShowError( xContext, xPeer, nTitleID, nErrorID, sArg, bQuery ); @@ -946,8 +943,6 @@ public class Helper if ( xContext != null && nErrorID >= 0 && nErrorID < STRINGS_NUM ) { - boolean bShown = false; - String sError = null; String sTitle = ""; @@ -975,7 +970,7 @@ public class Helper { XMultiComponentFactory xFactory = xContext.getServiceManager(); if ( xFactory != null ) - xMBFactory = (XMessageBoxFactory)UnoRuntime.queryInterface( + xMBFactory = UnoRuntime.queryInterface( XMessageBoxFactory.class, xFactory.createInstanceWithContext( "com.sun.star.awt.Toolkit", xContext ) ); @@ -1004,7 +999,6 @@ public class Helper if ( xMB != null ) { bResult = MainThreadDialogExecutor.Execute( xContext, xMB ); - bShown = true; } } } @@ -1030,7 +1024,7 @@ public class Helper XNameAccess xNameAccess = GetConfigNameAccess( xContext, "org.openoffice.Office.Custom.WikiExtension/SpecialData" ); if ( xNameAccess.hasByName( aURL ) ) { - XNameAccess xEntry = (XNameAccess)UnoRuntime.queryInterface( XNameAccess.class, xNameAccess.getByName( aURL ) ); + XNameAccess xEntry = UnoRuntime.queryInterface( XNameAccess.class, xNameAccess.getByName( aURL ) ); if ( xEntry != null && xEntry.hasByName( "AllowUnknownCertificate" ) ) return AnyConverter.toBoolean( xEntry.getByName( "AllowUnknownCertificate" ) ); } @@ -1050,10 +1044,10 @@ public class Helper XNameAccess xNameAccess = GetConfigNameAccess( xContext, "org.openoffice.Office.Custom.WikiExtension/SpecialData" ); if ( xNameAccess.hasByName( aURL ) ) { - XNameAccess xEntry = (XNameAccess)UnoRuntime.queryInterface( XNameAccess.class, xNameAccess.getByName( aURL ) ); + XNameAccess xEntry = UnoRuntime.queryInterface( XNameAccess.class, xNameAccess.getByName( aURL ) ); if ( xEntry != null ) { - XNameAccess xArgs = (XNameAccess)UnoRuntime.queryInterface( XNameAccess.class, xEntry.getByName( "AdditionalLoginArguments" ) ); + XNameAccess xArgs = UnoRuntime.queryInterface( XNameAccess.class, xEntry.getByName( "AdditionalLoginArguments" ) ); if ( xArgs != null ) { String[] pNames = xArgs.getElementNames(); @@ -1062,7 +1056,7 @@ public class Helper String[][] pResult = new String[pNames.length][2]; for ( int nInd = 0; nInd < pNames.length; nInd++ ) { - XNameAccess xArgument = (XNameAccess)UnoRuntime.queryInterface( XNameAccess.class, xArgs.getByName( pNames[nInd] ) ); + XNameAccess xArgument = UnoRuntime.queryInterface( XNameAccess.class, xArgs.getByName( pNames[nInd] ) ); if ( xArgument == null ) throw new com.sun.star.uno.RuntimeException(); @@ -1112,7 +1106,7 @@ public class Helper { try { - XComponent xComp = (XComponent)UnoRuntime.queryInterface( XComponent.class, oObject ); + XComponent xComp = UnoRuntime.queryInterface( XComponent.class, oObject ); if ( xComp != null ) xComp.dispose(); } |