Пример #1
0
 public Ref3DEval(Ref3DPtg ptg, ValueEval ve)
 {
     if (ve == null)
     {
         throw new ArgumentException("ve must not be null");
     }
     if (ptg == null)
     {
         throw new ArgumentException("ptg must not be null");
     }
     value = ve;
     _delegate = ptg;
 }
Пример #2
0
 /**
  * @return <c>true</c> if this Ptg needed to be changed
  */
 private Ptg AdjustPtgDueToRowMove(Ptg ptg, int currentExternSheetIx)
 {
     if (ptg is RefPtg)
     {
         if (currentExternSheetIx != _externSheetIndex)
         {
             // local refs on other sheets are unaffected
             return(null);
         }
         RefPtg rptg = (RefPtg)ptg;
         return(RowMoveRefPtg(rptg));
     }
     if (ptg is Ref3DPtg)
     {
         Ref3DPtg rptg = (Ref3DPtg)ptg;
         if (_externSheetIndex != rptg.ExternSheetIndex)
         {
             // only move 3D refs that refer to the sheet with cells being moved
             // (currentExternSheetIx is irrelevant)
             return(null);
         }
         return(RowMoveRefPtg(rptg));
     }
     if (ptg is Area2DPtgBase)
     {
         if (currentExternSheetIx != _externSheetIndex)
         {
             // local refs on other sheets are unaffected
             return(ptg);
         }
         return(RowMoveAreaPtg((Area2DPtgBase)ptg));
     }
     if (ptg is Area3DPtg)
     {
         Area3DPtg aptg = (Area3DPtg)ptg;
         if (_externSheetIndex != aptg.ExternSheetIndex)
         {
             // only move 3D refs that refer to the sheet with cells being moved
             // (currentExternSheetIx is irrelevant)
             return(null);
         }
         return(RowMoveAreaPtg(aptg));
     }
     return(null);
 }
Пример #3
0
        private static Ptg CreateDeletedRef(Ptg ptg)
        {
            if (ptg is RefPtg)
            {
                return(new RefErrorPtg());
            }
            if (ptg is Ref3DPtg)
            {
                Ref3DPtg rptg = (Ref3DPtg)ptg;
                return(new DeletedRef3DPtg(rptg.ExternSheetIndex));
            }
            if (ptg is AreaPtg)
            {
                return(new AreaErrPtg());
            }
            if (ptg is Area3DPtg)
            {
                Area3DPtg area3DPtg = (Area3DPtg)ptg;
                return(new DeletedArea3DPtg(area3DPtg.ExternSheetIndex));
            }

            throw new ArgumentException("Unexpected ref ptg class (" + ptg.GetType().Name + ")");
        }
Пример #4
0
        /**
         *
         * @param sheetIden may be <code>null</code>
         * @param part1
         * @param part2 may be <code>null</code>
         */
        private ParseNode CreateAreaRefParseNode(SheetIdentifier sheetIden, SimpleRangePart part1,
                SimpleRangePart part2)
        {
            int extIx;
            if (sheetIden == null)
            {
                extIx = Int32.MinValue;
            }
            else
            {
                String sName = sheetIden.SheetID.Name;
                if (sheetIden.BookName == null)
                {
                    extIx = book.GetExternalSheetIndex(sName);
                }
                else
                {
                    extIx = book.GetExternalSheetIndex(sheetIden.BookName, sName);
                }
            }
            Ptg ptg;
            if (part2 == null)
            {
                CellReference cr = part1.getCellReference();
                if (sheetIden == null)
                {
                    ptg = new RefPtg(cr);
                }
                else
                {
                    ptg = new Ref3DPtg(cr, extIx);
                }
            }
            else
            {
                AreaReference areaRef = CreateAreaRef(part1, part2);

                if (sheetIden == null)
                {
                    ptg = new AreaPtg(areaRef);
                }
                else
                {
                    ptg = new Area3DPtg(areaRef, extIx);
                }
            }
            return new ParseNode(ptg);
        }
Пример #5
0
        public LazyRefEval(Ref3DPtg ptg, SheetRefEvaluator sre)
            : base(ptg.Row, ptg.Column)
        {

            _evaluator = sre;
        }
Пример #6
0
        /** Sets the reference , the area only (range)
         * @param ref1 area reference
         */
        public void SetAreaReference(String ref1){
        //Trying to Find if what ptg do we need
        RangeAddress ra = new RangeAddress(ref1);
        Ptg oldPtg;

        if (field_13_name_definition.Length < 1)
        {
            oldPtg = CreateNewPtg();
        }
        else
        {
            //Trying to find extern sheet index
            oldPtg = field_13_name_definition[0];
        }

        int externSheetIndex = 0;

        if (oldPtg.GetType() == typeof(Area3DPtg)){
            externSheetIndex =  ((Area3DPtg) oldPtg).ExternSheetIndex;

        } else if (oldPtg.GetType() == typeof(Ref3DPtg)){
            externSheetIndex =  ((Ref3DPtg) oldPtg).ExternSheetIndex;
        }
        ArrayList temp = new ArrayList();
        if (ra.HasRange) {
        	// Is it contiguous or not?
        	AreaReference[] refs = 
        		AreaReference.GenerateContiguous(ref1);

            // Add the area reference(s) 
        	for(int i=0; i<refs.Length; i++) {
                Ptg ptg1 = new Area3DPtg(refs[i].FormatAsString(), externSheetIndex);
                temp.Add(ptg1);
        	}
        	// And then a Union if we had more than one area
        	if(refs.Length > 1) {
                Ptg ptg = UnionPtg.instance;
                temp.Add(ptg);
        	}
        } else {
            Ref3DPtg ptg = new Ref3DPtg(ra.FromCell, externSheetIndex);
            temp.Add(ptg);
        }
        Ptg[] ptgs = new Ptg[temp.Count];
        ptgs=(Ptg[])temp.ToArray(typeof(Ptg));
        field_13_name_definition = ptgs;
    }