From c290998df667bd2a8a12379642f79d09eca471c3 Mon Sep 17 00:00:00 2001 From: LeMoyne Castle Date: Sun, 15 Feb 2015 09:05:46 -0700 Subject: 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/14499 Reviewed-by: Noel Grandin Tested-by: Noel Grandin --- .../sun/star/comp/Calc/NLPSolver/BaseNLPSolver.java | 19 +++++++++---------- .../sun/star/comp/Calc/NLPSolver/PropertyInfo.java | 7 ++++--- .../sun/star/comp/Calc/NLPSolver/Registration.java | 4 ---- 3 files changed, 13 insertions(+), 17 deletions(-) (limited to 'nlpsolver/src') diff --git a/nlpsolver/src/com/sun/star/comp/Calc/NLPSolver/BaseNLPSolver.java b/nlpsolver/src/com/sun/star/comp/Calc/NLPSolver/BaseNLPSolver.java index 30b83922f028..73da46b39567 100644 --- a/nlpsolver/src/com/sun/star/comp/Calc/NLPSolver/BaseNLPSolver.java +++ b/nlpsolver/src/com/sun/star/comp/Calc/NLPSolver/BaseNLPSolver.java @@ -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 final ResourceManager resourceManager; + private CellAddress m_objective; + protected CellAddress[] m_variables; + protected SolverConstraint[] m_constraints; + public BaseNLPSolver(XComponentContext xContext, String name) { m_xContext = xContext; 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(); try { @@ -117,9 +125,6 @@ public abstract class BaseNLPSolver extends WeakBase private XSpreadsheetDocument m_document; private XModel m_xModel; protected XReschedule m_xReschedule; - private CellAddress m_objective; - protected CellAddress[] m_variables; - protected SolverConstraint[] m_constraints; protected ExtSolverConstraint[] m_extConstraints; protected boolean m_maximize; @@ -155,9 +160,6 @@ public abstract class BaseNLPSolver extends WeakBase } public CellAddress[] getVariables() { - if (m_variables == null) - return new CellAddress[0]; //Workaround for basic scripts; otherwise - //setting the Variables property fails. return m_variables; } @@ -296,9 +298,6 @@ public abstract class BaseNLPSolver extends WeakBase } public SolverConstraint[] getConstraints() { - if (m_constraints == null) - return new SolverConstraint[0]; //Workaround for basic scripts; otherwise - //setting the Constraints property fails. return m_constraints; } @@ -463,7 +462,7 @@ public abstract class BaseNLPSolver extends WeakBase return m_propertyMap.containsKey(property); } - // + // Helper functions private void lockDocument(boolean lock) { if (lock) m_xModel.lockControllers(); diff --git a/nlpsolver/src/com/sun/star/comp/Calc/NLPSolver/PropertyInfo.java b/nlpsolver/src/com/sun/star/comp/Calc/NLPSolver/PropertyInfo.java index 2371f0eb79e6..f1a7a4714f05 100644 --- a/nlpsolver/src/com/sun/star/comp/Calc/NLPSolver/PropertyInfo.java +++ b/nlpsolver/src/com/sun/star/comp/Calc/NLPSolver/PropertyInfo.java @@ -89,10 +89,11 @@ public class PropertyInfo { public void localize(ResourceManager resourceManager) { try { - m_description = resourceManager.getLocalizedString("Properties." + m_property.Name); - System.out.println("Localised description to " + m_description); + m_description = resourceManager.getLocalizedString("Properties." + + m_property.Name); } 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); } } diff --git a/nlpsolver/src/com/sun/star/comp/Calc/NLPSolver/Registration.java b/nlpsolver/src/com/sun/star/comp/Calc/NLPSolver/Registration.java index 02a3d3ea052d..157f4963f9e0 100644 --- a/nlpsolver/src/com/sun/star/comp/Calc/NLPSolver/Registration.java +++ b/nlpsolver/src/com/sun/star/comp/Calc/NLPSolver/Registration.java @@ -23,8 +23,6 @@ public final class Registration { { XSingleComponentFactory xFactory = null; - System.out.println("Get component '" + sImplementationName + "'"); - if ( sImplementationName.equals( "com.sun.star.comp.Calc.NLPSolver.DEPSSolverImpl" ) ) xFactory = Factory.createComponentFactory( com.sun.star.comp.Calc.NLPSolver.DEPSSolverImpl.class, m_serviceNames ); @@ -32,8 +30,6 @@ public final class Registration { xFactory = Factory.createComponentFactory( com.sun.star.comp.Calc.NLPSolver.SCOSolverImpl.class, m_serviceNames ); - System.out.println("Return factory " + xFactory); - return xFactory; } private Registration() {} -- cgit