/**
         * @return possibly  <c>ErrorEval</c>, and <c>null</c>
         */
        private static ValueEval ChooseSingleElementFromAreaInternal(AreaEval ae,
                                                                     int srcCellRow, int srcCellCol)
        {
            //if (false)
            //{
            //    // this is too simplistic
            //    if (ae.ContainsRow(srcCellRow) && ae.ContainsColumn(srcCellCol))
            //    {
            //        throw new EvaluationException(ErrorEval.CIRCULAR_REF_ERROR);
            //    }
            //    /*
            //    Circular references are not dealt with directly here, but it is worth noting some Issues.

            //    ANY one of the return statements in this method could return a cell that is identical
            //    to the one immediately being Evaluated.  The evaluating cell is identified by srcCellRow,
            //    srcCellRow AND sheet.  The sheet is not available in any nearby calling method, so that's
            //    one reason why circular references are not easy to detect here. (The sheet of the returned
            //    cell can be obtained from ae if it is an Area3DEval.)

            //    Another reason there's little value in attempting to detect circular references here Is
            //    that only direct circular references could be detected.  If the cycle involved two or more
            //    cells this method could not detect it.

            //    Logic to detect evaluation cycles of all kinds has been coded in EvaluationCycleDetector
            //    (and HSSFFormulaEvaluator).
            //     */
            //}

            if (ae.IsColumn)
            {
                if (ae.IsRow)
                {
                    return(ae.GetRelativeValue(0, 0));
                }
                if (!ae.ContainsRow(srcCellRow))
                {
                    throw EvaluationException.InvalidValue();
                }
                return(ae.GetAbsoluteValue(srcCellRow, ae.FirstColumn));
            }
            if (!ae.IsRow)
            {
                // multi-column, multi-row area
                if (ae.ContainsRow(srcCellRow) && ae.ContainsColumn(srcCellCol))
                {
                    return(ae.GetAbsoluteValue(ae.FirstRow, ae.FirstColumn));
                }
                throw EvaluationException.InvalidValue();
            }
            if (!ae.ContainsColumn(srcCellCol))
            {
                throw EvaluationException.InvalidValue();
            }
            return(ae.GetAbsoluteValue(ae.FirstRow, srcCellCol));
        }
Example #2
0
 public ColumnVector(AreaEval tableArray, int columnIndex)
 {
     _columnIndex = columnIndex;
     int _columnAbsoluteIndex = tableArray.FirstColumn + columnIndex;
     if (!tableArray.ContainsColumn((short)_columnAbsoluteIndex))
     {
         int lastColIx = tableArray.LastColumn - tableArray.FirstColumn;
         throw new ArgumentException("Specified column index (" + columnIndex
                 + ") is outside the allowed range (0.." + lastColIx + ")");
     }
     _tableArray = tableArray;
     _size = _tableArray.Height;
 }
Example #3
0
            public ColumnVector(AreaEval tableArray, int columnIndex)
            {
                _columnIndex = columnIndex;
                int _columnAbsoluteIndex = tableArray.FirstColumn + columnIndex;

                if (!tableArray.ContainsColumn((short)_columnAbsoluteIndex))
                {
                    int lastColIx = tableArray.LastColumn - tableArray.FirstColumn;
                    throw new ArgumentException("Specified column index (" + columnIndex
                                                + ") is outside the allowed range (0.." + lastColIx + ")");
                }
                _tableArray = tableArray;
                _size       = _tableArray.Height;
            }
Example #4
0
        protected ValueEval SingleOperandEvaluate(Eval eval, int srcRow, short srcCol)
        {
            ValueEval retval;

            if (eval is AreaEval)
            {
                AreaEval ae = (AreaEval)eval;
                if (ae.Contains(srcRow, srcCol))
                { // circular ref!
                    retval = ErrorEval.CIRCULAR_REF_ERROR;
                }
                else if (ae.IsRow)
                {
                    if (ae.ContainsColumn(srcCol))
                    {
                        ValueEval ve = ae.GetValueAt(ae.FirstRow, srcCol);
                        ve     = Xlator.AttemptXlateToNumeric(ve);
                        retval = Xlator.AttemptXlateToNumeric(ve);
                    }
                    else
                    {
                        retval = ErrorEval.VALUE_INVALID;
                    }
                }
                else if (ae.IsColumn)
                {
                    if (ae.ContainsRow(srcRow))
                    {
                        ValueEval ve = ae.GetValueAt(srcRow, ae.FirstColumn);
                        retval = Xlator.AttemptXlateToNumeric(ve);
                    }
                    else
                    {
                        retval = ErrorEval.VALUE_INVALID;
                    }
                }
                else
                {
                    retval = ErrorEval.VALUE_INVALID;
                }
            }
            else
            {
                retval = Xlator.AttemptXlateToNumeric((ValueEval)eval);
            }
            return(retval);
        }
