diff options
author | Noel Grandin <noel@peralex.com> | 2015-11-05 14:16:35 +0200 |
---|---|---|
committer | Noel Grandin <noel@peralex.com> | 2015-11-05 14:55:15 +0200 |
commit | b73db446ac9681fdfc4ad602c6da7ce3e36a8588 (patch) | |
tree | 6107f4347c188f4c14840c01167b2f05b2f5ad48 | |
parent | dfcb982ae8810e22204bc15fd7c119a903900a53 (diff) |
java: combine nested if statements
Change-Id: I0457b81668e9427a3c8d6a4af93438b7fb2bb7ba
34 files changed, 225 insertions, 332 deletions
diff --git a/javaunohelper/com/sun/star/lib/uno/helper/InterfaceContainer.java b/javaunohelper/com/sun/star/lib/uno/helper/InterfaceContainer.java index a61edc06acc8..e0fa1456e817 100644 --- a/javaunohelper/com/sun/star/lib/uno/helper/InterfaceContainer.java +++ b/javaunohelper/com/sun/star/lib/uno/helper/InterfaceContainer.java @@ -569,13 +569,10 @@ public class InterfaceContainer implements Cloneable while (itColl.hasNext()) { Object o= itColl.next(); - if (o != null) + if (o != null && UnoRuntime.areSame(o, curElem)) { - if (UnoRuntime.areSame(o, curElem)) - { - bExists= true; - break; - } + bExists= true; + break; } } } diff --git a/javaunohelper/test/com/sun/star/comp/helper/SharedLibraryLoader_Test.java b/javaunohelper/test/com/sun/star/comp/helper/SharedLibraryLoader_Test.java index 550a497018dc..b9c67e68be74 100644 --- a/javaunohelper/test/com/sun/star/comp/helper/SharedLibraryLoader_Test.java +++ b/javaunohelper/test/com/sun/star/comp/helper/SharedLibraryLoader_Test.java @@ -61,9 +61,8 @@ public class SharedLibraryLoader_Test { sharedLibraryLoader = null; System.out.println("*******************************************************************"); System.out.println("Test: <<< instantiate SharedLibraryLoader >>>"); - if ( sharedLibraryLoaderFactory == null ) - if ( ! test_getSharedLibraryLoaderFactory() ) - return false; + if ( sharedLibraryLoaderFactory == null && ! test_getSharedLibraryLoaderFactory() ) + return false; sharedLibraryLoader = UnoRuntime.queryInterface( XImplementationLoader.class, sharedLibraryLoaderFactory.createInstance() ); @@ -83,9 +82,8 @@ public class SharedLibraryLoader_Test { System.out.println("*******************************************************************"); System.out.println("Test: <<< load native ServiceManager >>>"); - if ( sharedLibraryLoader == null ) - if ( ! test_instantiateSharedLibraryLoader() ) - return false; + if ( sharedLibraryLoader == null && ! test_instantiateSharedLibraryLoader() ) + return false; System.err.println("- get the native ServiceManger factory"); XSingleServiceFactory aSMgrFac = @@ -108,9 +106,8 @@ public class SharedLibraryLoader_Test { { System.out.println("*******************************************************************"); System.out.println("Test: <<< load native SimpleRegistry >>>"); - if ( sharedLibraryLoader == null ) - if ( ! test_instantiateSharedLibraryLoader() ) - return false; + if ( sharedLibraryLoader == null && ! test_instantiateSharedLibraryLoader() ) + return false; System.err.println("- get factory of the Registry"); XSingleServiceFactory aRegFac = @@ -134,9 +131,8 @@ public class SharedLibraryLoader_Test { System.out.println("*******************************************************************"); System.out.println("Test: <<< register SharedLibraryLoader at the Registry >>>"); - if ( simpleRegistry == null ) - if ( ! test_loadNativeSimpleRegistry() ) - return false; + if ( simpleRegistry == null && ! test_loadNativeSimpleRegistry() ) + return false; com.sun.star.registry.XRegistryKey regKey = simpleRegistry.getRootKey(); result = SharedLibraryLoader.writeRegistryServiceInfo( null, regKey ); diff --git a/jurt/com/sun/star/comp/bridgefactory/BridgeFactory.java b/jurt/com/sun/star/comp/bridgefactory/BridgeFactory.java index a43cb094cf0d..614631711b84 100644 --- a/jurt/com/sun/star/comp/bridgefactory/BridgeFactory.java +++ b/jurt/com/sun/star/comp/bridgefactory/BridgeFactory.java @@ -109,9 +109,8 @@ public class BridgeFactory implements XBridgeFactory/*, XEventListener*/ { for(int i = 0; i < iBridges.length; ++ i) { XBridge xBridge = UnoRuntime.queryInterface(XBridge.class, iBridges[i]); - if(xBridge != null) { - if(xBridge.getName().equals(sName)) - throw new BridgeExistsException(sName + " already exists"); + if(xBridge != null && xBridge.getName().equals(sName)) { + throw new BridgeExistsException(sName + " already exists"); } } } diff --git a/jvmfwk/plugins/sunmajor/pluginlib/JREProperties.java b/jvmfwk/plugins/sunmajor/pluginlib/JREProperties.java index c20e02ab6709..dfb27e941b8b 100644 --- a/jvmfwk/plugins/sunmajor/pluginlib/JREProperties.java +++ b/jvmfwk/plugins/sunmajor/pluginlib/JREProperties.java @@ -36,10 +36,8 @@ public class JREProperties try { boolean bNoAccess = false; - if(args.length > 0) - { - if (args[0].equals("noaccessibility")) - bNoAccess = true; + if(args.length > 0 && args[0].equals("noaccessibility")) { + bNoAccess = true; } //We need to be able to switch this part off because diff --git a/qadevOOo/runner/helper/ProcessHandler.java b/qadevOOo/runner/helper/ProcessHandler.java index 999a0097fd8e..607c1f21a2c2 100644 --- a/qadevOOo/runner/helper/ProcessHandler.java +++ b/qadevOOo/runner/helper/ProcessHandler.java @@ -509,14 +509,11 @@ public class ProcessHandler } } - if (bKillProcessAfterTimeout) + if (bKillProcessAfterTimeout && !isFinished) { - if (!isFinished) - { - log.println("Going to destroy the process!!"); - m_aProcess.destroy(); - log.println("Process has been destroyed!"); - } + log.println("Going to destroy the process!!"); + m_aProcess.destroy(); + log.println("Process has been destroyed!"); } return isFinished(); diff --git a/qadevOOo/tests/java/ifc/beans/_XTolerantMultiPropertySet.java b/qadevOOo/tests/java/ifc/beans/_XTolerantMultiPropertySet.java index 8b5bb5c0b4c8..3f08e3e6a9a8 100644 --- a/qadevOOo/tests/java/ifc/beans/_XTolerantMultiPropertySet.java +++ b/qadevOOo/tests/java/ifc/beans/_XTolerantMultiPropertySet.java @@ -237,9 +237,8 @@ public class _XTolerantMultiPropertySet extends MultiMethodTest { try { PropertyState state = pState.getPropertyState(pName); - if (state.equals(PropertyState.DIRECT_VALUE)) { - if (isUsable(pName)) direct.add(pName); - } + if (state.equals(PropertyState.DIRECT_VALUE) && isUsable(pName)) + direct.add(pName); } catch (com.sun.star.beans.UnknownPropertyException e) { log.println("Property '" + pName + "'"); } diff --git a/qadevOOo/tests/java/ifc/view/_XMultiSelectionSupplier.java b/qadevOOo/tests/java/ifc/view/_XMultiSelectionSupplier.java index afc10f138b85..ebd7226c0415 100644 --- a/qadevOOo/tests/java/ifc/view/_XMultiSelectionSupplier.java +++ b/qadevOOo/tests/java/ifc/view/_XMultiSelectionSupplier.java @@ -326,12 +326,10 @@ public class _XMultiSelectionSupplier extends MultiMethodTest { log.println("nextElement()-object and expected object 'selections["+i+"]' are equal: "+compRes); - if (!compRes) { - if ((selections[i]) instanceof Object[]){ - if (((Object[])selections[i])[0] instanceof Integer) { - log.println("Getting: "+((Integer) ((Object[])shouldElement)[0]).intValue()); - log.println("Expected: "+((Integer) ((Object[])selections[i])[0]).intValue()); - } + if (!compRes && (selections[i]) instanceof Object[]) { + if (((Object[])selections[i])[0] instanceof Integer) { + log.println("Getting: "+((Integer) ((Object[])shouldElement)[0]).intValue()); + log.println("Expected: "+((Integer) ((Object[])selections[i])[0]).intValue()); } } bOK &= compRes; @@ -399,12 +397,10 @@ public class _XMultiSelectionSupplier extends MultiMethodTest { log.println("nextElement()-object and expected object 'selections["+i+"]' are equal: "+compRes); - if (!compRes) { - if ((selections[i]) instanceof Object[]){ - if (((Object[])selections[i])[0] instanceof Integer) { - log.println("Getting: "+((Integer) ((Object[])shouldElement)[0]).intValue()); - log.println("Expected: "+((Integer) ((Object[])selections[i])[0]).intValue()); - } + if (!compRes && (selections[i]) instanceof Object[]){ + if (((Object[])selections[i])[0] instanceof Integer) { + log.println("Getting: "+((Integer) ((Object[])shouldElement)[0]).intValue()); + log.println("Expected: "+((Integer) ((Object[])selections[i])[0]).intValue()); } } bOK &= compRes; diff --git a/qadevOOo/tests/java/ifc/view/_XSelectionSupplier.java b/qadevOOo/tests/java/ifc/view/_XSelectionSupplier.java index d601f1f2251b..c0059c718758 100644 --- a/qadevOOo/tests/java/ifc/view/_XSelectionSupplier.java +++ b/qadevOOo/tests/java/ifc/view/_XSelectionSupplier.java @@ -128,12 +128,10 @@ public class _XSelectionSupplier extends MultiMethodTest { compRes = util.ValueComparer.equalValue(selections[i], curSelection); } log.println("selected object and current selection are equal: "+compRes); - if (!compRes) { - if ((selections[i]) instanceof Object[]){ - if (((Object[])selections[i])[0] instanceof Integer) { - log.println("Getting: "+((Integer) ((Object[])curSelection)[0]).intValue()); - log.println("Expected: "+((Integer) ((Object[])selections[i])[0]).intValue()); - } + if (!compRes && (selections[i]) instanceof Object[]){ + if (((Object[])selections[i])[0] instanceof Integer) { + log.println("Getting: "+((Integer) ((Object[])curSelection)[0]).intValue()); + log.println("Expected: "+((Integer) ((Object[])selections[i])[0]).intValue()); } } res &= compRes; diff --git a/scripting/java/com/sun/star/script/framework/container/ParcelDescriptor.java b/scripting/java/com/sun/star/script/framework/container/ParcelDescriptor.java index f92662e10f1a..f58a9d88d838 100644 --- a/scripting/java/com/sun/star/script/framework/container/ParcelDescriptor.java +++ b/scripting/java/com/sun/star/script/framework/container/ParcelDescriptor.java @@ -114,11 +114,9 @@ public class ParcelDescriptor { } public String getLanguage() { - if (language == null) { - if (document != null) { - Element e = document.getDocumentElement(); - language = e.getAttribute("language"); - } + if (language == null && document != null) { + Element e = document.getDocumentElement(); + language = e.getAttribute("language"); } return language; diff --git a/scripting/java/com/sun/star/script/framework/container/UnoPkgContainer.java b/scripting/java/com/sun/star/script/framework/container/UnoPkgContainer.java index dfbac7c8d2e1..bf4f29a3a896 100644 --- a/scripting/java/com/sun/star/script/framework/container/UnoPkgContainer.java +++ b/scripting/java/com/sun/star/script/framework/container/UnoPkgContainer.java @@ -98,25 +98,23 @@ public class UnoPkgContainer extends ParcelContainer { try { DeployedUnoPackagesDB db = getUnoPackagesDB(); - if (db != null) { - if (db.removePackage(language, url)) { - writeUnoPackageDB(db); - ParcelContainer container = registeredPackages.get(url); - - if (!container.hasElements()) { - // When all libraries within a package bundle - // ( for this language ) are removed also - // remove the container from its parent - // Otherwise, a container ( with no containees ) - // representing the uno package bundle will - // still exist and so will get displayed - if (container.parent() != null) { - container.parent().removeChildContainer(container); - } + if (db != null && db.removePackage(language, url)) { + writeUnoPackageDB(db); + ParcelContainer container = registeredPackages.get(url); + + if (!container.hasElements()) { + // When all libraries within a package bundle + // ( for this language ) are removed also + // remove the container from its parent + // Otherwise, a container ( with no containees ) + // representing the uno package bundle will + // still exist and so will get displayed + if (container.parent() != null) { + container.parent().removeChildContainer(container); } - - registeredPackages.remove(url); } + + registeredPackages.remove(url); } } catch (Exception e) { //TODO revisit exception handling and exception here diff --git a/scripting/java/com/sun/star/script/framework/io/UCBStreamHandler.java b/scripting/java/com/sun/star/script/framework/io/UCBStreamHandler.java index 4e2059b2f5c5..6413745d3617 100644 --- a/scripting/java/com/sun/star/script/framework/io/UCBStreamHandler.java +++ b/scripting/java/com/sun/star/script/framework/io/UCBStreamHandler.java @@ -235,10 +235,8 @@ public class UCBStreamHandler extends URLStreamHandler { // TODO don't depend on result of available() or size() // just read stream 'till complete - if (sz == 0) { - if (xInputStream.available() > 0) { - sz = xInputStream.available(); - } + if (sz == 0 && xInputStream.available() > 0) { + sz = xInputStream.available(); } LogUtils.DEBUG("size of file " + path + " is " + sz); diff --git a/swext/mediawiki/src/com/sun/star/wiki/EditPageParser.java b/swext/mediawiki/src/com/sun/star/wiki/EditPageParser.java index f583447f885f..4ef08950c11b 100644 --- a/swext/mediawiki/src/com/sun/star/wiki/EditPageParser.java +++ b/swext/mediawiki/src/com/sun/star/wiki/EditPageParser.java @@ -130,24 +130,18 @@ public class EditPageParser extends HTMLEditorKit.ParserCallback else if ( t == HTML.Tag.TEXTAREA ) { String sName = ( String ) a.getAttribute( HTML.Attribute.NAME ); - if ( sName != null ) + if ( sName != null && sName.equalsIgnoreCase( "wpTextbox1" ) ) { - if ( sName.equalsIgnoreCase( "wpTextbox1" ) ) - { - m_nWikiArticleStart = pos; - } + m_nWikiArticleStart = pos; } } else if ( t == HTML.Tag.DIV ) { String sId = ( String ) a.getAttribute( HTML.Attribute.ID ); sClass = ( String ) a.getAttribute( HTML.Attribute.CLASS ); - if ( sId != null ) + if ( sId != null && sId.equalsIgnoreCase( "contentSub" ) ) { - if ( sId.equalsIgnoreCase( "contentSub" ) ) - { - m_bHTMLStartFound = true; - } + m_bHTMLStartFound = true; } if ( sClass != null ) { diff --git a/toolkit/test/accessibility/AccessibilityTree.java b/toolkit/test/accessibility/AccessibilityTree.java index d750bf75c811..fdf44177a783 100644 --- a/toolkit/test/accessibility/AccessibilityTree.java +++ b/toolkit/test/accessibility/AccessibilityTree.java @@ -365,9 +365,8 @@ public class AccessibilityTree { AccTreeNode aNode = (AccTreeNode)aObject; XAccessibleContext xContext = aNode.getContext(); - if (xContext != null) - if (xContext.getAccessibleRole() >= 100) - return true; + if (xContext != null && xContext.getAccessibleRole() >= 100) + return true; } return false; } diff --git a/toolkit/test/accessibility/AccessibleComponentHandler.java b/toolkit/test/accessibility/AccessibleComponentHandler.java index 7420a00daf51..229612b8dd11 100644 --- a/toolkit/test/accessibility/AccessibleComponentHandler.java +++ b/toolkit/test/accessibility/AccessibleComponentHandler.java @@ -115,8 +115,7 @@ class AccessibleComponentHandler public void update (AccessibleTreeNode aNode) { maChildList.clear(); - if (aNode instanceof AccTreeNode) - if (((AccTreeNode)aNode).getComponent() != null) - maChildList.setSize (4); + if (aNode instanceof AccTreeNode && ((AccTreeNode)aNode).getComponent() != null) + maChildList.setSize (4); } } diff --git a/toolkit/test/accessibility/Canvas.java b/toolkit/test/accessibility/Canvas.java index c254ed62c5e8..e9149ff82e35 100644 --- a/toolkit/test/accessibility/Canvas.java +++ b/toolkit/test/accessibility/Canvas.java @@ -395,12 +395,11 @@ class Canvas for (int i=nCount-1; i>=0; --i) { CanvasShape aObject = maObjectList.get(i); - if (aObject != null) - if (aObject.contains (e.getX(),e.getY())) - { - aObjectUnderMouse = aObject; - break; - } + if (aObject != null && aObject.contains (e.getX(),e.getY())) + { + aObjectUnderMouse = aObject; + break; + } } return aObjectUnderMouse; } diff --git a/unotools/qa/complex/tempfile/TestHelper.java b/unotools/qa/complex/tempfile/TestHelper.java index d3d82392e787..237c95b9ef11 100644 --- a/unotools/qa/complex/tempfile/TestHelper.java +++ b/unotools/qa/complex/tempfile/TestHelper.java @@ -164,11 +164,9 @@ public class TestHelper { public void KillTempFile ( String sTempFileURL, XSimpleFileAccess xSFA ) { try { - if ( sTempFileURL != null ) { - if ( xSFA != null ) { - xSFA.kill( sTempFileURL ); - Message ( "Tempfile killed successfully." ); - } + if ( sTempFileURL != null && xSFA != null ) { + xSFA.kill( sTempFileURL ); + Message ( "Tempfile killed successfully." ); } } catch ( Exception e ) { @@ -180,11 +178,9 @@ public class TestHelper { public boolean IfTempFileExists( XSimpleFileAccess xSFA, String sTempFileURL ) { boolean bRet = false; try { - if ( sTempFileURL != null ) { - if ( xSFA != null ) { - bRet = xSFA.exists( sTempFileURL ); - Message ( "Tempfile " + ( bRet ? "still " : "no longer " ) + "exists." ); - } + if ( sTempFileURL != null && xSFA != null ) { + bRet = xSFA.exists( sTempFileURL ); + Message ( "Tempfile " + ( bRet ? "still " : "no longer " ) + "exists." ); } } catch( Exception e ) { diff --git a/wizards/com/sun/star/wizards/common/JavaTools.java b/wizards/com/sun/star/wizards/common/JavaTools.java index cfeb1427cac7..65bb3f644840 100644 --- a/wizards/com/sun/star/wizards/common/JavaTools.java +++ b/wizards/com/sun/star/wizards/common/JavaTools.java @@ -126,11 +126,9 @@ public class JavaTools int FieldLen = SearchList.length; if (FieldLen > 0) { for (int i = 0; i < FieldLen; i++) { - if (SearchList[i][0] != null) { - if (SearchList[i][0].equals(SearchString)) { - retvalue = i; - break; - } + if (SearchList[i][0] != null && SearchList[i][0].equals(SearchString)) { + retvalue = i; + break; } } } diff --git a/wizards/com/sun/star/wizards/common/Properties.java b/wizards/com/sun/star/wizards/common/Properties.java index 764703c74ac2..2056921d36c6 100644 --- a/wizards/com/sun/star/wizards/common/Properties.java +++ b/wizards/com/sun/star/wizards/common/Properties.java @@ -72,15 +72,12 @@ public class Properties extends HashMap<String,Object> public static PropertyValue[] convertToPropertyValueArray(Object[] _oObjectArray) { PropertyValue[] retproperties = null; - if (_oObjectArray != null) + if (_oObjectArray != null && _oObjectArray.length > 0) { - if (_oObjectArray.length > 0) + retproperties = new PropertyValue[_oObjectArray.length]; + for (int i = 0; i < _oObjectArray.length; i++) { - retproperties = new PropertyValue[_oObjectArray.length]; - for (int i = 0; i < _oObjectArray.length; i++) - { - retproperties[i] = (PropertyValue) _oObjectArray[i]; - } + retproperties[i] = (PropertyValue) _oObjectArray[i]; } } return retproperties; diff --git a/wizards/com/sun/star/wizards/common/PropertySetHelper.java b/wizards/com/sun/star/wizards/common/PropertySetHelper.java index 1def4f063580..0fb0959a0f18 100644 --- a/wizards/com/sun/star/wizards/common/PropertySetHelper.java +++ b/wizards/com/sun/star/wizards/common/PropertySetHelper.java @@ -167,12 +167,9 @@ public class PropertySetHelper DebugHelper.writeInfo(e.getMessage()); } } - if (aObject == null) + if (aObject == null && getHashMap().containsKey(_sName)) { - if (getHashMap().containsKey(_sName)) - { - aObject = getHashMap().get(_sName); - } + aObject = getHashMap().get(_sName); } if (aObject != null) { diff --git a/wizards/com/sun/star/wizards/db/DBMetaData.java b/wizards/com/sun/star/wizards/db/DBMetaData.java index d62a547803c4..0b03f0453024 100644 --- a/wizards/com/sun/star/wizards/db/DBMetaData.java +++ b/wizards/com/sun/star/wizards/db/DBMetaData.java @@ -324,12 +324,9 @@ public class DBMetaData public String[] getQueryNames() { - if (QueryNames != null) + if (QueryNames != null && QueryNames.length > 0) { - if (QueryNames.length > 0) - { - return QueryNames; - } + return QueryNames; } QueryNames = getQueryNamesAsNameAccess().getElementNames(); return QueryNames; @@ -337,12 +334,9 @@ public class DBMetaData public String[] getTableNames() { - if (TableNames != null) + if (TableNames != null && TableNames.length > 0) { - if (TableNames.length > 0) - { - return TableNames; - } + return TableNames; } TableNames = getTableNamesAsNameAccess().getElementNames(); return TableNames; diff --git a/wizards/com/sun/star/wizards/db/TableDescriptor.java b/wizards/com/sun/star/wizards/db/TableDescriptor.java index ee9c427ba6f2..2db69f52c31c 100644 --- a/wizards/com/sun/star/wizards/db/TableDescriptor.java +++ b/wizards/com/sun/star/wizards/db/TableDescriptor.java @@ -351,18 +351,15 @@ public class TableDescriptor extends CommandMetaData implements XContainerListen private void assignTableProperty(String _spropname, String _svalue) { - if (_svalue != null) + if (_svalue != null && !_svalue.equals(PropertyNames.EMPTY_STRING)) { - if (!_svalue.equals(PropertyNames.EMPTY_STRING)) + try { - try - { - xPropTableDataDescriptor.setPropertyValue(_spropname, _svalue); - } - catch (Exception e) - { - e.printStackTrace(System.err); - } + xPropTableDataDescriptor.setPropertyValue(_spropname, _svalue); + } + catch (Exception e) + { + e.printStackTrace(System.err); } } } diff --git a/wizards/com/sun/star/wizards/db/TypeInspector.java b/wizards/com/sun/star/wizards/db/TypeInspector.java index bc9f696a4e86..4acc32e1af08 100644 --- a/wizards/com/sun/star/wizards/db/TypeInspector.java +++ b/wizards/com/sun/star/wizards/db/TypeInspector.java @@ -322,12 +322,9 @@ public class TypeInspector int i = JavaTools.FieldInIntTable(nDataTypeInfos, curDataType, startindex); startindex = i + 1; bleaveloop = (i == -1); - if (!bleaveloop) + if (!bleaveloop && bisAutoIncrementableInfos[i]) { - if (bisAutoIncrementableInfos[i]) - { - return nDataTypeInfos[i]; - } + return nDataTypeInfos[i]; } } } diff --git a/wizards/com/sun/star/wizards/form/FormConfiguration.java b/wizards/com/sun/star/wizards/form/FormConfiguration.java index dbdaa6272be3..9782a5aa25ea 100644 --- a/wizards/com/sun/star/wizards/form/FormConfiguration.java +++ b/wizards/com/sun/star/wizards/form/FormConfiguration.java @@ -203,12 +203,9 @@ public class FormConfiguration if (areexistingRelationsdefined()) { short[] iselected = (short[]) Helper.getUnoArrayPropertyValue(UnoDialog.getModel(lstRelations), PropertyNames.SELECTED_ITEMS); - if (iselected != null) + if (iselected != null && iselected.length > 0) { - if (iselected.length > 0) - { - return sreferencedTables[iselected[0]]; - } + return sreferencedTables[iselected[0]]; } } return PropertyNames.EMPTY_STRING; diff --git a/wizards/com/sun/star/wizards/form/FormDocument.java b/wizards/com/sun/star/wizards/form/FormDocument.java index 532c979b5f61..72faa38c491c 100644 --- a/wizards/com/sun/star/wizards/form/FormDocument.java +++ b/wizards/com/sun/star/wizards/form/FormDocument.java @@ -299,15 +299,12 @@ public class FormDocument extends TextDocument { LinkFieldNames = _curFieldLinker.getLinkFieldNames(_curFormConfiguration.getRelationController(), sRefTableName); } - if (LinkFieldNames != null) + if (LinkFieldNames != null && LinkFieldNames.length > 0) { - if (LinkFieldNames.length > 0) - { - oSubControlForm.xPropertySet.setPropertyValue("DetailFields", LinkFieldNames[0]); - oSubControlForm.xPropertySet.setPropertyValue("MasterFields", LinkFieldNames[1]); - oSubControlForm.finalizeControls(); - return true; - } + oSubControlForm.xPropertySet.setPropertyValue("DetailFields", LinkFieldNames[0]); + oSubControlForm.xPropertySet.setPropertyValue("MasterFields", LinkFieldNames[1]); + oSubControlForm.finalizeControls(); + return true; } return false; } diff --git a/wizards/com/sun/star/wizards/query/Finalizer.java b/wizards/com/sun/star/wizards/query/Finalizer.java index 8efe9abf76ed..a14923b4d75c 100644 --- a/wizards/com/sun/star/wizards/query/Finalizer.java +++ b/wizards/com/sun/star/wizards/query/Finalizer.java @@ -140,15 +140,12 @@ public class Finalizer try { String sCurQueryName = AnyConverter.toString(Helper.getUnoPropertyValue(UnoDialog.getModel(m_aTxtTitle), "Text")); - if (sCurQueryName != null) + if (sCurQueryName != null && sCurQueryName.equals(PropertyNames.EMPTY_STRING)) { - if (sCurQueryName.equals(PropertyNames.EMPTY_STRING)) - { - String[] sCommandNames = CurDBMetaData.getIncludedCommandNames(); - sCurQueryName = resQuery + "_" + sCommandNames[0]; - sCurQueryName = CurDBMetaData.suggestName( CommandType.QUERY, sCurQueryName ); - Helper.setUnoPropertyValue(UnoDialog.getModel(m_aTxtTitle), "Text", sCurQueryName); - } + String[] sCommandNames = CurDBMetaData.getIncludedCommandNames(); + sCurQueryName = resQuery + "_" + sCommandNames[0]; + sCurQueryName = CurDBMetaData.suggestName( CommandType.QUERY, sCurQueryName ); + Helper.setUnoPropertyValue(UnoDialog.getModel(m_aTxtTitle), "Text", sCurQueryName); } CurDBMetaData.setSummaryString(); m_queryWizard.setControlProperty("txtSummary", "Text", CurDBMetaData.getSummaryString()); diff --git a/wizards/com/sun/star/wizards/table/Finalizer.java b/wizards/com/sun/star/wizards/table/Finalizer.java index b824d515e9cd..86496efedbfb 100644 --- a/wizards/com/sun/star/wizards/table/Finalizer.java +++ b/wizards/com/sun/star/wizards/table/Finalizer.java @@ -93,110 +93,104 @@ public class Finalizer txtTableName.setMaxTextLen((short) this.curtabledescriptor.getMaxTableNameLength()); if (this.curtabledescriptor.xDBMetaData.supportsCatalogsInTableDefinitions()) { - if (sCatalogNames != null) + if (sCatalogNames != null && sCatalogNames.length > 0) { - if (sCatalogNames.length > 0) + bsupportsCatalogs = true; + String sCatalog = PropertyNames.EMPTY_STRING; + try { - bsupportsCatalogs = true; - String sCatalog = PropertyNames.EMPTY_STRING; - try - { - sCatalog = curtabledescriptor.DBConnection.getCatalog(); - } - catch (SQLException e1) - { - e1.printStackTrace(System.err); - } - CurUnoDialog.insertLabel("lblCatalog", + sCatalog = curtabledescriptor.DBConnection.getCatalog(); + } + catch (SQLException e1) + { + e1.printStackTrace(System.err); + } + CurUnoDialog.insertLabel("lblCatalog", + new String[] + { + PropertyNames.PROPERTY_HEIGHT, PropertyNames.PROPERTY_LABEL, PropertyNames.PROPERTY_POSITION_X, PropertyNames.PROPERTY_POSITION_Y, PropertyNames.PROPERTY_STEP, PropertyNames.PROPERTY_TABINDEX, PropertyNames.PROPERTY_WIDTH + }, + new Object[] + { + 8, slblCatalog, Integer.valueOf(nListBoxPosX), 52, IFINALSTEP, Short.valueOf(curtabindex++), 120 + }); + + try + { + xCatalogListBox = CurUnoDialog.insertListBox("lstCatalog", null, null, new String[] { - PropertyNames.PROPERTY_HEIGHT, PropertyNames.PROPERTY_LABEL, PropertyNames.PROPERTY_POSITION_X, PropertyNames.PROPERTY_POSITION_Y, PropertyNames.PROPERTY_STEP, PropertyNames.PROPERTY_TABINDEX, PropertyNames.PROPERTY_WIDTH + "Dropdown", PropertyNames.PROPERTY_HEIGHT, PropertyNames.PROPERTY_HELPURL, "LineCount", PropertyNames.PROPERTY_POSITION_X, PropertyNames.PROPERTY_POSITION_Y, PropertyNames.PROPERTY_STEP, PropertyNames.STRING_ITEM_LIST, PropertyNames.PROPERTY_TABINDEX, PropertyNames.PROPERTY_WIDTH }, new Object[] { - 8, slblCatalog, Integer.valueOf(nListBoxPosX), 52, IFINALSTEP, Short.valueOf(curtabindex++), 120 + Boolean.TRUE, 12, "HID:WIZARDS_HID_DLGTABLE_LST_CATALOG", Short.valueOf(UnoDialog.getListBoxLineCount()), Integer.valueOf(nListBoxPosX), 62, IFINALSTEP, sCatalogNames, Short.valueOf(curtabindex++), 80 }); - - try - { - xCatalogListBox = CurUnoDialog.insertListBox("lstCatalog", null, null, - new String[] - { - "Dropdown", PropertyNames.PROPERTY_HEIGHT, PropertyNames.PROPERTY_HELPURL, "LineCount", PropertyNames.PROPERTY_POSITION_X, PropertyNames.PROPERTY_POSITION_Y, PropertyNames.PROPERTY_STEP, PropertyNames.STRING_ITEM_LIST, PropertyNames.PROPERTY_TABINDEX, PropertyNames.PROPERTY_WIDTH - }, - new Object[] - { - Boolean.TRUE, 12, "HID:WIZARDS_HID_DLGTABLE_LST_CATALOG", Short.valueOf(UnoDialog.getListBoxLineCount()), Integer.valueOf(nListBoxPosX), 62, IFINALSTEP, sCatalogNames, Short.valueOf(curtabindex++), 80 - }); - int isel = JavaTools.FieldInList(sCatalogNames, sCatalog); - if (isel < 0) - { - isel = 0; - } - CurUnoDialog.setControlProperty("lstCatalog", PropertyNames.SELECTED_ITEMS, new short[] - { - (short) isel - }); - } - catch (Exception e) + int isel = JavaTools.FieldInList(sCatalogNames, sCatalog); + if (isel < 0) { - e.printStackTrace(System.err); + isel = 0; } - nListBoxPosX = 200; + CurUnoDialog.setControlProperty("lstCatalog", PropertyNames.SELECTED_ITEMS, new short[] + { + (short) isel + }); + } + catch (Exception e) + { + e.printStackTrace(System.err); } + nListBoxPosX = 200; } } if (this.curtabledescriptor.xDBMetaData.supportsSchemasInTableDefinitions()) { - if (sSchemaNames != null) + if (sSchemaNames != null && sSchemaNames.length > 0) { - if (sSchemaNames.length > 0) + bsupportsSchemata = true; + String sSchema = PropertyNames.EMPTY_STRING; + try { - bsupportsSchemata = true; - String sSchema = PropertyNames.EMPTY_STRING; - try - { - sSchema = (String) curtabledescriptor.getDataSourcePropertySet().getPropertyValue("User"); - } - catch (Exception e1) - { - e1.printStackTrace(System.err); - } - CurUnoDialog.insertLabel("lblSchema", + sSchema = (String) curtabledescriptor.getDataSourcePropertySet().getPropertyValue("User"); + } + catch (Exception e1) + { + e1.printStackTrace(System.err); + } + CurUnoDialog.insertLabel("lblSchema", + new String[] + { + PropertyNames.PROPERTY_HEIGHT, PropertyNames.PROPERTY_LABEL, PropertyNames.PROPERTY_POSITION_X, PropertyNames.PROPERTY_POSITION_Y, PropertyNames.PROPERTY_STEP, PropertyNames.PROPERTY_TABINDEX, PropertyNames.PROPERTY_WIDTH + }, + new Object[] + { + 8, slblSchema, Integer.valueOf(nListBoxPosX), 52, IFINALSTEP, Short.valueOf(curtabindex++), 80 + }); + + try + { + xSchemaListBox = CurUnoDialog.insertListBox("lstSchema", null, null, new String[] { - PropertyNames.PROPERTY_HEIGHT, PropertyNames.PROPERTY_LABEL, PropertyNames.PROPERTY_POSITION_X, PropertyNames.PROPERTY_POSITION_Y, PropertyNames.PROPERTY_STEP, PropertyNames.PROPERTY_TABINDEX, PropertyNames.PROPERTY_WIDTH + "Dropdown", PropertyNames.PROPERTY_HEIGHT, PropertyNames.PROPERTY_HELPURL, "LineCount", PropertyNames.PROPERTY_POSITION_X, PropertyNames.PROPERTY_POSITION_Y, PropertyNames.PROPERTY_STEP, PropertyNames.STRING_ITEM_LIST, PropertyNames.PROPERTY_TABINDEX, PropertyNames.PROPERTY_WIDTH }, new Object[] { - 8, slblSchema, Integer.valueOf(nListBoxPosX), 52, IFINALSTEP, Short.valueOf(curtabindex++), 80 + Boolean.TRUE, 12, "HID:WIZARDS_HID_DLGTABLE_LST_SCHEMA", Short.valueOf(UnoDialog.getListBoxLineCount()), Integer.valueOf(nListBoxPosX), 62, IFINALSTEP, sSchemaNames, Short.valueOf(curtabindex++), 80 }); - - try - { - xSchemaListBox = CurUnoDialog.insertListBox("lstSchema", null, null, - new String[] - { - "Dropdown", PropertyNames.PROPERTY_HEIGHT, PropertyNames.PROPERTY_HELPURL, "LineCount", PropertyNames.PROPERTY_POSITION_X, PropertyNames.PROPERTY_POSITION_Y, PropertyNames.PROPERTY_STEP, PropertyNames.STRING_ITEM_LIST, PropertyNames.PROPERTY_TABINDEX, PropertyNames.PROPERTY_WIDTH - }, - new Object[] - { - Boolean.TRUE, 12, "HID:WIZARDS_HID_DLGTABLE_LST_SCHEMA", Short.valueOf(UnoDialog.getListBoxLineCount()), Integer.valueOf(nListBoxPosX), 62, IFINALSTEP, sSchemaNames, Short.valueOf(curtabindex++), 80 - }); - int isel = JavaTools.FieldInList(sSchemaNames, sSchema); - if (isel < 0) - { - isel = 0; - } - CurUnoDialog.setControlProperty("lstSchema", PropertyNames.SELECTED_ITEMS, new short[] - { - (short) isel - }); - } - catch (Exception e) + int isel = JavaTools.FieldInList(sSchemaNames, sSchema); + if (isel < 0) { - e.printStackTrace(System.err); + isel = 0; } + CurUnoDialog.setControlProperty("lstSchema", PropertyNames.SELECTED_ITEMS, new short[] + { + (short) isel + }); + } + catch (Exception e) + { + e.printStackTrace(System.err); } } } diff --git a/wizards/com/sun/star/wizards/table/PrimaryKeyHandler.java b/wizards/com/sun/star/wizards/table/PrimaryKeyHandler.java index 4f5b2d22a694..e45c3dab97c0 100644 --- a/wizards/com/sun/star/wizards/table/PrimaryKeyHandler.java +++ b/wizards/com/sun/star/wizards/table/PrimaryKeyHandler.java @@ -224,13 +224,10 @@ public class PrimaryKeyHandler implements XFieldSelectionListener fieldnames = curTableDescriptor.getNonBinaryFieldNames(); String[] skeyfieldnames = curPrimaryKeySelection.getSelectedFieldNames(); curPrimaryKeySelection.initialize(fieldnames, false); - if (skeyfieldnames != null) + if (skeyfieldnames != null && skeyfieldnames.length > 0) { - if (skeyfieldnames.length > 0) - { - String[] snewkeyfieldnames = JavaTools.removeOutdatedFields(skeyfieldnames, fieldnames); - curPrimaryKeySelection.setSelectedFieldNames(snewkeyfieldnames); - } + String[] snewkeyfieldnames = JavaTools.removeOutdatedFields(skeyfieldnames, fieldnames); + curPrimaryKeySelection.setSelectedFieldNames(snewkeyfieldnames); } String selfield = lstSinglePrimeKey.getSelectedItem(); Helper.setUnoPropertyValue(UnoDialog.getModel(lstSinglePrimeKey), PropertyNames.STRING_ITEM_LIST, fieldnames); @@ -313,12 +310,9 @@ public class PrimaryKeyHandler implements XFieldSelectionListener try { XPropertySet xColPropertySet = curTableDescriptor.getByName(_fieldname); - if (xColPropertySet != null) + if (xColPropertySet != null && curTableDescriptor.getDBDataTypeInspector() != null) { - if (curTableDescriptor.getDBDataTypeInspector() != null) - { - return curTableDescriptor.getDBDataTypeInspector().isAutoIncrementable(xColPropertySet); - } + return curTableDescriptor.getDBDataTypeInspector().isAutoIncrementable(xColPropertySet); } } catch (Exception e) diff --git a/wizards/com/sun/star/wizards/table/TableWizard.java b/wizards/com/sun/star/wizards/table/TableWizard.java index 7acfb593938e..60632764a3e4 100644 --- a/wizards/com/sun/star/wizards/table/TableWizard.java +++ b/wizards/com/sun/star/wizards/table/TableWizard.java @@ -237,14 +237,11 @@ public class TableWizard extends DatabaseObjectWizard implements XTextListener if (curTableDescriptor.supportsPrimaryKeys()) { String[] keyfieldnames = curPrimaryKeyHandler.getPrimaryKeyFields(); - if (keyfieldnames != null) + if (keyfieldnames != null && keyfieldnames.length > 0) { - if (keyfieldnames.length > 0) - { - boolean bIsAutoIncrement = curPrimaryKeyHandler.isAutoIncremented(); - bIsSuccessfull = curTableDescriptor.createTable(catalogname, schemaname, tablename, keyfieldnames, bIsAutoIncrement); - bTableCreated = true; - } + boolean bIsAutoIncrement = curPrimaryKeyHandler.isAutoIncremented(); + bIsSuccessfull = curTableDescriptor.createTable(catalogname, schemaname, tablename, keyfieldnames, bIsAutoIncrement); + bTableCreated = true; } } if (!bTableCreated) diff --git a/wizards/com/sun/star/wizards/ui/DBLimitedFieldSelection.java b/wizards/com/sun/star/wizards/ui/DBLimitedFieldSelection.java index 270e19f77f8a..c08aa9996ef2 100644 --- a/wizards/com/sun/star/wizards/ui/DBLimitedFieldSelection.java +++ b/wizards/com/sun/star/wizards/ui/DBLimitedFieldSelection.java @@ -95,22 +95,19 @@ public abstract class DBLimitedFieldSelection { short[] SelList = null; Helper.setUnoPropertyValue(UnoDialog.getModel(xListBox), PropertyNames.STRING_ITEM_LIST, _AllFieldNames); - if (_SelFieldNames != null) + if (_SelFieldNames != null && curindex < _SelFieldNames.length) { - if (curindex < _SelFieldNames.length) + int index = JavaTools.FieldInList(_AllFieldNames, _SelFieldNames[curindex]); + if (index > -1) { - int index = JavaTools.FieldInList(_AllFieldNames, _SelFieldNames[curindex]); - if (index > -1) - { - SelList = new short[] { (short) (index) }; - } - else - { - SelList = new short[] { (short) (0) }; - } - Helper.setUnoPropertyValue(UnoDialog.getModel(xListBox), PropertyNames.SELECTED_ITEMS, SelList); - return; + SelList = new short[] { (short) (index) }; } + else + { + SelList = new short[] { (short) (0) }; + } + Helper.setUnoPropertyValue(UnoDialog.getModel(xListBox), PropertyNames.SELECTED_ITEMS, SelList); + return; } SelList = new short[] { (short) (0) }; Helper.setUnoPropertyValue(UnoDialog.getModel(xListBox), PropertyNames.SELECTED_ITEMS, SelList); diff --git a/xmerge/source/xmerge/java/org/openoffice/xmerge/converter/xml/EmbeddedBinaryObject.java b/xmerge/source/xmerge/java/org/openoffice/xmerge/converter/xml/EmbeddedBinaryObject.java index 212e07ee891a..6ac60f183f13 100644 --- a/xmerge/source/xmerge/java/org/openoffice/xmerge/converter/xml/EmbeddedBinaryObject.java +++ b/xmerge/source/xmerge/java/org/openoffice/xmerge/converter/xml/EmbeddedBinaryObject.java @@ -61,11 +61,9 @@ public class EmbeddedBinaryObject extends EmbeddedObject { */ public byte[] getBinaryData() { - if (objData == null) { - // See if we came from a Zip file - if (zipFile != null) { - objData = zipFile.getNamedBytes(objName); - } + // See if we came from a Zip file + if (objData == null && zipFile != null) { + objData = zipFile.getNamedBytes(objName); } return objData; diff --git a/xmerge/source/xmerge/java/org/openoffice/xmerge/converter/xml/TextStyle.java b/xmerge/source/xmerge/java/org/openoffice/xmerge/converter/xml/TextStyle.java index 26115d4084a5..8875c21c902f 100644 --- a/xmerge/source/xmerge/java/org/openoffice/xmerge/converter/xml/TextStyle.java +++ b/xmerge/source/xmerge/java/org/openoffice/xmerge/converter/xml/TextStyle.java @@ -461,10 +461,8 @@ public class TextStyle extends Style implements Cloneable { if (tStyle.values != values) return false; - if (tStyle.sizeInPoints != 0) { - if (sizeInPoints != tStyle.sizeInPoints) - return false; - } + if (tStyle.sizeInPoints != 0 && sizeInPoints != tStyle.sizeInPoints) + return false; if (tStyle.fontName != null) { if (fontName == null) @@ -498,29 +496,23 @@ public class TextStyle extends Style implements Cloneable { */ private void writeAttributes(Element node) { - if ((mask & BOLD) != 0) - if ((values & BOLD) != 0) - node.setAttribute("fo:font-weight", "bold"); + if ((mask & BOLD) != 0 && (values & BOLD) != 0) + node.setAttribute("fo:font-weight", "bold"); - if ((mask & ITALIC) != 0) - if ((values & ITALIC) != 0) - node.setAttribute("fo:font-style", "italic"); + if ((mask & ITALIC) != 0 && (values & ITALIC) != 0) + node.setAttribute("fo:font-style", "italic"); - if ((mask & UNDERLINE) != 0) - if ((values & UNDERLINE) != 0) - node.setAttribute("style:text-underline", "single"); + if ((mask & UNDERLINE) != 0 && (values & UNDERLINE) != 0) + node.setAttribute("style:text-underline", "single"); - if ((mask & STRIKETHRU) != 0) - if ((values & STRIKETHRU) != 0) - node.setAttribute("style:text-crossing-out", "single-line"); + if ((mask & STRIKETHRU) != 0 && (values & STRIKETHRU) != 0) + node.setAttribute("style:text-crossing-out", "single-line"); - if ((mask & SUPERSCRIPT) != 0) - if ((values & SUPERSCRIPT) != 0) - node.setAttribute("style:text-position", "super 58%"); + if ((mask & SUPERSCRIPT) != 0 && (values & SUPERSCRIPT) != 0) + node.setAttribute("style:text-position", "super 58%"); - if ((mask & SUBSCRIPT) != 0) - if ((values & SUBSCRIPT) != 0) - node.setAttribute("style:text-position", "sub 58%"); + if ((mask & SUBSCRIPT) != 0 && (values & SUBSCRIPT) != 0) + node.setAttribute("style:text-position", "sub 58%"); if (sizeInPoints != 0) { node.setAttribute("fo:font-size", Integer.toString(sizeInPoints) + "pt"); diff --git a/xmerge/source/xmerge/java/org/openoffice/xmerge/converter/xml/sxc/Format.java b/xmerge/source/xmerge/java/org/openoffice/xmerge/converter/xml/sxc/Format.java index 7015847152a5..0a24044159ea 100644 --- a/xmerge/source/xmerge/java/org/openoffice/xmerge/converter/xml/sxc/Format.java +++ b/xmerge/source/xmerge/java/org/openoffice/xmerge/converter/xml/sxc/Format.java @@ -406,10 +406,8 @@ public class Format { if (rhs.attributes!= attributes) return false; - if (rhs.sizeInPoints != 0) { - if (sizeInPoints != rhs.sizeInPoints) - return false; - } + if (rhs.sizeInPoints != 0 && sizeInPoints != rhs.sizeInPoints) + return false; if (fontName == null ? rhs.fontName != null : !fontName.equals(rhs.fontName)) return false; diff --git a/xmerge/source/xmerge/java/org/openoffice/xmerge/converter/xml/xslt/ConverterCapabilitiesImpl.java b/xmerge/source/xmerge/java/org/openoffice/xmerge/converter/xml/xslt/ConverterCapabilitiesImpl.java index 5569af0a8c33..64a94d350168 100644 --- a/xmerge/source/xmerge/java/org/openoffice/xmerge/converter/xml/xslt/ConverterCapabilitiesImpl.java +++ b/xmerge/source/xmerge/java/org/openoffice/xmerge/converter/xml/xslt/ConverterCapabilitiesImpl.java @@ -68,12 +68,7 @@ public final class ConverterCapabilitiesImpl } public boolean canConvertAttribute(String tag, String attribute) { - - if (OfficeConstants.TAG_SPACE.equals(tag)) { - if (OfficeConstants.ATTRIBUTE_SPACE_COUNT.equals(attribute)) - return true; - } - - return false; + return OfficeConstants.TAG_SPACE.equals(tag) + && OfficeConstants.ATTRIBUTE_SPACE_COUNT.equals(attribute); } }
\ No newline at end of file diff --git a/xmerge/source/xmerge/java/org/openoffice/xmerge/util/Debug.java b/xmerge/source/xmerge/java/org/openoffice/xmerge/util/Debug.java index 4599a0e49c23..ed95031f8a24 100644 --- a/xmerge/source/xmerge/java/org/openoffice/xmerge/util/Debug.java +++ b/xmerge/source/xmerge/java/org/openoffice/xmerge/util/Debug.java @@ -203,10 +203,8 @@ public final class Debug { * @param msg The message. */ public static void log(int flag, String msg) { - if (isFlagSet(flag)) { - if (writer != null) { - writer.println(msg); - } + if (isFlagSet(flag) && writer != null) { + writer.println(msg); } } @@ -223,12 +221,10 @@ public final class Debug { * @param e Throwable object. */ public static void log(int flag, String msg, Throwable e) { - if (isFlagSet(flag)) { - if (writer != null) { - writer.println(msg); - if (e != null) - e.printStackTrace(writer); - } + if (isFlagSet(flag) && writer != null) { + writer.println(msg); + if (e != null) + e.printStackTrace(writer); } } }
\ No newline at end of file |