Ejemplo n.º 1
0
 private FormulaEngine(SerializationInfo info, StreamingContext context)
 {
     DependencyManager    = (DependencyManager)info.GetValue("DependencyManager", typeof(DependencyManager));
     ReferencePool        = (ReferencePool)info.GetValue("ReferencePool", typeof(ReferencePool));
     _referenceFormulaMap = (IDictionary)info.GetValue("ReferenceFormulaMap", typeof(IDictionary));
     Sheets           = (SheetCollection)info.GetValue("SheetManager", typeof(SheetCollection));
     FunctionLibrary  = (FunctionLibrary)info.GetValue("FunctionLibrary", typeof(FunctionLibrary));
     Info             = new FormulaEngineInfo(this);
     ReferenceFactory = new ReferenceFactory(this);
     Settings         = new FormulaParserSettings();
     Parser           = CreateParser();
 }
Ejemplo n.º 2
0
 public FormulaEngine(FormulaParserSettings settings = null)
 {
     _referenceFormulaMap = new Hashtable();
     FunctionLibrary      = new FunctionLibrary(this);
     DependencyManager    = new DependencyManager(this);
     ReferenceFactory     = new ReferenceFactory(this);
     ReferencePool        = new ReferencePool(this);
     Sheets   = new SheetCollection(this);
     Info     = new FormulaEngineInfo(this);
     Settings = settings ?? new FormulaParserSettings();
     Parser   = CreateParser();
 }
Ejemplo n.º 3
0
        /// <summary>
        ///     Notifies the engine that a range has moved
        /// </summary>
        /// <param name="range">The range that has moved</param>
        /// <param name="rowOffset">The number of rows range has moved.  Can be negative.</param>
        /// <param name="colOffset">The number of columns the range has moved.  Can be negative.</param>
        /// <remarks>
        ///     Use this method to notify the engine that a range on a sheet has moved.  The engine will update all references
        ///     in, or that depend on, the moved range accordingly.
        /// </remarks>
        /// <exception cref="System.ArgumentOutOfRangeException">
        ///     The given range, when offset by the given offsets, is not within the bounds
        ///     of the active sheet
        /// </exception>
        public void OnRangeMoved(ISheetReference range, int rowOffset, int colOffset)
        {
            ValidateNonNull(range, "range");
            var sourceRef = (SheetReference)range;

            Rectangle destRect = range.Area;

            destRect.Offset(colOffset, rowOffset);
            var destRef = (SheetReference)ReferenceFactory.FromRectangle(destRect);

            ReferencePredicateBase pred;

            if (ReferenceEquals(sourceRef.Sheet, destRef.Sheet))
            {
                pred = new SheetReferencePredicate(Sheets.ActiveSheet);
            }
            else
            {
                pred = new CrossSheetReferencePredicate(sourceRef.Sheet, destRef.Sheet);
            }

            DoReferenceOperation(new RangeMovedOperator(this, sourceRef, destRef), pred);
        }