Example #5
0
        /**
         * Returns an is StringValueEval or ErrorEval or BlankEval
         *
         * @param eval
         * @param srcRow
         * @param srcCol
         */
        protected ValueEval SingleOperandEvaluate(Eval eval, int srcRow, short srcCol)
        {
            ValueEval retval;

            if (eval is AreaEval)
            {
                AreaEval ae = (AreaEval)eval;
                if (ae.Contains(srcRow, srcCol))
                { // circular ref!
                    retval = ErrorEval.CIRCULAR_REF_ERROR;
                }
                else if (ae.IsRow)
                {
                    if (ae.ContainsColumn(srcCol))
                    {
                        ValueEval ve = ae.GetValue(ae.FirstRow, srcCol);
                        retval = InternalResolveEval(eval);
                    }
                    else
                    {
                        retval = ErrorEval.NAME_INVALID;
                    }
                }
                else if (ae.IsColumn)
                {
                    if (ae.ContainsRow(srcRow))
                    {
                        ValueEval ve = ae.GetValue(srcRow, ae.FirstColumn);
                        retval = InternalResolveEval(eval);
                    }
                    else
                    {
                        retval = ErrorEval.NAME_INVALID;
                    }
                }
                else
                {
                    retval = ErrorEval.NAME_INVALID;
                }
            }
            else
            {
                retval = InternalResolveEval(eval);
            }
            return(retval);
        }
Example #6
0
        /**
         * @return possibly  <tt>ErrorEval</tt>, and <c>null</c> 
         */
        private static ValueEval ChooseSingleElementFromAreaInternal(AreaEval ae,
                int srcCellRow, short srcCellCol)
        {

            //if (false)
            //{
            //    // this Is too simplistic
            //    if (ae.ContainsRow(srcCellRow) && ae.ContainsColumn(srcCellCol))
            //    {
            //        throw new EvaluationException(ErrorEval.CIRCULAR_REF_ERROR);
            //    }
            //    /*
            //    Circular references are not dealt with directly here, but it Is worth noting some Issues.

            //    ANY one of the return statements in this method could return a cell that Is identical
            //    to the one immediately being Evaluated.  The evaluating cell Is identified by srcCellRow,
            //    srcCellRow AND sheet.  The sheet Is not available in any nearby calling method, so that's
            //    one reason why circular references are not easy to detect here. (The sheet of the returned
            //    cell can be obtained from ae if it Is an Area3DEval.)

            //    Another reason there's little value in attempting to detect circular references here Is
            //    that only direct circular references could be detected.  If the cycle involved two or more
            //    cells this method could not detect it.  

            //    Logic to detect evaluation cycles of all kinds has been coded in EvaluationCycleDetector
            //    (and HSSFFormulaEvaluator). 
            //     */
            //}

            if (ae.IsColumn)
            {
                if (ae.IsRow)
                {
                    return ae.GetRelativeValue(0, 0);
                }
                if (!ae.ContainsRow(srcCellRow))
                {
                    throw EvaluationException.InvalidValue();
                }
                return ae.GetValueAt(srcCellRow, ae.FirstColumn);
            }
            if (!ae.IsRow)
            {
                // multi-column, multi-row area
                if (ae.ContainsRow(srcCellRow) && ae.ContainsColumn(srcCellCol))
                {
                    return ae.GetValueAt(ae.FirstRow, ae.FirstColumn);
                }
                throw EvaluationException.InvalidValue();
            }
            if (!ae.ContainsColumn(srcCellCol))
            {
                throw EvaluationException.InvalidValue();
            }
            return ae.GetValueAt(ae.FirstRow, srcCellCol);
        }