diff options
author | Noel Grandin <noel@peralex.com> | 2014-11-11 15:32:10 +0200 |
---|---|---|
committer | Noel Grandin <noelgrandin@gmail.com> | 2014-11-12 08:01:55 +0000 |
commit | 36ff1527c9cb20542d3097d123d221c40a356795 (patch) | |
tree | 52590ce642803a862bc331b3eae2e2b100b8e85f /swext | |
parent | 1eb31467a5af90fe41dc646dd716bdb7d3e5db45 (diff) |
java: reduce excessive code indentation levels
by using early return in some methods
Change-Id: I3611c8c89b3a94ef7e1772d178acf065fd7fcdc7
Reviewed-on: https://gerrit.libreoffice.org/12374
Reviewed-by: Noel Grandin <noelgrandin@gmail.com>
Tested-by: Noel Grandin <noelgrandin@gmail.com>
Diffstat (limited to 'swext')
3 files changed, 86 insertions, 86 deletions
diff --git a/swext/mediawiki/src/com/sun/star/wiki/Helper.java b/swext/mediawiki/src/com/sun/star/wiki/Helper.java index 9d58de7a3b90..6aad820af421 100644 --- a/swext/mediawiki/src/com/sun/star/wiki/Helper.java +++ b/swext/mediawiki/src/com/sun/star/wiki/Helper.java @@ -466,51 +466,51 @@ public class Helper protected static String GetFilterName( XComponentContext xContext, String aTypeName, String aDocServiceName ) { + if ( xContext == null || aTypeName == null || aTypeName.length() == 0 + || aDocServiceName == null || aDocServiceName.length() == 0 ) { + return ""; + } String aFilterName = ""; - if ( xContext != null && aTypeName != null && aTypeName.length() != 0 - && aDocServiceName != null && aDocServiceName.length() != 0 ) + try { - try + Object oFilterFactory = xContext.getServiceManager().createInstanceWithContext( "com.sun.star.document.FilterFactory", xContext ); + XContainerQuery xQuery = UnoRuntime.queryInterface( XContainerQuery.class, oFilterFactory ); + if ( xQuery != null ) { - Object oFilterFactory = xContext.getServiceManager().createInstanceWithContext( "com.sun.star.document.FilterFactory", xContext ); - XContainerQuery xQuery = UnoRuntime.queryInterface( XContainerQuery.class, oFilterFactory ); - if ( xQuery != null ) - { - NamedValue[] aRequest = new NamedValue[2]; - aRequest[0] = new NamedValue( "Type", aTypeName ); - aRequest[1] = new NamedValue( "DocumentService", aDocServiceName ); + NamedValue[] aRequest = new NamedValue[2]; + aRequest[0] = new NamedValue( "Type", aTypeName ); + aRequest[1] = new NamedValue( "DocumentService", aDocServiceName ); - XEnumeration xSet = xQuery.createSubSetEnumerationByProperties( aRequest ); - if ( xSet != null ) + XEnumeration xSet = xQuery.createSubSetEnumerationByProperties( aRequest ); + if ( xSet != null ) + { + boolean bAcceptable = false; + while ( xSet.hasMoreElements() && !bAcceptable ) { - boolean bAcceptable = false; - while ( xSet.hasMoreElements() && !bAcceptable ) + PropertyValue[] pFilterProps = ( PropertyValue[] )AnyConverter.toArray( xSet.nextElement() ); + if ( pFilterProps != null ) { - PropertyValue[] pFilterProps = ( PropertyValue[] )AnyConverter.toArray( xSet.nextElement() ); - if ( pFilterProps != null ) + int nLen = pFilterProps.length; + String aTmpFilter = null; + + for ( int nInd = 0; nInd < nLen; nInd++ ) { - int nLen = pFilterProps.length; - String aTmpFilter = null; - - for ( int nInd = 0; nInd < nLen; nInd++ ) - { - if ( pFilterProps[nInd].Name.equals( "Name" ) ) - aTmpFilter = AnyConverter.toString( pFilterProps[nInd].Value ); - else if ( pFilterProps[nInd].Name.equals( "Flags" ) ) - bAcceptable = ( ( AnyConverter.toInt( pFilterProps[nInd].Value ) & 2 ) == 2 ); // must allow export - } - - if ( bAcceptable ) - aFilterName = aTmpFilter; + if ( pFilterProps[nInd].Name.equals( "Name" ) ) + aTmpFilter = AnyConverter.toString( pFilterProps[nInd].Value ); + else if ( pFilterProps[nInd].Name.equals( "Flags" ) ) + bAcceptable = ( ( AnyConverter.toInt( pFilterProps[nInd].Value ) & 2 ) == 2 ); // must allow export } + + if ( bAcceptable ) + aFilterName = aTmpFilter; } } } } - catch( java.lang.Exception e ) - { - e.printStackTrace(); - } + } + catch( java.lang.Exception e ) + { + e.printStackTrace(); } return aFilterName; diff --git a/swext/mediawiki/src/com/sun/star/wiki/WikiDialog.java b/swext/mediawiki/src/com/sun/star/wiki/WikiDialog.java index 699a682b5eed..55893cf88e53 100644 --- a/swext/mediawiki/src/com/sun/star/wiki/WikiDialog.java +++ b/swext/mediawiki/src/com/sun/star/wiki/WikiDialog.java @@ -125,15 +125,15 @@ public class WikiDialog implements XDialogEventHandler, XTopWindowListener private static void SetTitle( XDialog xDialog, String sTitle ) throws Exception { - if ( xDialog != null && sTitle != null ) + if ( xDialog == null || sTitle == null ) { + return; + } + XControl xDialogControl = UnoRuntime.queryInterface( XControl.class, xDialog ); + if ( xDialogControl != null ) { - XControl xDialogControl = UnoRuntime.queryInterface( XControl.class, xDialog ); - if ( xDialogControl != null ) - { - XPropertySet xPropSet = UnoRuntime.queryInterface( XPropertySet.class, xDialogControl.getModel() ); - if ( xPropSet != null ) - xPropSet.setPropertyValue( "Title", sTitle ); - } + XPropertySet xPropSet = UnoRuntime.queryInterface( XPropertySet.class, xDialogControl.getModel() ); + if ( xPropSet != null ) + xPropSet.setPropertyValue( "Title", sTitle ); } } diff --git a/swext/mediawiki/src/com/sun/star/wiki/WikiProtocolSocketFactory.java b/swext/mediawiki/src/com/sun/star/wiki/WikiProtocolSocketFactory.java index 196df54fd112..b6da4a5a630c 100644 --- a/swext/mediawiki/src/com/sun/star/wiki/WikiProtocolSocketFactory.java +++ b/swext/mediawiki/src/com/sun/star/wiki/WikiProtocolSocketFactory.java @@ -41,68 +41,68 @@ class WikiProtocolSocketFactory implements SecureProtocolSocketFactory private synchronized SSLContext GetNotSoSecureSSLContext() { - if ( m_aSSLContext == null ) + if ( m_aSSLContext != null ) { + return m_aSSLContext; + } + TrustManager[] pTrustUnknownCerts = new TrustManager[] { - TrustManager[] pTrustUnknownCerts = new TrustManager[] - { - new X509TrustManager() { - private X509TrustManager m_aOrgTrustManager; + new X509TrustManager() { + private X509TrustManager m_aOrgTrustManager; - private X509TrustManager GetOrgTrustManager() + private X509TrustManager GetOrgTrustManager() + { + if ( m_aOrgTrustManager == null ) { - if ( m_aOrgTrustManager == null ) + try { - try - { - TrustManagerFactory aFactory = TrustManagerFactory.getInstance( TrustManagerFactory.getDefaultAlgorithm() ); - aFactory.init( (KeyStore)null ); - TrustManager[] pTrustmanagers = aFactory.getTrustManagers(); - if ( pTrustmanagers.length != 0 && pTrustmanagers[0] != null ) - m_aOrgTrustManager = (X509TrustManager)pTrustmanagers[0]; - } - catch( Exception e ) - { - throw new RuntimeException( "No access to the default trust manager!", e ); - } + TrustManagerFactory aFactory = TrustManagerFactory.getInstance( TrustManagerFactory.getDefaultAlgorithm() ); + aFactory.init( (KeyStore)null ); + TrustManager[] pTrustmanagers = aFactory.getTrustManagers(); + if ( pTrustmanagers.length != 0 && pTrustmanagers[0] != null ) + m_aOrgTrustManager = (X509TrustManager)pTrustmanagers[0]; + } + catch( Exception e ) + { + throw new RuntimeException( "No access to the default trust manager!", e ); } - - return m_aOrgTrustManager; } - public X509Certificate[] getAcceptedIssuers() - { - return GetOrgTrustManager().getAcceptedIssuers(); - } + return m_aOrgTrustManager; + } - public void checkClientTrusted(X509Certificate[] certs, String authType) throws CertificateException - { - GetOrgTrustManager().checkClientTrusted( certs, authType ); - } + public X509Certificate[] getAcceptedIssuers() + { + return GetOrgTrustManager().getAcceptedIssuers(); + } - public void checkServerTrusted(X509Certificate[] certs, String authType) throws CertificateException - { - if ( certs == null || certs.length == 0 ) - GetOrgTrustManager().checkServerTrusted( certs, authType ); - else - for ( int nInd = 0; nInd < certs.length; nInd++ ) - certs[nInd].checkValidity(); - } + public void checkClientTrusted(X509Certificate[] certs, String authType) throws CertificateException + { + GetOrgTrustManager().checkClientTrusted( certs, authType ); } - }; - try - { - SSLContext aContext = SSLContext.getInstance("SSL"); - if ( aContext != null ) + public void checkServerTrusted(X509Certificate[] certs, String authType) throws CertificateException { - aContext.init( null, pTrustUnknownCerts, null ); - m_aSSLContext = aContext; + if ( certs == null || certs.length == 0 ) + GetOrgTrustManager().checkServerTrusted( certs, authType ); + else + for ( int nInd = 0; nInd < certs.length; nInd++ ) + certs[nInd].checkValidity(); } } - catch ( Exception e ) + }; + + try + { + SSLContext aContext = SSLContext.getInstance("SSL"); + if ( aContext != null ) { + aContext.init( null, pTrustUnknownCerts, null ); + m_aSSLContext = aContext; } } + catch ( Exception e ) + { + } if ( m_aSSLContext == null ) throw new HttpClientError(); |