scripting: the assigned value is never used
Change-Id: I430da93e985291300ac5fdaccc7f907535771a07 Reviewed-on: https://gerrit.libreoffice.org/11287 Reviewed-by: Thomas Arnhold <thomas@arnhold.org> Tested-by: Thomas Arnhold <thomas@arnhold.org>
This commit is contained in:
@@ -459,8 +459,6 @@ public class ParcelContainer implements XNameAccess
|
||||
public Parcel loadParcel( String parcelUrl ) throws com.sun.star.lang.WrappedTargetException, com.sun.star.lang.IllegalArgumentException
|
||||
{
|
||||
|
||||
String name = null;
|
||||
|
||||
String parcelDescUrl = PathUtils.make_url( parcelUrl, ParcelDescriptor.PARCEL_DESCRIPTOR_NAME );
|
||||
Parcel parcel = null;
|
||||
|
||||
@@ -494,7 +492,7 @@ public class ParcelContainer implements XNameAccess
|
||||
LogUtils.DEBUG("Processing " + parcelDescUrl + " closed " );
|
||||
|
||||
int indexOfSlash = parcelUrl.lastIndexOf("/");
|
||||
name = parcelUrl.substring( indexOfSlash + 1 );
|
||||
String name = parcelUrl.substring( indexOfSlash + 1 );
|
||||
|
||||
parcel = new Parcel( m_xSFA, this, pd, name );
|
||||
|
||||
@@ -588,20 +586,17 @@ public class ParcelContainer implements XNameAccess
|
||||
// removes but doesn't physically delele parcel from container
|
||||
public boolean removeParcel(String name) throws com.sun.star.container.NoSuchElementException, com.sun.star.lang.WrappedTargetException
|
||||
{
|
||||
boolean result = false;
|
||||
Parcel p = (Parcel)getByName( name );
|
||||
if ( p == null )
|
||||
{
|
||||
throw new com.sun.star.container.NoSuchElementException("No parcel named " + name );
|
||||
}
|
||||
|
||||
result = parcels.remove( p );
|
||||
return result;
|
||||
return parcels.remove( p );
|
||||
}
|
||||
public boolean deleteParcel(String name) throws com.sun.star.container.NoSuchElementException, com.sun.star.lang.WrappedTargetException
|
||||
{
|
||||
LogUtils.DEBUG( "deleteParcel for containerURL " + containerUrl + " name = " + name + " Langueg = " + language );
|
||||
boolean result = false;
|
||||
|
||||
Parcel p = (Parcel)getByName( name );
|
||||
if ( p == null )
|
||||
@@ -620,18 +615,15 @@ public class ParcelContainer implements XNameAccess
|
||||
throw new com.sun.star.lang.WrappedTargetException( e.toString() );
|
||||
}
|
||||
|
||||
result = parcels.remove( p );
|
||||
return result;
|
||||
return parcels.remove( p );
|
||||
}
|
||||
|
||||
public String getLanguage() { return language; }
|
||||
|
||||
public ScriptMetaData findScript( ParsedScriptUri parsedUri ) throws com.sun.star.container.NoSuchElementException, com.sun.star.lang.WrappedTargetException
|
||||
{
|
||||
ScriptMetaData scriptData = null;
|
||||
Parcel p = null;
|
||||
p = (Parcel)getByName( parsedUri.parcel);
|
||||
scriptData = (ScriptMetaData)p.getByName( parsedUri.function);
|
||||
Parcel p = (Parcel)getByName( parsedUri.parcel);
|
||||
ScriptMetaData scriptData = (ScriptMetaData)p.getByName( parsedUri.function);
|
||||
LogUtils.DEBUG("** found script data for " + parsedUri.function + " script is " + scriptData );
|
||||
return scriptData;
|
||||
|
||||
|
@@ -288,14 +288,12 @@ public class ScriptMetaData extends ScriptEntry {
|
||||
}
|
||||
private URL createURL( String path ) throws java.net.MalformedURLException
|
||||
{
|
||||
URL url = null;
|
||||
int indexOfColon = path.indexOf(":");
|
||||
String scheme = path.substring( 0, indexOfColon );
|
||||
UCBStreamHandler handler = new UCBStreamHandler( scheme, parent.m_xSFA);
|
||||
|
||||
path += UCBStreamHandler.separator;
|
||||
url = new URL(null, path, handler);
|
||||
return url;
|
||||
return new URL(null, path, handler);
|
||||
}
|
||||
|
||||
// TODO should decide whether this should throw or not
|
||||
@@ -313,8 +311,7 @@ public class ScriptMetaData extends ScriptEntry {
|
||||
InputStream in = sourceUrl.openStream();
|
||||
|
||||
byte[] contents = new byte[1024];
|
||||
int len = 0;
|
||||
|
||||
int len;
|
||||
while ((len = in.read(contents, 0, 1024)) != -1) {
|
||||
buf.append(new String(contents, 0, len));
|
||||
}
|
||||
@@ -379,13 +376,9 @@ public class ScriptMetaData extends ScriptEntry {
|
||||
|
||||
public URL getSourceURL() throws java.net.MalformedURLException
|
||||
{
|
||||
String sUrl = null;
|
||||
URL scriptURL = null;
|
||||
|
||||
sUrl = getParcelLocation();
|
||||
String sUrl = getParcelLocation();
|
||||
sUrl = PathUtils.make_url( sUrl, getLanguageName() );
|
||||
LogUtils.DEBUG("Creating script url for " + sUrl );
|
||||
scriptURL = createURL( sUrl );
|
||||
return scriptURL;
|
||||
return createURL( sUrl );
|
||||
}
|
||||
}
|
||||
|
@@ -140,10 +140,9 @@ public class UnoPkgContainer extends ParcelContainer
|
||||
private void init() throws com.sun.star.lang.IllegalArgumentException
|
||||
{
|
||||
LogUtils.DEBUG("getting container for " + containerUrl );
|
||||
DeployedUnoPackagesDB db = null;
|
||||
try
|
||||
{
|
||||
db = getUnoPackagesDB();
|
||||
DeployedUnoPackagesDB db = getUnoPackagesDB();
|
||||
if ( db != null )
|
||||
{
|
||||
String[] packages = db.getDeployedPackages( language );
|
||||
@@ -201,9 +200,7 @@ public class UnoPkgContainer extends ParcelContainer
|
||||
throw new com.sun.star.lang.WrappedTargetException( "Failed to resolve script " , null, new com.sun.star.lang.IllegalArgumentException( "Cannot resolve script location for script = " + functionName ) );
|
||||
}
|
||||
|
||||
scriptData = pc.findScript( psu );
|
||||
return scriptData;
|
||||
|
||||
return pc.findScript( psu );
|
||||
}
|
||||
|
||||
private DeployedUnoPackagesDB getUnoPackagesDB() throws com.sun.star.lang.WrappedTargetException
|
||||
@@ -317,9 +314,7 @@ public class UnoPkgContainer extends ParcelContainer
|
||||
public void processUnoPackage( XPackage dPackage, String language ) throws com.sun.star.lang.IllegalArgumentException, com.sun.star.lang.WrappedTargetException, com.sun.star.container.ElementExistException
|
||||
{
|
||||
LogUtils.DEBUG("** in processUnoPackage " );
|
||||
String uri = null;
|
||||
DeployedUnoPackagesDB db = null;
|
||||
uri = dPackage.getURL();
|
||||
String uri = dPackage.getURL();
|
||||
|
||||
if ( !uri.endsWith( "/" ) )
|
||||
{
|
||||
@@ -340,7 +335,7 @@ public class UnoPkgContainer extends ParcelContainer
|
||||
|
||||
processUnoPackage( uri, language );
|
||||
|
||||
db = getUnoPackagesDB();
|
||||
DeployedUnoPackagesDB db = getUnoPackagesDB();
|
||||
if ( db == null )
|
||||
{
|
||||
try
|
||||
|
@@ -58,12 +58,11 @@ public class XMLParserFactory {
|
||||
|
||||
public Document parse(InputStream inputStream) throws IOException {
|
||||
Document result = null;
|
||||
InputSource is = null;
|
||||
|
||||
try {
|
||||
DocumentBuilder builder = factory.newDocumentBuilder();
|
||||
|
||||
is = new InputSource(inputStream);
|
||||
InputSource is = new InputSource(inputStream);
|
||||
|
||||
if (officedtdurl != null) {
|
||||
is.setSystemId(officedtdurl);
|
||||
@@ -126,8 +125,7 @@ public class XMLParserFactory {
|
||||
Object formatterObject = formatterClass.newInstance();
|
||||
|
||||
// improve output readability using the OutputFormat class
|
||||
Method method = null;
|
||||
method = formatterClass.getMethod("setMethod",
|
||||
Method method = formatterClass.getMethod("setMethod",
|
||||
new Class[] {String.class});
|
||||
method.invoke(formatterObject, new Object[] {"xml"});
|
||||
method = formatterClass.getMethod("setIndenting",
|
||||
|
@@ -187,10 +187,9 @@ public class UCBStreamHandler extends URLStreamHandler {
|
||||
private InputStream getFileStreamFromJarStream(String file, InputStream is)
|
||||
throws IOException
|
||||
{
|
||||
ZipInputStream zis = null;
|
||||
ZipEntry entry = null;
|
||||
|
||||
zis = new ZipInputStream(is);
|
||||
ZipInputStream zis = new ZipInputStream(is);
|
||||
|
||||
while (zis.available() != 0) {
|
||||
entry = zis.getNextEntry();
|
||||
@@ -214,7 +213,6 @@ public class UCBStreamHandler extends URLStreamHandler {
|
||||
LogUtils.DEBUG("sfa appeared to read file " );
|
||||
byte[][] inputBytes = new byte[1][];
|
||||
|
||||
int ln = 0;
|
||||
int sz = m_xSimpleFileAccess.getSize(path);
|
||||
// TODO don't depend on result of available() or size()
|
||||
// just read stream 'till complete
|
||||
@@ -229,7 +227,7 @@ public class UCBStreamHandler extends URLStreamHandler {
|
||||
LogUtils.DEBUG("available = " + xInputStream.available() );
|
||||
inputBytes[0] = new byte[sz];
|
||||
|
||||
ln = xInputStream.readBytes(inputBytes, sz);
|
||||
int ln = xInputStream.readBytes(inputBytes, sz);
|
||||
|
||||
if (ln != sz) {
|
||||
throw new IOException(
|
||||
|
@@ -38,7 +38,7 @@ public class XInputStreamImpl implements XInputStream
|
||||
|
||||
try
|
||||
{
|
||||
int bytesRead = 0;
|
||||
int bytesRead;
|
||||
while ( ( bytesRead = is.read( aData[ 0 ], totalBytesRead, nBytesToRead ) ) > 0 && ( totalBytesRead < nBytesToRead ) )
|
||||
{
|
||||
totalBytesRead += bytesRead;
|
||||
|
@@ -76,12 +76,9 @@ public class ScriptContext extends PropertySet implements XScriptContext
|
||||
|
||||
try {
|
||||
|
||||
Object xInterface = null;
|
||||
XDesktop xDesktop = null;
|
||||
|
||||
xInterface = xMCF.createInstanceWithContext(
|
||||
Object xInterface = xMCF.createInstanceWithContext(
|
||||
"com.sun.star.frame.Desktop", xCtxt);
|
||||
xDesktop = UnoRuntime.queryInterface(XDesktop.class, xInterface);
|
||||
XDesktop xDesktop = UnoRuntime.queryInterface(XDesktop.class, xInterface);
|
||||
if ( xModel != null )
|
||||
{
|
||||
sc = new ScriptContext(xCtxt, xDesktop, xModel, xInvocContext);
|
||||
|
@@ -73,8 +73,7 @@ public class ScriptEditorForBeanShell
|
||||
InputStream in = url.openStream();
|
||||
StringBuffer buf = new StringBuffer();
|
||||
byte[] b = new byte[1024];
|
||||
int len = 0;
|
||||
|
||||
int len;
|
||||
while ((len = in.read(b)) != -1) {
|
||||
buf.append(new String(b, 0, len));
|
||||
}
|
||||
|
@@ -228,8 +228,7 @@ class ScriptImpl implements XScript
|
||||
}
|
||||
|
||||
try {
|
||||
String source = null;
|
||||
Object result = null;
|
||||
Object result;
|
||||
|
||||
ScriptEditorForBeanShell editor =
|
||||
ScriptEditorForBeanShell.getEditor(
|
||||
@@ -247,7 +246,7 @@ class ScriptImpl implements XScript
|
||||
}
|
||||
|
||||
metaData.loadSource();
|
||||
source = metaData.getSource();
|
||||
String source = metaData.getSource();
|
||||
|
||||
if ( source == null || source.length() == 0 )
|
||||
{
|
||||
@@ -286,11 +285,10 @@ class ScriptImpl implements XScript
|
||||
}
|
||||
private void raiseEditor( int lineNum )
|
||||
{
|
||||
ScriptEditorForBeanShell editor = null;
|
||||
try
|
||||
{
|
||||
URL sourceUrl = metaData.getSourceURL();
|
||||
editor = ScriptEditorForBeanShell.getEditor( sourceUrl );
|
||||
ScriptEditorForBeanShell editor = ScriptEditorForBeanShell.getEditor( sourceUrl );
|
||||
if ( editor == null )
|
||||
{
|
||||
editor = ScriptEditorForBeanShell.getEditor();
|
||||
|
@@ -39,8 +39,7 @@ public class ScriptSourceModel {
|
||||
InputStream in = file.openStream();
|
||||
|
||||
byte[] contents = new byte[1024];
|
||||
int len = 0;
|
||||
|
||||
int len;
|
||||
while ((len = in.read(contents, 0, 1024)) != -1) {
|
||||
buf.append(new String(contents, 0, len));
|
||||
}
|
||||
@@ -78,7 +77,6 @@ public class ScriptSourceModel {
|
||||
public Object execute(final XScriptContext context, ClassLoader cl )
|
||||
throws Exception
|
||||
{
|
||||
Object result = null;
|
||||
if ( cl != null )
|
||||
{
|
||||
// sets this threads class loader
|
||||
@@ -110,6 +108,7 @@ public class ScriptSourceModel {
|
||||
interpreter.set("XSCRIPTCONTEXT", context);
|
||||
interpreter.set("ARGUMENTS", new Object[0]);
|
||||
|
||||
Object result;
|
||||
if (view.isModified()) {
|
||||
result = interpreter.eval(view.getText());
|
||||
}
|
||||
|
@@ -57,12 +57,10 @@ public class ScriptProviderForJava
|
||||
throws com.sun.star.uno.RuntimeException,
|
||||
ScriptFrameworkErrorException
|
||||
{
|
||||
ScriptMetaData scriptData = null;
|
||||
scriptData = getScriptData( scriptURI );
|
||||
ScriptImpl script = null;
|
||||
ScriptMetaData scriptData = getScriptData( scriptURI );
|
||||
try
|
||||
{
|
||||
script = new ScriptImpl( m_xContext, m_resolutionPolicy, scriptData, m_xModel, m_xInvocContext );
|
||||
ScriptImpl script = new ScriptImpl( m_xContext, m_resolutionPolicy, scriptData, m_xModel, m_xInvocContext );
|
||||
return script;
|
||||
}
|
||||
catch ( com.sun.star.uno.RuntimeException re )
|
||||
|
@@ -51,7 +51,6 @@ public class StrictResolver implements Resolver
|
||||
throws NoSuchMethodException
|
||||
{
|
||||
Method m = null;
|
||||
ScriptProxy sp = null;
|
||||
|
||||
LogUtils.DEBUG( "StrictResolver.getProxy() for: " + sd.toString() );
|
||||
|
||||
@@ -70,7 +69,7 @@ public class StrictResolver implements Resolver
|
||||
+ sd.getMethodName() + ":" + e.getMessage() );
|
||||
}
|
||||
|
||||
sp = new ScriptProxy( m );
|
||||
ScriptProxy sp = new ScriptProxy( m );
|
||||
|
||||
int modifiers = m.getModifiers();
|
||||
if ( !Modifier.isStatic( modifiers ) )
|
||||
|
@@ -61,8 +61,7 @@ public class ScriptEditorForJavaScript implements ScriptEditor
|
||||
InputStream in = url.openStream();
|
||||
StringBuffer buf = new StringBuffer();
|
||||
byte[] b = new byte[1024];
|
||||
int len = 0;
|
||||
|
||||
int len;
|
||||
while ((len = in.read(b)) != -1) {
|
||||
buf.append(new String(b, 0, len));
|
||||
}
|
||||
|
@@ -205,7 +205,6 @@ class ScriptImpl implements XScript
|
||||
{
|
||||
String editorURL = sourceUrl.toString();
|
||||
Object result = null;
|
||||
String source = null;
|
||||
ScriptEditorForJavaScript editor =
|
||||
ScriptEditorForJavaScript.getEditor(
|
||||
metaData.getSourceURL() );
|
||||
@@ -224,6 +223,7 @@ class ScriptImpl implements XScript
|
||||
|
||||
}
|
||||
|
||||
String source;
|
||||
if (editor != null && editor.isModified())
|
||||
{
|
||||
LogUtils.DEBUG("GOT A MODIFIED SOURCE");
|
||||
@@ -316,11 +316,10 @@ class ScriptImpl implements XScript
|
||||
|
||||
private void raiseEditor( int lineNum )
|
||||
{
|
||||
ScriptEditorForJavaScript editor = null;
|
||||
try
|
||||
{
|
||||
URL sourceUrl = metaData.getSourceURL();
|
||||
editor = ScriptEditorForJavaScript.getEditor( sourceUrl );
|
||||
ScriptEditorForJavaScript editor = ScriptEditorForJavaScript.getEditor( sourceUrl );
|
||||
if ( editor == null )
|
||||
{
|
||||
editor = ScriptEditorForJavaScript.getEditor();
|
||||
|
Reference in New Issue
Block a user