scripting: avoid a possible NullPointerException

Change-Id: I90589bc042f4b88b700e9f3c167c460c3cff043c
Reviewed-on: https://gerrit.libreoffice.org/11311
Reviewed-by: Noel Grandin <noelgrandin@gmail.com>
Tested-by: Noel Grandin <noelgrandin@gmail.com>
This commit is contained in:
rbuj
2014-09-06 21:15:33 +02:00
committed by Noel Grandin
parent d44ace5d50
commit b50fedfc34

View File

@@ -64,47 +64,44 @@ public class ScriptBrowseNode extends PropertySet
this.provider = provider;
this.name = name;
this.parent = parent;
ScriptMetaData data = null;
XSimpleFileAccess xSFA = null;
XComponentContext xCtx = provider.getScriptingContext().getComponentContext();
XMultiComponentFactory xFac = xCtx.getServiceManager();
try
{
data = (ScriptMetaData)parent.getByName( name );
xSFA = UnoRuntime.queryInterface( XSimpleFileAccess.class,
ScriptMetaData data = (ScriptMetaData)parent.getByName( name );
XSimpleFileAccess xSFA = UnoRuntime.queryInterface( XSimpleFileAccess.class,
xFac.createInstanceWithContext(
"com.sun.star.ucb.SimpleFileAccess",
xCtx ) );
}
if (provider.hasScriptEditor())
{
this.editable = true;
try
{
if (!parent.isUnoPkg()
&& !xSFA.isReadOnly(parent.getPathToParcel()))
{
this.deletable = true;
this.renamable = true;
}
}
// TODO propagate errors
catch (Exception e)
{
LogUtils.DEBUG("Caught exception in creation of ScriptBrowseNode");
LogUtils.DEBUG(LogUtils.getTrace(e));
}
}
}
// TODO fix exception types to be caught here, should we rethrow?
catch ( Exception e )
{
LogUtils.DEBUG("** caught exception getting script data for " + name + " ->" + e.toString() );
}
if (provider.hasScriptEditor())
{
this.editable = true;
try
{
if ( !parent.isUnoPkg() &&
!xSFA.isReadOnly( parent.getPathToParcel() ) )
{
this.deletable = true;
this.renamable = true;
}
}
// TODO propagate errors
catch ( Exception e )
{
LogUtils.DEBUG("Caught exception in creation of ScriptBrowseNode");
LogUtils.DEBUG( LogUtils.getTrace(e));
}
}
registerProperty("Deletable", new Type(boolean.class),
(short)0, "deletable");
registerProperty("Editable", new Type(boolean.class),