Kaydet (Commit) c290998d authored tarafından LeMoyne Castle's avatar LeMoyne Castle Kaydeden (comit) Noel Grandin

tdf#87074 null-ref error from NLPSolver in Basic

Initialize java class member objects exposed as
XSolver properties: no default construction in java.
Fixes issue for both DEPS and SCO solvers.
Also removed info level console prints.

Change-Id: I6762c5cca978072ce20b1f69a6b523f53364107d
Reviewed-on: https://gerrit.libreoffice.org/14499Reviewed-by: 's avatarNoel Grandin <noelgrandin@gmail.com>
Tested-by: 's avatarNoel Grandin <noelgrandin@gmail.com>
üst a8e6f0be
...@@ -78,9 +78,17 @@ public abstract class BaseNLPSolver extends WeakBase ...@@ -78,9 +78,17 @@ public abstract class BaseNLPSolver extends WeakBase
private com.sun.star.lang.Locale m_locale = new com.sun.star.lang.Locale(); private com.sun.star.lang.Locale m_locale = new com.sun.star.lang.Locale();
private final ResourceManager resourceManager; private final ResourceManager resourceManager;
private CellAddress m_objective;
protected CellAddress[] m_variables;
protected SolverConstraint[] m_constraints;
public BaseNLPSolver(XComponentContext xContext, String name) { public BaseNLPSolver(XComponentContext xContext, String name) {
m_xContext = xContext; m_xContext = xContext;
m_name = name; m_name = name;
// init members exposed as XSolver properties thru uno bridge
m_objective = new CellAddress();
m_variables = new CellAddress[0];
m_constraints = new SolverConstraint[0];
XMultiComponentFactory componentFactory = xContext.getServiceManager(); XMultiComponentFactory componentFactory = xContext.getServiceManager();
try { try {
...@@ -117,9 +125,6 @@ public abstract class BaseNLPSolver extends WeakBase ...@@ -117,9 +125,6 @@ public abstract class BaseNLPSolver extends WeakBase
private XSpreadsheetDocument m_document; private XSpreadsheetDocument m_document;
private XModel m_xModel; private XModel m_xModel;
protected XReschedule m_xReschedule; protected XReschedule m_xReschedule;
private CellAddress m_objective;
protected CellAddress[] m_variables;
protected SolverConstraint[] m_constraints;
protected ExtSolverConstraint[] m_extConstraints; protected ExtSolverConstraint[] m_extConstraints;
protected boolean m_maximize; protected boolean m_maximize;
...@@ -155,9 +160,6 @@ public abstract class BaseNLPSolver extends WeakBase ...@@ -155,9 +160,6 @@ public abstract class BaseNLPSolver extends WeakBase
} }
public CellAddress[] getVariables() { public CellAddress[] getVariables() {
if (m_variables == null)
return new CellAddress[0]; //Workaround for basic scripts; otherwise
//setting the Variables property fails.
return m_variables; return m_variables;
} }
...@@ -296,9 +298,6 @@ public abstract class BaseNLPSolver extends WeakBase ...@@ -296,9 +298,6 @@ public abstract class BaseNLPSolver extends WeakBase
} }
public SolverConstraint[] getConstraints() { public SolverConstraint[] getConstraints() {
if (m_constraints == null)
return new SolverConstraint[0]; //Workaround for basic scripts; otherwise
//setting the Constraints property fails.
return m_constraints; return m_constraints;
} }
...@@ -463,7 +462,7 @@ public abstract class BaseNLPSolver extends WeakBase ...@@ -463,7 +462,7 @@ public abstract class BaseNLPSolver extends WeakBase
return m_propertyMap.containsKey(property); return m_propertyMap.containsKey(property);
} }
// <editor-fold defaultstate="collapsed" desc="Helper functions"> // Helper functions
private void lockDocument(boolean lock) { private void lockDocument(boolean lock) {
if (lock) if (lock)
m_xModel.lockControllers(); m_xModel.lockControllers();
......
...@@ -89,10 +89,11 @@ public class PropertyInfo<PropType> { ...@@ -89,10 +89,11 @@ public class PropertyInfo<PropType> {
public void localize(ResourceManager resourceManager) { public void localize(ResourceManager resourceManager) {
try { try {
m_description = resourceManager.getLocalizedString("Properties." + m_property.Name); m_description = resourceManager.getLocalizedString("Properties."
System.out.println("Localised description to " + m_description); + m_property.Name);
} catch (com.sun.star.resource.MissingResourceException ex) { } catch (com.sun.star.resource.MissingResourceException ex) {
System.out.println("No properties file !"); System.out.println("Can't localize. Resource missing for property: "
+ m_property.Name);
} }
} }
......
...@@ -23,8 +23,6 @@ public final class Registration { ...@@ -23,8 +23,6 @@ public final class Registration {
{ {
XSingleComponentFactory xFactory = null; XSingleComponentFactory xFactory = null;
System.out.println("Get component '" + sImplementationName + "'");
if ( sImplementationName.equals( "com.sun.star.comp.Calc.NLPSolver.DEPSSolverImpl" ) ) if ( sImplementationName.equals( "com.sun.star.comp.Calc.NLPSolver.DEPSSolverImpl" ) )
xFactory = Factory.createComponentFactory( com.sun.star.comp.Calc.NLPSolver.DEPSSolverImpl.class, xFactory = Factory.createComponentFactory( com.sun.star.comp.Calc.NLPSolver.DEPSSolverImpl.class,
m_serviceNames ); m_serviceNames );
...@@ -32,8 +30,6 @@ public final class Registration { ...@@ -32,8 +30,6 @@ public final class Registration {
xFactory = Factory.createComponentFactory( com.sun.star.comp.Calc.NLPSolver.SCOSolverImpl.class, xFactory = Factory.createComponentFactory( com.sun.star.comp.Calc.NLPSolver.SCOSolverImpl.class,
m_serviceNames ); m_serviceNames );
System.out.println("Return factory " + xFactory);
return xFactory; return xFactory;
} }
private Registration() {} private Registration() {}
......
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