[Libreoffice-commits] core.git: nlpsolver/src

LeMoyne Castle lemoyne.castle at gmail.com
Mon Feb 16 22:21:46 PST 2015


 nlpsolver/src/com/sun/star/comp/Calc/NLPSolver/BaseNLPSolver.java |   19 ++++------
 nlpsolver/src/com/sun/star/comp/Calc/NLPSolver/PropertyInfo.java  |    7 ++-
 nlpsolver/src/com/sun/star/comp/Calc/NLPSolver/Registration.java  |    4 --
 3 files changed, 13 insertions(+), 17 deletions(-)

New commits:
commit c290998df667bd2a8a12379642f79d09eca471c3
Author: LeMoyne Castle <lemoyne.castle at gmail.com>
Date:   Sun Feb 15 09:05:46 2015 -0700

    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 <noelgrandin at gmail.com>
    Tested-by: Noel Grandin <noelgrandin at gmail.com>

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 30b8392..73da46b 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);
     }
 
-    // <editor-fold defaultstate="collapsed" desc="Helper functions">
+        // 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 2371f0e..f1a7a47 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<PropType> {
 
     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 02a3d3e..157f496 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() {}


More information about the Libreoffice-commits mailing list