Kaydet (Commit) fb39e719 authored tarafından Noel Grandin's avatar Noel Grandin

Java cleanup, call static methods statically

Change-Id: Ibe0454d490153f723a58c3c619be7f8d443639c8
üst d2d3e5d2
......@@ -24,23 +24,23 @@
package integration.forms;
import com.sun.star.uno.AnyConverter;
public class BooleanValidator extends integration.forms.ControlValidator
{
private boolean m_preventChecked;
private com.sun.star.uno.AnyConverter m_converter;
/** Creates a new instance of BooleanValidator */
public BooleanValidator( boolean preventChecked )
{
m_preventChecked = preventChecked;
m_converter = new com.sun.star.uno.AnyConverter();
}
public String explainInvalid( Object Value )
{
try
{
if ( m_converter.isVoid( Value ) )
if ( AnyConverter.isVoid( Value ) )
return "'indetermined' is not an allowed state";
boolean value = ((Boolean)Value).booleanValue();
if ( m_preventChecked && ( value == true ) )
......@@ -57,7 +57,7 @@ public class BooleanValidator extends integration.forms.ControlValidator
{
try
{
if ( m_converter.isVoid( Value ) )
if ( AnyConverter.isVoid( Value ) )
return false;
boolean value = ((Boolean)Value).booleanValue();
......
......@@ -465,9 +465,8 @@ public class ConfigExamples
for(int i=0; i< aElementNames.length; ++i)
{
Object aChild = xChildAccess.getByName( aElementNames[i] );
AnyConverter aAnyConv = new AnyConverter();
// is it a structural element (object) ...
if ( aAnyConv.isObject(aChild) && !aAnyConv.isArray(aChild) )
if ( AnyConverter.isObject(aChild) && !AnyConverter.isArray(aChild) )
{
// then get an interface
XInterface xChildElement = UnoRuntime.queryInterface(XInterface.class, aChild);
......@@ -527,7 +526,7 @@ public class ConfigExamples
new IConfigurationProcessor () {
/// prints Path and Value of properties
public void processValueElement( String sPath_, Object aValue_ ) {
if (new AnyConverter().isArray(aValue_))
if (AnyConverter.isArray(aValue_))
{
final Object [] aArray = (Object [])aValue_;
......@@ -751,11 +750,10 @@ public class ConfigExamples
String aItemNames [] = aReplace.getElementNames();
for (int i=0; i < aItemNames.length; ++i) {
Object aItem = aReplace.getByName( aItemNames [i] );
AnyConverter aAnyConv = new AnyConverter();
// replace integers by a 'complement' value
if ( aAnyConv.isInt(aItem) )
if ( AnyConverter.isInt(aItem) )
{
int nOld = aAnyConv.toInt(aItem);
int nOld = AnyConverter.toInt(aItem);
int nNew = 9999 - nOld;
System.out.println("Replacing integer value: " + aItemNames [i]);
......@@ -763,9 +761,9 @@ public class ConfigExamples
}
// and booleans by their negated value
else if ( aAnyConv.isBoolean(aItem) )
else if ( AnyConverter.isBoolean(aItem) )
{
boolean bOld = aAnyConv.toBoolean(aItem);
boolean bOld = AnyConverter.toBoolean(aItem);
boolean bNew = ! bOld;
System.out.println("Replacing boolean value: " + aItemNames [i]);
......
import com.sun.star.uno.AnyConverter;
/*************************************************************************
*
* The Contents of this file are made available subject to the terms of
......@@ -35,20 +37,18 @@
public class BooleanValidator extends ControlValidator
{
private boolean m_preventChecked;
private com.sun.star.uno.AnyConverter m_converter;
/** Creates a new instance of BooleanValidator */
public BooleanValidator( boolean preventChecked )
{
m_preventChecked = preventChecked;
m_converter = new com.sun.star.uno.AnyConverter();
}
public String explainInvalid( Object Value )
{
try
{
if ( m_converter.isVoid( Value ) )
if ( AnyConverter.isVoid( Value ) )
return "'indetermined' is not an allowed state";
boolean value = ((Boolean)Value).booleanValue();
if ( m_preventChecked && ( value == true ) )
......@@ -65,7 +65,7 @@ public class BooleanValidator extends ControlValidator
{
try
{
if ( m_converter.isVoid( Value ) )
if ( AnyConverter.isVoid( Value ) )
return false;
boolean value = ((Boolean)Value).booleanValue();
......
......@@ -830,16 +830,15 @@ public class SpreadsheetSample extends SpreadsheetDocHelper
// --- Document properties ---
com.sun.star.beans.XPropertySet xPropSet = UnoRuntime.queryInterface( com.sun.star.beans.XPropertySet.class, getDocument() );
AnyConverter aAnyConv = new AnyConverter();
String aText = "Value of property IsIterationEnabled: ";
aText += aAnyConv.toBoolean(xPropSet.getPropertyValue( "IsIterationEnabled" ));
aText += AnyConverter.toBoolean(xPropSet.getPropertyValue( "IsIterationEnabled" ));
System.out.println( aText );
aText = "Value of property IterationCount: ";
aText += aAnyConv.toInt(xPropSet.getPropertyValue( "IterationCount" ));
aText += AnyConverter.toInt(xPropSet.getPropertyValue( "IterationCount" ));
System.out.println( aText );
aText = "Value of property NullDate: ";
com.sun.star.util.Date aDate = (com.sun.star.util.Date)
aAnyConv.toObject(com.sun.star.util.Date.class, xPropSet.getPropertyValue( "NullDate" ));
AnyConverter.toObject(com.sun.star.util.Date.class, xPropSet.getPropertyValue( "NullDate" ));
aText += aDate.Year + "-" + aDate.Month + "-" + aDate.Day;
System.out.println( aText );
......@@ -1202,12 +1201,11 @@ public class SpreadsheetSample extends SpreadsheetDocHelper
UnoRuntime.queryInterface(
com.sun.star.container.XNameAccess.class, aRangesObj );
String[] aNames = xRanges.getElementNames();
AnyConverter aAnyConv = new AnyConverter();
for ( int i=0; i<aNames.length; i++ )
{
Object aRangeObj = xRanges.getByName( aNames[i] );
com.sun.star.beans.XPropertySet xRangeProp = UnoRuntime.queryInterface( com.sun.star.beans.XPropertySet.class, aRangeObj );
boolean bUser = aAnyConv.toBoolean(xRangeProp.getPropertyValue( "IsUserDefined" ));
boolean bUser = AnyConverter.toBoolean(xRangeProp.getPropertyValue( "IsUserDefined" ));
if ( !bUser )
{
// this is the temporary database range - get the cell range and format it
......@@ -1340,7 +1338,7 @@ public class SpreadsheetSample extends SpreadsheetDocHelper
com.sun.star.beans.XPropertySet.class, aSettings );
AnyConverter aAnyConv = new AnyConverter();
String[] aEntries = (String[])
aAnyConv.toObject(String[].class,
AnyConverter.toObject(String[].class,
xPropSet.getPropertyValue( "UserLists" ));
System.out.println("User defined sort lists:");
for ( int i=0; i<aEntries.length; i++ )
......
......@@ -33,19 +33,21 @@
*************************************************************************/
import org.openoffice.XInstanceInspector;
import com.sun.star.beans.Property;
import com.sun.star.beans.PropertyValue;
import com.sun.star.beans.XIntrospectionAccess;
import com.sun.star.beans.XPropertySet;
import com.sun.star.lang.XServiceInfo;
import com.sun.star.lib.uno.helper.WeakBase;
import com.sun.star.reflection.XIdlMethod;
import com.sun.star.uno.Any;
import com.sun.star.lang.XServiceInfo;
import com.sun.star.uno.AnyConverter;
import com.sun.star.uno.Type;
import com.sun.star.uno.TypeClass;
import com.sun.star.uno.UnoRuntime;
import com.sun.star.uno.Type;
import com.sun.star.uno.XComponentContext;
import com.sun.star.beans.XIntrospectionAccess;
import com.sun.star.beans.Property;
import com.sun.star.beans.PropertyValue;
import com.sun.star.beans.XPropertySet;
import com.sun.star.reflection.XIdlMethod;
import org.openoffice.XInstanceInspector;
public class InspectorPane extends WeakBase implements XInstanceInspector{ //, XServiceInfo
private XIdlMethod[] xIdlMethods;
......@@ -111,7 +113,7 @@ import org.openoffice.XInstanceInspector;
private Type[] getTypes(Object _oUnoObject){
Type[] aTypes = null;
if (m_oIntrospector.isArray(_oUnoObject)){
if (AnyConverter.isArray(_oUnoObject)){
aTypes = (Type[])_oUnoObject;
}
else{
......@@ -144,17 +146,17 @@ import org.openoffice.XInstanceInspector;
}
else{
Any aReturnObject = Any.complete(oUnoReturnObject);
String sShortClassName = m_oIntrospector.getShortClassName(aReturnObject.getType().getTypeName());
String sShortClassName = Introspector.getShortClassName(aReturnObject.getType().getTypeName());
sNodeDescription += m_oSourceCodeGenerator.getVariableNameforUnoObject(sShortClassName);
}
if (m_oIntrospector.isArray(oUnoReturnObject)){
if (m_oIntrospector.isUnoTypeObject(oUnoReturnObject)){
if (Introspector.isArray(oUnoReturnObject)){
if (Introspector.isUnoTypeObject(oUnoReturnObject)){
oUnoNode = addUnoFacetteNode(_oUnoMethodNode, XUnoFacetteNode.SINTERFACEDESCRIPTION, _oUnoMethodNode.getUnoObject());
}
else if(m_oIntrospector.isUnoPropertyTypeObject(oUnoReturnObject)){
else if(Introspector.isUnoPropertyTypeObject(oUnoReturnObject)){
oUnoNode = addUnoFacetteNode(_oUnoMethodNode, XUnoFacetteNode.SPROPERTYINFODESCRIPTION, oUnoReturnObject);
}
else if(m_oIntrospector.isUnoPropertyValueTypeObject(oUnoReturnObject)){
else if(Introspector.isUnoPropertyValueTypeObject(oUnoReturnObject)){
oUnoNode = addUnoFacetteNode(_oUnoMethodNode, XUnoFacetteNode.SPROPERTYVALUEDESCRIPTION, oUnoReturnObject);
}
}
......@@ -245,7 +247,7 @@ import org.openoffice.XInstanceInspector;
public void addMethodsToTreeNode(XUnoNode _oGrandParentNode, Object _oUnoParentObject, XIdlMethod[] _xIdlMethods){
if (this.m_oIntrospector.isValid(_xIdlMethods)){
if (Introspector.isValid(_xIdlMethods)){
for ( int n = 0; n < _xIdlMethods.length; n++ ) {
XIdlMethod xIdlMethod = _xIdlMethods[n];
if (!xIdlMethod.getDeclaringClass().getName().equals("com.sun.star.uno.XInterface")){
......@@ -347,7 +349,7 @@ import org.openoffice.XInstanceInspector;
public void addContainerElementsToTreeNode(XUnoNode _oParentNode, Object _oUnoParentObject){
Object[] oUnoContainerElements = m_oIntrospector.getUnoObjectsOfContainer(_oUnoParentObject);
if (m_oIntrospector.isValid(oUnoContainerElements)){
if (Introspector.isValid(oUnoContainerElements)){
if (oUnoContainerElements.length > 0){
for (int i=0; i< oUnoContainerElements.length; i++){
XUnoNode oChildNode = addUnoNode(_oParentNode, oUnoContainerElements[i], UnoNode.getNodeDescription(oUnoContainerElements[i]));
......@@ -371,7 +373,7 @@ import org.openoffice.XInstanceInspector;
private void setNodeFoldable(XUnoNode _oUnoNode, Object _oUnoObject){
if (_oUnoObject != null){
if (!m_oIntrospector.isObjectPrimitive(_oUnoObject)){
if (!Introspector.isObjectPrimitive(_oUnoObject)){
_oUnoNode.setFoldable(true);
}
}
......@@ -406,7 +408,7 @@ import org.openoffice.XInstanceInspector;
if (!_oUnoObject.getClass().getComponentType().isPrimitive()){
Object[] object = ( Object[] ) _oUnoObject;
for ( int i = 0; i < object.length; i++ ) {
if (m_oIntrospector.isObjectPrimitive(object[i])){
if (Introspector.isObjectPrimitive(object[i])){
XUnoNode oChildNode = addUnoNode(_oUnoNode, null, UnoNode.getNodeDescription(object[i]));
}
}
......@@ -431,14 +433,14 @@ import org.openoffice.XInstanceInspector;
private void addPropertyValueSubNodes(XUnoFacetteNode _oUnoFacetteNode, Object _oUnoObject){
if (m_oIntrospector.isUnoPropertyValueTypeObject(_oUnoObject)){
if (Introspector.isUnoPropertyValueTypeObject(_oUnoObject)){
Object[] object = ( Object[] ) _oUnoObject;
for ( int i = 0; i < object.length; i++ ) {
String sObjectClassName = object[i].getClass().getName();
if (sObjectClassName.equals("com.sun.star.beans.PropertyValue")){
XUnoNode oChildNode = null;
PropertyValue aPropertyValue = (PropertyValue) object[i];
if (! m_oIntrospector.isObjectPrimitive(aPropertyValue.Value)){
if (! Introspector.isObjectPrimitive(aPropertyValue.Value)){
oChildNode = m_xTreeControlProvider.addUnoPropertyNode(_oUnoObject, aPropertyValue, _oUnoObject);
}
else{
......@@ -491,7 +493,7 @@ import org.openoffice.XInstanceInspector;
}
if (oUnoFacetteNode.isPropertyNode()){
String sNodeDescription = oUnoFacetteNode.getLabel();
// TODO: it's very dangerous to distinguishe the different UnoFacetteNodes only by the nodedescription
// TODO: it's very dangerous to distinguish the different UnoFacetteNodes only by the node description
if (sNodeDescription.startsWith(XUnoFacetteNode.SPROPERTYINFODESCRIPTION)){
addPropertySetInfoNodesToTreeNode(oUnoFacetteNode, oUnoObject);
}
......@@ -597,7 +599,7 @@ import org.openoffice.XInstanceInspector;
if (oUnoObject instanceof String){
}
else{
if (!m_oIntrospector.isUnoTypeObject(oUnoObject)){
if (!Introspector.isUnoTypeObject(oUnoObject)){
return oUnoObject;
}
}
......@@ -622,4 +624,3 @@ import org.openoffice.XInstanceInspector;
m_xDialogProvider.showPopUpMenu(_invoker, x, y);
}
}
\ No newline at end of file
......@@ -394,10 +394,10 @@ public class SourceCodeGenerator {
bisDeclared = aVariables.containsKey(sVariableStemName);
if (bisDeclared){
Object oUnoObject = _oUnoObjectDefinition.getUnoObject();
if (m_oIntrospector.isObjectPrimitive(oUnoObject)){
if (Introspector.isObjectPrimitive(oUnoObject)){
bisDeclared = false;
}
else if (m_oIntrospector.isObjectSequence(oUnoObject)){
else if (Introspector.isObjectSequence(oUnoObject)){
bisDeclared = false;
}
else{
......@@ -513,7 +513,7 @@ public class SourceCodeGenerator {
TypeClass aLocTypeClass = aTypeClass;
boolean bIsArray = false;
if (_oUnoObjectDefinition.getUnoObject() != null){
bIsArray = m_oIntrospector.isObjectSequence(_oUnoObjectDefinition.getUnoObject());
bIsArray = Introspector.isObjectSequence(_oUnoObjectDefinition.getUnoObject());
}
else{
bIsArray = _oUnoObjectDefinition.getTypeClass().getValue() == TypeClass.SEQUENCE_value;
......@@ -756,8 +756,8 @@ class UnoObjectDefinition{
if (aVariables.containsKey(sVariableName)){
String sUnoObjectIdentity = aVariables.get(sVariableName).getUnoObject().toString();
if (m_oUnoObject != null){
if ((sUnoObjectIdentity.equals(m_oUnoObject.toString()) && (!m_oIntrospector.isPrimitive(this.getTypeClass())) &&
(! m_oIntrospector.isObjectSequence(m_oUnoObject)))){
if ((sUnoObjectIdentity.equals(m_oUnoObject.toString()) && (!Introspector.isPrimitive(this.getTypeClass())) &&
(! Introspector.isObjectSequence(m_oUnoObject)))){
bleaveloop = true;
}
else{
......@@ -871,11 +871,11 @@ class UnoObjectDefinition{
String sClassName = _sClassName;
String sHeaderStatement = "";
if (_oUnoObject != null){
if (!m_oIntrospector.isObjectPrimitive(_oUnoObject)){
if (m_oIntrospector.isObjectSequence(_oUnoObject)){
if (!Introspector.isObjectPrimitive(_oUnoObject)){
if (Introspector.isObjectSequence(_oUnoObject)){
XTypeDescription xTypeDescription = m_oIntrospector.getReferencedType(sClassName);
if (xTypeDescription != null){
if (!m_oIntrospector.isPrimitive(xTypeDescription.getTypeClass())){
if (!Introspector.isPrimitive(xTypeDescription.getTypeClass())){
sClassName = getTypeString(xTypeDescription.getName(), xTypeDescription.getTypeClass(), true);
}
// primitive Types are not supposed to turn up in the import section...
......@@ -1428,11 +1428,11 @@ class UnoObjectDefinition{
String sClassName = _sClassName;
String sHeaderStatement = "";
if (_oUnoObject != null){
if (!m_oIntrospector.isObjectPrimitive(_oUnoObject)){
if (m_oIntrospector.isObjectSequence(_oUnoObject)){
if (!Introspector.isObjectPrimitive(_oUnoObject)){
if (Introspector.isObjectSequence(_oUnoObject)){
XTypeDescription xTypeDescription = m_oIntrospector.getReferencedType(sClassName);
if (xTypeDescription != null){
if (!m_oIntrospector.isPrimitive(xTypeDescription.getTypeClass())){
if (!Introspector.isPrimitive(xTypeDescription.getTypeClass())){
sClassName = getTypeString(xTypeDescription.getName(), xTypeDescription.getTypeClass(), true);
}
// primitive Types are not supposed to turn up in the import section...
......@@ -1682,7 +1682,7 @@ class UnoObjectDefinition{
public String getVariableDeclaration(String _sTypeString, String _sVariableName, boolean bIsArray, TypeClass _aTypeClass, boolean _bInitialize){
boolean bIsPrimitive = m_oIntrospector.isPrimitive(_aTypeClass);
boolean bIsPrimitive = Introspector.isPrimitive(_aTypeClass);
// uno::Reference< frame::XDispatch > m_xDispatch
String sReturn = "";
......
......@@ -419,7 +419,7 @@ public class UnoNode{
return xServiceInfo.getImplementationName();
}
String sClassName = _oUnoObject.getClass().getName();
if (Introspector.getIntrospector().isObjectPrimitive(_oUnoObject)){ //super.isO{sObjectClassName.equals("java.lang.String"))issClassName.equals("java.lang.String"))
if (Introspector.isObjectPrimitive(_oUnoObject)){ //super.isO{sObjectClassName.equals("java.lang.String"))issClassName.equals("java.lang.String"))
return _oUnoObject.toString();
}
else{
......
......@@ -165,9 +165,6 @@ public class EuroAdaption {
XEnumeration xRanges = xEnumerationAccess.createEnumeration();
// create an AnyConverter for later use
AnyConverter aAnyConv = new AnyConverter();
while( xRanges.hasMoreElements() ) {
// the enumeration returns a cellrange
XCellRange xCellRange = UnoRuntime.queryInterface(
......@@ -180,28 +177,28 @@ public class EuroAdaption {
// getPropertyValue returns an Object, you have to cast it to
// type that you need
Object oNumberObject = xCellProp.getPropertyValue( "NumberFormat" );
int iNumberFormat = aAnyConv.toInt(oNumberObject);
int iNumberFormat = AnyConverter.toInt(oNumberObject);
// get the properties from the cellrange numberformat
XPropertySet xFormat = xNumberFormats.getByKey(iNumberFormat );
short fType = aAnyConv.toShort(xFormat.getPropertyValue("Type"));
String sCurrencySymbol = aAnyConv.toString(
short fType = AnyConverter.toShort(xFormat.getPropertyValue("Type"));
String sCurrencySymbol = AnyConverter.toString(
xFormat.getPropertyValue("CurrencySymbol"));
// change the numberformat only on cellranges with a
// currency numberformat
if( ( (fType & com.sun.star.util.NumberFormat.CURRENCY) > 0) &&
( sCurrencySymbol.compareTo( sOldSymbol ) == 0 ) ) {
boolean bThousandSep = aAnyConv.toBoolean(
boolean bThousandSep = AnyConverter.toBoolean(
xFormat.getPropertyValue("ThousandsSeparator"));
boolean bNegativeRed = aAnyConv.toBoolean(
boolean bNegativeRed = AnyConverter.toBoolean(
xFormat.getPropertyValue("NegativeRed"));
short fDecimals = aAnyConv.toShort(
short fDecimals = AnyConverter.toShort(
xFormat.getPropertyValue("Decimals"));
short fLeadingZeros = aAnyConv.toShort(
short fLeadingZeros = AnyConverter.toShort(
xFormat.getPropertyValue("LeadingZeros"));
Locale oLocale = (Locale) aAnyConv.toObject(
Locale oLocale = (Locale) AnyConverter.toObject(
new com.sun.star.uno.Type(Locale.class),
xFormat.getPropertyValue("Locale"));
......
......@@ -202,7 +202,7 @@ public class StyleInitialization {
com.sun.star.beans.XPropertySet.class, xStyle );
AnyConverter aAnyConv = new AnyConverter();
String sFontname = aAnyConv.toString(xPropertySet.getPropertyValue("CharFontName"));
String sFontname = AnyConverter.toString(xPropertySet.getPropertyValue("CharFontName"));
sFontname = sFontname.toLowerCase();
// if the style use the font 'Albany', apply it to the current paragraph
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment