/* package */
 public WorkbookEvaluator(EvaluationWorkbook workbook, IEvaluationListener evaluationListener)
 {
     _workbook = workbook;
     _evaluationListener = evaluationListener;
     _cache = new EvaluationCache(evaluationListener);
     _sheetIndexesBySheet = new Hashtable();
     _collaboratingWorkbookEnvironment = CollaboratingWorkbooksEnvironment.EMPTY;
     _workbookIx = 0;
 }
Example #2
0
 /**
  * Coordinates several formula Evaluators together so that formulas that involve external
  * references can be Evaluated.
  * @param workbookNames the simple file names used to identify the workbooks in formulas
  * with external links (for example "MyData.xls" as used in a formula "[MyData.xls]Sheet1!A1")
  * @param Evaluators all Evaluators for the full Set of workbooks required by the formulas.
  */
 public static void SetupEnvironment(String[] workbookNames, BaseFormulaEvaluator[] Evaluators)
 {
     WorkbookEvaluator[] wbEvals = new WorkbookEvaluator[Evaluators.Length];
     for (int i = 0; i < wbEvals.Length; i++)
     {
         wbEvals[i] = Evaluators[i]._bookEvaluator;
     }
     CollaboratingWorkbooksEnvironment.Setup(workbookNames, wbEvals);
 }
 public WorkbookEvaluator(EvaluationWorkbook workbook, IEvaluationListener evaluationListener, IStabilityClassifier stabilityClassifier, UDFFinder udfFinder)
 {
     _workbook = workbook;
     _evaluationListener = evaluationListener;
     _cache = new EvaluationCache(evaluationListener);
     _sheetIndexesBySheet = new Hashtable();
     _sheetIndexesByName = new Dictionary<string,int>();
     _collaboratingWorkbookEnvironment = CollaboratingWorkbooksEnvironment.EMPTY;
     _workbookIx = 0;
     _stabilityClassifier = stabilityClassifier;
     _udfFinder = udfFinder == null ? UDFFinder.DEFAULT : udfFinder;
 }
 public WorkbookEvaluator(EvaluationWorkbook workbook, IEvaluationListener evaluationListener, IStabilityClassifier stabilityClassifier, UDFFinder udfFinder)
 {
     _workbook           = workbook;
     _evaluationListener = evaluationListener;
     _cache = new EvaluationCache(evaluationListener);
     _sheetIndexesBySheet = new Hashtable();
     _sheetIndexesByName  = new Dictionary <string, int>();
     _collaboratingWorkbookEnvironment = CollaboratingWorkbooksEnvironment.EMPTY;
     _workbookIx          = 0;
     _stabilityClassifier = stabilityClassifier;
     _udfFinder           = udfFinder == null ? UDFFinder.DEFAULT : udfFinder;
 }
 public static void Setup(String[] workbookNames, WorkbookEvaluator[] evaluators)
 {
     int nItems = workbookNames.Length;
     if (evaluators.Length != nItems)
     {
         throw new ArgumentException("Number of workbook names is " + nItems
                 + " but number of evaluators is " + evaluators.Length);
     }
     if (nItems < 1)
     {
         throw new ArgumentException("Must provide at least one collaborating worbook");
     }
     CollaboratingWorkbooksEnvironment env = new CollaboratingWorkbooksEnvironment(workbookNames, evaluators, nItems);
     HookNewEnvironment(evaluators, env);
 }
        private void UnhookOldEnvironments(WorkbookEvaluator[] evaluators)
        {
            ArrayList oldEnvs = new ArrayList();

            for (int i = 0; i < evaluators.Length; i++)
            {
                oldEnvs.Add(evaluators[i].GetEnvironment());
            }
            CollaboratingWorkbooksEnvironment[] oldCWEs = new CollaboratingWorkbooksEnvironment[oldEnvs.Count];
            oldCWEs = (CollaboratingWorkbooksEnvironment[])oldEnvs.ToArray(typeof(CollaboratingWorkbooksEnvironment));
            for (int i = 0; i < oldCWEs.Length; i++)
            {
                oldCWEs[i].Unhook();
            }
        }
        public static void Setup(String[] workbookNames, WorkbookEvaluator[] evaluators)
        {
            int nItems = workbookNames.Length;

            if (evaluators.Length != nItems)
            {
                throw new ArgumentException("Number of workbook names is " + nItems
                                            + " but number of evaluators is " + evaluators.Length);
            }
            if (nItems < 1)
            {
                throw new ArgumentException("Must provide at least one collaborating worbook");
            }
            CollaboratingWorkbooksEnvironment env = new CollaboratingWorkbooksEnvironment(workbookNames, evaluators, nItems);

            HookNewEnvironment(evaluators, env);
        }
Example #8
0
        public WorkbookEvaluator(IEvaluationWorkbook workbook, IEvaluationListener evaluationListener, IStabilityClassifier stabilityClassifier, UDFFinder udfFinder)
        {
            _workbook = workbook;
            _evaluationListener = evaluationListener;
            _cache = new EvaluationCache(evaluationListener);
            _sheetIndexesBySheet = new Hashtable();
            _sheetIndexesByName = new Dictionary<string, int>();
            _collaboratingWorkbookEnvironment = CollaboratingWorkbooksEnvironment.EMPTY;
            _workbookIx = 0;
            _stabilityClassifier = stabilityClassifier;

            AggregatingUDFFinder defaultToolkit = // workbook can be null in unit tests
                workbook == null ? null : (AggregatingUDFFinder)workbook.GetUDFFinder();
            if (defaultToolkit != null && udfFinder != null)
            {
                defaultToolkit.Add(udfFinder);
            }
            _udfFinder = defaultToolkit;
        }
Example #9
0
        public WorkbookEvaluator(IEvaluationWorkbook workbook, IEvaluationListener evaluationListener, IStabilityClassifier stabilityClassifier, UDFFinder udfFinder)
        {
            _workbook           = workbook;
            _evaluationListener = evaluationListener;
            _cache = new EvaluationCache(evaluationListener);
            _sheetIndexesBySheet = new Hashtable();
            _sheetIndexesByName  = new Dictionary <string, int>();
            _collaboratingWorkbookEnvironment = CollaboratingWorkbooksEnvironment.EMPTY;
            _workbookIx          = 0;
            _stabilityClassifier = stabilityClassifier;

            AggregatingUDFFinder defaultToolkit = // workbook can be null in unit tests
                                                  workbook == null ? null : (AggregatingUDFFinder)workbook.GetUDFFinder();

            if (defaultToolkit != null && udfFinder != null)
            {
                defaultToolkit.Add(udfFinder);
            }
            _udfFinder = defaultToolkit;
        }
        private static void HookNewEnvironment(WorkbookEvaluator[] evaluators, CollaboratingWorkbooksEnvironment env)
        {
            // All evaluators will need To share the same cache.
            // but the cache takes an optional evaluation listener.
            int nItems = evaluators.Length;
            IEvaluationListener evalListener = evaluators[0].GetEvaluationListener();

            // make sure that all evaluators have the same listener
            for (int i = 0; i < nItems; i++)
            {
                if (evalListener != evaluators[i].GetEvaluationListener())
                {
                    // This would be very complex To support
                    throw new Exception("Workbook evaluators must all have the same evaluation listener");
                }
            }
            EvaluationCache cache = new EvaluationCache(evalListener);

            for (int i = 0; i < nItems; i++)
            {
                evaluators[i].AttachToEnvironment(env, cache, i);
            }
        }
Example #11
0
 public virtual void SetupReferencedWorkbooks(Dictionary <String, IFormulaEvaluator> evaluators)
 {
     CollaboratingWorkbooksEnvironment.SetupFormulaEvaluator(evaluators);
 }
        private static void HookNewEnvironment(WorkbookEvaluator[] evaluators, CollaboratingWorkbooksEnvironment env)
        {

            // All evaluators will need To share the same cache.
            // but the cache takes an optional evaluation listener.
            int nItems = evaluators.Length;
            IEvaluationListener evalListener = evaluators[0].GetEvaluationListener();
            // make sure that all evaluators have the same listener
            for (int i = 0; i < nItems; i++)
            {
                if (evalListener != evaluators[i].GetEvaluationListener())
                {
                    // This would be very complex To support
                    throw new Exception("Workbook evaluators must all have the same evaluation listener");
                }
            }
            EvaluationCache cache = new EvaluationCache(evalListener);

            for (int i = 0; i < nItems; i++)
            {
                evaluators[i].AttachToEnvironment(env, cache, i);
            }

        }
 private void UnhookOldEnvironments(WorkbookEvaluator[] evaluators)
 {
     ArrayList oldEnvs = new ArrayList();
     for (int i = 0; i < evaluators.Length; i++)
     {
         oldEnvs.Add(evaluators[i].GetEnvironment());
     }
     CollaboratingWorkbooksEnvironment[] oldCWEs = new CollaboratingWorkbooksEnvironment[oldEnvs.Count];
     oldCWEs = (CollaboratingWorkbooksEnvironment[])oldEnvs.ToArray(typeof(CollaboratingWorkbooksEnvironment));
     for (int i = 0; i < oldCWEs.Length; i++)
     {
         oldCWEs[i].Unhook();
     }
 }
Example #14
0
 /* package */
 public void AttachToEnvironment(CollaboratingWorkbooksEnvironment collaboratingWorkbooksEnvironment, EvaluationCache cache, int workbookIx)
 {
     _collaboratingWorkbookEnvironment = collaboratingWorkbooksEnvironment;
     _cache      = cache;
     _workbookIx = workbookIx;
 }
 /* package */
 public void DetachFromEnvironment()
 {
     _collaboratingWorkbookEnvironment = CollaboratingWorkbooksEnvironment.EMPTY;
     _cache = new EvaluationCache(_evaluationListener);
     _workbookIx = 0;
 }
 /* package */
 public void AttachToEnvironment(CollaboratingWorkbooksEnvironment collaboratingWorkbooksEnvironment, EvaluationCache cache, int workbookIx)
 {
     _collaboratingWorkbookEnvironment = collaboratingWorkbooksEnvironment;
     _cache = cache;
     _workbookIx = workbookIx;
 }
Example #17
0
 /* package */
 public void DetachFromEnvironment()
 {
     _collaboratingWorkbookEnvironment = CollaboratingWorkbooksEnvironment.EMPTY;
     _cache      = new EvaluationCache(_evaluationListener);
     _workbookIx = 0;
 }