Some PMD cleaning
This commit is contained in:
@@ -179,7 +179,7 @@ public class LocalOfficeConnection
|
|||||||
public void dispose()
|
public void dispose()
|
||||||
{
|
{
|
||||||
Iterator itr = mComponents.iterator();
|
Iterator itr = mComponents.iterator();
|
||||||
while (itr.hasNext() == true) {
|
while (itr.hasNext()) {
|
||||||
// ignore runtime exceptions in dispose
|
// ignore runtime exceptions in dispose
|
||||||
try { ((XEventListener)itr.next()).disposing(null); }
|
try { ((XEventListener)itr.next()).disposing(null); }
|
||||||
catch ( RuntimeException aExc ) {}
|
catch ( RuntimeException aExc ) {}
|
||||||
@@ -462,12 +462,12 @@ public class LocalOfficeConnection
|
|||||||
case ';':
|
case ';':
|
||||||
idx -= 1; // put back the last read character
|
idx -= 1; // put back the last read character
|
||||||
state = 5;
|
state = 5;
|
||||||
if (name.equals("path")) {
|
if (("path").equals(name)) {
|
||||||
if (path == null)
|
if (path == null)
|
||||||
path = buffer.toString();
|
path = buffer.toString();
|
||||||
else
|
else
|
||||||
state = -3; // error: more then one 'path'
|
state = -3; // error: more then one 'path'
|
||||||
} else if (name.equals("pipe")) {
|
} else if (("pipe").equals(name)) {
|
||||||
if (pipe == null)
|
if (pipe == null)
|
||||||
pipe = buffer.toString();
|
pipe = buffer.toString();
|
||||||
else
|
else
|
||||||
|
@@ -77,8 +77,7 @@ public class OOoBeanTest
|
|||||||
*/
|
*/
|
||||||
private int getSleepTime(int time)
|
private int getSleepTime(int time)
|
||||||
{
|
{
|
||||||
int ret = time;
|
if (!isWindows())
|
||||||
if (isWindows() == false)
|
|
||||||
{
|
{
|
||||||
return time * 5;
|
return time * 5;
|
||||||
}
|
}
|
||||||
@@ -146,7 +145,7 @@ public class OOoBeanTest
|
|||||||
try
|
try
|
||||||
{
|
{
|
||||||
f = new WriterFrame(100, 100, 500,500, false, connection.getComponentContext());
|
f = new WriterFrame(100, 100, 500,500, false, connection.getComponentContext());
|
||||||
if (f.checkUnoFramePosition() == false)
|
if (!f.checkUnoFramePosition())
|
||||||
{
|
{
|
||||||
fail("Sizing error: Client are of Java frame does not match the UNO window.");
|
fail("Sizing error: Client are of Java frame does not match the UNO window.");
|
||||||
}
|
}
|
||||||
@@ -162,18 +161,18 @@ public class OOoBeanTest
|
|||||||
capturer.grabOne(f.getClientArea());
|
capturer.grabOne(f.getClientArea());
|
||||||
f.setExtendedState(Frame.ICONIFIED);
|
f.setExtendedState(Frame.ICONIFIED);
|
||||||
Thread.sleep(getSleepTime(200));
|
Thread.sleep(getSleepTime(200));
|
||||||
if (f.checkUnoFramePosition() == false)
|
if (!f.checkUnoFramePosition())
|
||||||
{
|
{
|
||||||
fail("Sizing error: Frame was iconified.");
|
fail("Sizing error: Frame was iconified.");
|
||||||
}
|
}
|
||||||
f.setExtendedState(Frame.NORMAL);
|
f.setExtendedState(Frame.NORMAL);
|
||||||
Thread.sleep(getSleepTime(200));
|
Thread.sleep(getSleepTime(200));
|
||||||
if (f.checkUnoFramePosition() == false)
|
if (!f.checkUnoFramePosition())
|
||||||
{
|
{
|
||||||
fail("Sizing error: Frame size set back to normal after it was iconified.");
|
fail("Sizing error: Frame size set back to normal after it was iconified.");
|
||||||
}
|
}
|
||||||
capturer.grabTwo(f.getClientArea());
|
capturer.grabTwo(f.getClientArea());
|
||||||
if (capturer.compare() == false)
|
if (!capturer.compare())
|
||||||
{
|
{
|
||||||
fail("Painting error: Minimize (iconify) frame and back to normal size.");
|
fail("Painting error: Minimize (iconify) frame and back to normal size.");
|
||||||
capturer.writeImages();
|
capturer.writeImages();
|
||||||
@@ -187,18 +186,18 @@ public class OOoBeanTest
|
|||||||
capturer.grabOne(f.getClientArea());
|
capturer.grabOne(f.getClientArea());
|
||||||
f.setExtendedState(Frame.MAXIMIZED_BOTH);
|
f.setExtendedState(Frame.MAXIMIZED_BOTH);
|
||||||
Thread.sleep(getSleepTime(200));
|
Thread.sleep(getSleepTime(200));
|
||||||
if (f.checkUnoFramePosition() == false)
|
if (!f.checkUnoFramePosition())
|
||||||
{
|
{
|
||||||
fail("Sizing error: Frame maximized.");
|
fail("Sizing error: Frame maximized.");
|
||||||
}
|
}
|
||||||
f.setExtendedState(Frame.NORMAL);
|
f.setExtendedState(Frame.NORMAL);
|
||||||
Thread.sleep(getSleepTime(200));
|
Thread.sleep(getSleepTime(200));
|
||||||
if (f.checkUnoFramePosition() == false)
|
if (!f.checkUnoFramePosition())
|
||||||
{
|
{
|
||||||
fail("Sizing error: Frame set from maximized to normal.");
|
fail("Sizing error: Frame set from maximized to normal.");
|
||||||
}
|
}
|
||||||
capturer.grabTwo(f.getClientArea());
|
capturer.grabTwo(f.getClientArea());
|
||||||
if (capturer.compare() == false)
|
if (!capturer.compare())
|
||||||
{
|
{
|
||||||
fail("Painting error: Maximize frame and back to normal size");
|
fail("Painting error: Maximize frame and back to normal size");
|
||||||
capturer.writeImages();
|
capturer.writeImages();
|
||||||
@@ -211,13 +210,13 @@ public class OOoBeanTest
|
|||||||
Rectangle oldPosition = f.getBounds();
|
Rectangle oldPosition = f.getBounds();
|
||||||
f.setBounds(0, 0, oldPosition.width, oldPosition.height);
|
f.setBounds(0, 0, oldPosition.width, oldPosition.height);
|
||||||
Thread.sleep(getSleepTime(200));
|
Thread.sleep(getSleepTime(200));
|
||||||
if (f.checkUnoFramePosition() == false)
|
if (!f.checkUnoFramePosition())
|
||||||
{
|
{
|
||||||
fail("Sizing error: Frame moved.");
|
fail("Sizing error: Frame moved.");
|
||||||
}
|
}
|
||||||
|
|
||||||
capturer.grabTwo(f.getClientArea());
|
capturer.grabTwo(f.getClientArea());
|
||||||
if (capturer.compare() == false)
|
if (!capturer.compare())
|
||||||
{
|
{
|
||||||
fail("Painting error: Move frame to a different position.");
|
fail("Painting error: Move frame to a different position.");
|
||||||
capturer.writeImages();
|
capturer.writeImages();
|
||||||
@@ -235,7 +234,7 @@ public class OOoBeanTest
|
|||||||
oldPosition = f.getBounds();
|
oldPosition = f.getBounds();
|
||||||
f.setBounds(0, curY, oldPosition.width, oldPosition.height);
|
f.setBounds(0, curY, oldPosition.width, oldPosition.height);
|
||||||
capturer.grabTwo(f.getClientArea());
|
capturer.grabTwo(f.getClientArea());
|
||||||
if (capturer.compare() == false)
|
if (!capturer.compare())
|
||||||
{
|
{
|
||||||
fail("Painting error: Move frame to a different position.");
|
fail("Painting error: Move frame to a different position.");
|
||||||
capturer.writeImages();
|
capturer.writeImages();
|
||||||
@@ -261,13 +260,13 @@ public class OOoBeanTest
|
|||||||
Thread.sleep(getSleepTime(200));
|
Thread.sleep(getSleepTime(200));
|
||||||
f.toFront();
|
f.toFront();
|
||||||
Thread.sleep(getSleepTime(200));
|
Thread.sleep(getSleepTime(200));
|
||||||
if (f.checkUnoFramePosition() == false)
|
if (!f.checkUnoFramePosition())
|
||||||
{
|
{
|
||||||
fail("Sizing error: Frame moved from back to front.");
|
fail("Sizing error: Frame moved from back to front.");
|
||||||
}
|
}
|
||||||
|
|
||||||
capturer.grabTwo(f.getClientArea());
|
capturer.grabTwo(f.getClientArea());
|
||||||
if (capturer.compare() == false)
|
if (!capturer.compare())
|
||||||
{
|
{
|
||||||
fail("Painting error: Move frame to back and to front.");
|
fail("Painting error: Move frame to back and to front.");
|
||||||
capturer.writeImages();
|
capturer.writeImages();
|
||||||
@@ -299,7 +298,7 @@ public class OOoBeanTest
|
|||||||
try
|
try
|
||||||
{
|
{
|
||||||
f = new WriterFrame(100, 100, 500, 300, true, connection.getComponentContext());
|
f = new WriterFrame(100, 100, 500, 300, true, connection.getComponentContext());
|
||||||
if (f.checkUnoFramePosition() == false)
|
if (!f.checkUnoFramePosition())
|
||||||
{
|
{
|
||||||
fail("Sizing error.");
|
fail("Sizing error.");
|
||||||
}
|
}
|
||||||
@@ -330,7 +329,7 @@ public class OOoBeanTest
|
|||||||
b.releaseSystemWindow();
|
b.releaseSystemWindow();
|
||||||
b.aquireSystemWindow();
|
b.aquireSystemWindow();
|
||||||
}
|
}
|
||||||
if (f.checkUnoFramePosition() == false)
|
if (!f.checkUnoFramePosition())
|
||||||
{
|
{
|
||||||
fail("Sizing error.");
|
fail("Sizing error.");
|
||||||
}
|
}
|
||||||
@@ -341,7 +340,7 @@ public class OOoBeanTest
|
|||||||
{
|
{
|
||||||
f.dispose();
|
f.dispose();
|
||||||
}
|
}
|
||||||
if (isWindows() == false)
|
if (!isWindows())
|
||||||
{
|
{
|
||||||
Thread.sleep(10000);
|
Thread.sleep(10000);
|
||||||
}
|
}
|
||||||
@@ -375,14 +374,14 @@ public class OOoBeanTest
|
|||||||
Thread.sleep(getSleepTime(200));
|
Thread.sleep(getSleepTime(200));
|
||||||
capturer.grabTwo();
|
capturer.grabTwo();
|
||||||
|
|
||||||
if (capturer.compare() == false)
|
if (!capturer.compare())
|
||||||
{
|
{
|
||||||
fail("Painting error: adding and removing OOoBean " +
|
fail("Painting error: adding and removing OOoBean " +
|
||||||
"repeatedly to java.lang.Frame.");
|
"repeatedly to java.lang.Frame.");
|
||||||
capturer.writeImages();
|
capturer.writeImages();
|
||||||
}
|
}
|
||||||
|
|
||||||
if (f.checkUnoFramePosition() == false)
|
if (!f.checkUnoFramePosition())
|
||||||
{
|
{
|
||||||
fail("Sizing error.");
|
fail("Sizing error.");
|
||||||
}
|
}
|
||||||
@@ -394,7 +393,7 @@ public class OOoBeanTest
|
|||||||
{
|
{
|
||||||
f.dispose();
|
f.dispose();
|
||||||
}
|
}
|
||||||
if (isWindows() == false)
|
if (!isWindows())
|
||||||
{
|
{
|
||||||
Thread.sleep(10000);
|
Thread.sleep(10000);
|
||||||
}
|
}
|
||||||
@@ -428,17 +427,13 @@ public class OOoBeanTest
|
|||||||
StringBuffer buf = new StringBuffer(1000);
|
StringBuffer buf = new StringBuffer(1000);
|
||||||
for (int i = 0; i < 1; i++)
|
for (int i = 0; i < 1; i++)
|
||||||
{
|
{
|
||||||
// Thread.sleep(1000);
|
|
||||||
bean.releaseSystemWindow();
|
bean.releaseSystemWindow();
|
||||||
frame.remove(bean);
|
frame.remove(bean);
|
||||||
// frame.validate();
|
|
||||||
// Thread.sleep(1000);
|
|
||||||
frame.add(bean, BorderLayout.CENTER);
|
frame.add(bean, BorderLayout.CENTER);
|
||||||
bean.aquireSystemWindow();
|
bean.aquireSystemWindow();
|
||||||
// frame.validate();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
if (isWindows() == false)
|
if (!isWindows())
|
||||||
{
|
{
|
||||||
Thread.sleep(5000);
|
Thread.sleep(5000);
|
||||||
}
|
}
|
||||||
@@ -532,7 +527,7 @@ public class OOoBeanTest
|
|||||||
Thread.sleep(1000);
|
Thread.sleep(1000);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (isWindows() == false)
|
if (!isWindows())
|
||||||
{
|
{
|
||||||
Thread.sleep(5000);
|
Thread.sleep(5000);
|
||||||
}
|
}
|
||||||
@@ -549,7 +544,7 @@ public class OOoBeanTest
|
|||||||
roby.keyRelease(KeyEvent.VK_H);
|
roby.keyRelease(KeyEvent.VK_H);
|
||||||
roby.waitForIdle();
|
roby.waitForIdle();
|
||||||
|
|
||||||
buf.append("h");
|
buf.append('h');
|
||||||
Thread.sleep(1000);
|
Thread.sleep(1000);
|
||||||
String s = getText(bean);
|
String s = getText(bean);
|
||||||
System.out.println(" getText: " + s);
|
System.out.println(" getText: " + s);
|
||||||
@@ -610,7 +605,7 @@ public class OOoBeanTest
|
|||||||
f.goToStart();
|
f.goToStart();
|
||||||
f.validate();
|
f.validate();
|
||||||
|
|
||||||
if (text.equals(f.getText()) == false)
|
if (!text.equals(f.getText()))
|
||||||
{
|
{
|
||||||
fail("Repeated loading of a document failed.");
|
fail("Repeated loading of a document failed.");
|
||||||
}
|
}
|
||||||
@@ -712,8 +707,7 @@ public class OOoBeanTest
|
|||||||
|
|
||||||
private XMultiServiceFactory getMSF()
|
private XMultiServiceFactory getMSF()
|
||||||
{
|
{
|
||||||
final XMultiServiceFactory xMSF1 = UnoRuntime.queryInterface(XMultiServiceFactory.class, connection.getComponentContext().getServiceManager());
|
return(UnoRuntime.queryInterface(XMultiServiceFactory.class, connection.getComponentContext().getServiceManager()));
|
||||||
return xMSF1;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// setup and close connections
|
// setup and close connections
|
||||||
|
@@ -70,7 +70,7 @@ public final class OfficeConnection {
|
|||||||
String envArg = Argument.get("env");
|
String envArg = Argument.get("env");
|
||||||
if (envArg != null) {
|
if (envArg != null) {
|
||||||
Map<String, String> env = pb.environment();
|
Map<String, String> env = pb.environment();
|
||||||
int i = envArg.indexOf("=");
|
int i = envArg.indexOf('=');
|
||||||
if (i == -1) {
|
if (i == -1) {
|
||||||
env.remove(envArg);
|
env.remove(envArg);
|
||||||
} else {
|
} else {
|
||||||
|
@@ -87,7 +87,7 @@ public class IniFile implements Enumeration
|
|||||||
|
|
||||||
public void insertFirstComment(String[] _aList)
|
public void insertFirstComment(String[] _aList)
|
||||||
{
|
{
|
||||||
if (m_aList.size() == 0)
|
if (m_aList.isEmpty())
|
||||||
{
|
{
|
||||||
// can only insert if there is nothing else already in the ini file
|
// can only insert if there is nothing else already in the ini file
|
||||||
for (int i = 0; i < _aList.length; i++)
|
for (int i = 0; i < _aList.length; i++)
|
||||||
@@ -224,7 +224,7 @@ public class IniFile implements Enumeration
|
|||||||
{
|
{
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
if (sFindSection.equals("[]"))
|
if (("[]").equals(sFindSection))
|
||||||
{
|
{
|
||||||
// special case, empty Section.
|
// special case, empty Section.
|
||||||
return i - 1;
|
return i - 1;
|
||||||
@@ -285,7 +285,7 @@ public class IniFile implements Enumeration
|
|||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
int nEqual = sLine.indexOf("=");
|
int nEqual = sLine.indexOf('=');
|
||||||
if (nEqual >= 0)
|
if (nEqual >= 0)
|
||||||
{
|
{
|
||||||
String sKey = toLowerIfNeed(sLine.substring(0, nEqual).trim());
|
String sKey = toLowerIfNeed(sLine.substring(0, nEqual).trim());
|
||||||
@@ -318,7 +318,7 @@ public class IniFile implements Enumeration
|
|||||||
return j;
|
return j;
|
||||||
}
|
}
|
||||||
|
|
||||||
int nEqual = sLine.indexOf("=");
|
int nEqual = sLine.indexOf('=');
|
||||||
if (nEqual >= 0)
|
if (nEqual >= 0)
|
||||||
{
|
{
|
||||||
String sKey = toLowerIfNeed(sLine.substring(0, nEqual).trim());
|
String sKey = toLowerIfNeed(sLine.substring(0, nEqual).trim());
|
||||||
@@ -338,12 +338,10 @@ public class IniFile implements Enumeration
|
|||||||
{
|
{
|
||||||
return "";
|
return "";
|
||||||
}
|
}
|
||||||
int nEqual = sLine.indexOf("=");
|
int nEqual = sLine.indexOf('=');
|
||||||
if (nEqual >= 0)
|
if (nEqual >= 0)
|
||||||
{
|
{
|
||||||
String sKey = sLine.substring(0, nEqual).trim();
|
return(sLine.substring(nEqual + 1).trim());
|
||||||
String sValue = sLine.substring(nEqual + 1).trim();
|
|
||||||
return sValue;
|
|
||||||
}
|
}
|
||||||
return "";
|
return "";
|
||||||
}
|
}
|
||||||
@@ -357,7 +355,6 @@ public class IniFile implements Enumeration
|
|||||||
// private String m_sOldKey;
|
// private String m_sOldKey;
|
||||||
public String getValue(String _sSection, String _sKey)
|
public String getValue(String _sSection, String _sKey)
|
||||||
{
|
{
|
||||||
String sValue = "";
|
|
||||||
int m_nCurrentPosition = findKey(_sSection, _sKey);
|
int m_nCurrentPosition = findKey(_sSection, _sKey);
|
||||||
if (m_nCurrentPosition == -1)
|
if (m_nCurrentPosition == -1)
|
||||||
{
|
{
|
||||||
@@ -365,22 +362,10 @@ public class IniFile implements Enumeration
|
|||||||
return "";
|
return "";
|
||||||
}
|
}
|
||||||
|
|
||||||
// m_sOldKey = _sKey;
|
return(getValue(m_nCurrentPosition));
|
||||||
sValue = getValue(m_nCurrentPosition);
|
|
||||||
|
|
||||||
return sValue;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// private String getNextValue()
|
|
||||||
// {
|
|
||||||
// if (m_nCurrentPosition >= 0)
|
|
||||||
// {
|
|
||||||
// ++m_nCurrentPosition;
|
|
||||||
// String sValue = getValue(m_nCurrentPosition);
|
|
||||||
// return sValue;
|
|
||||||
// }
|
|
||||||
// return "";
|
|
||||||
// }
|
|
||||||
/**
|
/**
|
||||||
* Returns the value at Section, Key converted to an integer
|
* Returns the value at Section, Key converted to an integer
|
||||||
* Check with hasValue(Section, Key) to check before you get into trouble.
|
* Check with hasValue(Section, Key) to check before you get into trouble.
|
||||||
@@ -397,7 +382,7 @@ public class IniFile implements Enumeration
|
|||||||
{
|
{
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
nValue = Integer.valueOf(sValue).intValue();
|
nValue = Integer.parseInt(sValue);
|
||||||
}
|
}
|
||||||
catch (java.lang.NumberFormatException e)
|
catch (java.lang.NumberFormatException e)
|
||||||
{
|
{
|
||||||
@@ -424,7 +409,7 @@ public class IniFile implements Enumeration
|
|||||||
// TODO: make private
|
// TODO: make private
|
||||||
private void store()
|
private void store()
|
||||||
{
|
{
|
||||||
if (m_bListContainUnsavedChanges == false)
|
if (!m_bListContainUnsavedChanges)
|
||||||
{
|
{
|
||||||
// nothing has changed, so no need to store
|
// nothing has changed, so no need to store
|
||||||
return;
|
return;
|
||||||
@@ -537,59 +522,7 @@ public class IniFile implements Enumeration
|
|||||||
m_bListContainUnsavedChanges = true;
|
m_bListContainUnsavedChanges = true;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
// -----------------------------------------------------------------------------
|
|
||||||
// String replaceEvaluatedValue(String _sSection, String _sValue)
|
|
||||||
// {
|
|
||||||
// String sValue = _sValue;
|
|
||||||
// int nIndex = 0;
|
|
||||||
// while (( nIndex = sValue.indexOf("$(", nIndex)) >= 0)
|
|
||||||
// {
|
|
||||||
// int nNextIndex = sValue.indexOf(")", nIndex);
|
|
||||||
// if (nNextIndex >= 0)
|
|
||||||
// {
|
|
||||||
// String sKey = sValue.substring(nIndex + 2, nNextIndex);
|
|
||||||
// String sNewValue = getValue(_sSection, sKey);
|
|
||||||
// if (sNewValue != null && sNewValue.length() > 0)
|
|
||||||
// {
|
|
||||||
// String sRegexpKey = "\\$\\(" + sKey + "\\)";
|
|
||||||
// sValue = sValue.replaceAll(sRegexpKey, sNewValue);
|
|
||||||
// }
|
|
||||||
// nIndex = nNextIndex;
|
|
||||||
// }
|
|
||||||
// else
|
|
||||||
// {
|
|
||||||
// nIndex += 2;
|
|
||||||
// }
|
|
||||||
// }
|
|
||||||
// return sValue;
|
|
||||||
// }
|
|
||||||
// -----------------------------------------------------------------------------
|
|
||||||
|
|
||||||
// public String getLocalEvaluatedValue(String _sSection, String _sKey)
|
|
||||||
// {
|
|
||||||
// String sValue = getValue(_sSection, _sKey);
|
|
||||||
// sValue = replaceEvaluatedValue(_sSection, sValue);
|
|
||||||
// return sValue;
|
|
||||||
// }
|
|
||||||
|
|
||||||
// -----------------------------------------------------------------------------
|
|
||||||
|
|
||||||
// this is a special behaviour.
|
|
||||||
// public String getGlobalLocalEvaluatedValue(String _sSection, String _sKey)
|
|
||||||
// {
|
|
||||||
// String sGlobalValue = getKey("global", _sKey);
|
|
||||||
// String sLocalValue = getKey(_sSection, _sKey);
|
|
||||||
// if (sLocalValue.length() == 0)
|
|
||||||
// {
|
|
||||||
// sGlobalValue = replaceEvaluatedKey(_sSection, sGlobalValue);
|
|
||||||
// sGlobalValue = replaceEvaluatedKey("global", sGlobalValue);
|
|
||||||
// return sGlobalValue;
|
|
||||||
// }
|
|
||||||
// sLocalValue = replaceEvaluatedKey(_sSection, sLocalValue);
|
|
||||||
// sLocalValue = replaceEvaluatedKey("global", sLocalValue);
|
|
||||||
//
|
|
||||||
// return sLocalValue;
|
|
||||||
// }
|
|
||||||
public void removeSection(String _sSectionToRemove)
|
public void removeSection(String _sSectionToRemove)
|
||||||
{
|
{
|
||||||
// first, search for the name
|
// first, search for the name
|
||||||
|
Reference in New Issue
Block a user