示例#1
0
        /// <summary>
        /// CreateFromData
        /// </summary>
        internal TNoteRecord(int aRow, int aCol, TRichString aTxt, string aAuthor, TDrawing Drawing, TImageProperties Properties,
                             ExcelFile xls, TSheet sSheet, bool ReadFromXlsx)
            : base((int)xlr.NOTE, aCol)
        {
            if ((aCol < 0) || (aCol > FlxConsts.Max_Columns))
            {
                XlsMessages.ThrowException(XlsErr.ErrXlsIndexOutBounds, aCol, "Column", 0, FlxConsts.Max_Columns);
            }

            Dwg = Drawing.AddNewComment(xls, Properties, sSheet, ReadFromXlsx);
            TEscherImageAnchorRecord Anchor = GetImageRecord();

            if (Anchor != null)
            {
                NoteTextBox = Anchor.SaveCommentCoords(sSheet, aRow, aCol);
            }

            Col         = aCol;
            OptionFlags = 0;   //option flags
            unchecked
            {
                ObjId = (UInt16)Dwg.ObjId;   //object id
            }

            Author = aAuthor;

            SetText(aTxt);
        }
示例#2
0
        internal bool Find(TEscherSpContainerRecord R, out List <TEscherClientDataRecord> BtnGroup, IRowColSize Workbook)
        {
            BtnGroup = null;
            if (R == null)
            {
                return(false);
            }
            TEscherClientDataRecord Cd = R.FindRec <TEscherClientDataRecord>() as TEscherClientDataRecord;

            if (Cd == null)
            {
                return(false);
            }
            BuildTree(Workbook);

            TRadioGroupCache rgc;

            if (!RadioButtonsById.TryGetValue(Cd.ObjId, out rgc))
            {
                return(false);
            }

            BtnGroup = rgc.Buttons;
            return(true);
        }
示例#3
0
        private bool AddToTree(TEscherClientDataRecord obj, bool MightNotBeFirst, IRowColSize Workbook)
        {
            TEscherOPTRecord CbObj    = (obj.Parent as TEscherSpContainerRecord).FindRec <TEscherOPTRecord>() as TEscherOPTRecord;
            TClientAnchor    CbAnchor = TDrawing.GetObjectAnchorAbsolute(CbObj, Workbook);

            for (int i = 1; i < Tree.Count; i++) // 0 is desktop
            {
                TEscherOPTRecord GrpObj  = (Tree[i].Group.Parent as TEscherSpContainerRecord).FindRec <TEscherOPTRecord>() as TEscherOPTRecord;
                TClientAnchor    GAnchor = TDrawing.GetObjectAnchorAbsolute(GrpObj, Workbook);

                if ((MightNotBeFirst || Tree[i].Buttons.Count == 0) && GAnchor.Contains(CbAnchor))
                {
                    AddRadioButton(obj, i);
                    return(true);
                }
            }

            if (MightNotBeFirst || Tree[0].Buttons.Count == 0)
            {
                AddRadioButton(obj, 0);
                return(true);
            }

            return(false);
        }
示例#4
0
 private void ProcessCopiedEntries(List <TEscherClientDataRecord> Entries, IRowColSize Workbook)
 {
     for (int i = 0; i < Entries.Count; i++)
     {
         TEscherClientDataRecord obj = Entries[i];
         AddToTree(obj, true, Workbook);
     }
     Entries.Clear();
 }
示例#5
0
        private void AddRadioButton(TEscherClientDataRecord obj, int i)
        {
            obj.IsFirstRadioButton = Tree[i].Buttons.Count == 0;
            if (Tree[i].Buttons.Count > 0)
            {
                Tree[i].Buttons[Tree[i].Buttons.Count - 1].NextRbId = obj.ObjId;
                (obj.ClientData as TMsObj).RemoveObjectFmlas(ft.CblsFmla, Tree[i].Buttons[0].ClientData as TMsObj); //only the first in the group might have a formula.
            }

            Tree[i].Buttons.Add(obj);
            obj.NextRbId = Tree[i].Buttons[0].ObjId; //docs say 0 can be here too, but excel writes a circular list. Both seem to work.
            RadioButtonsById[obj.ObjId] = Tree[i];
        }
示例#6
0
        internal void Add(TEscherClientDataRecord ms, bool Copied)
        {
            switch ((TObjectType)((ms.ClientData as TMsObj).ObjType))
            {
            case TObjectType.GroupBox:
                TRadioGroupCache rg = new TRadioGroupCache(ms);
                Tree.Add(rg);
                return;

            case TObjectType.OptionButton:
                List <TEscherClientDataRecord> Entries = Copied ? CopiedEntries : NewEntries;
                Entries.Add(ms);
                return;
            }
        }
示例#7
0
 private void FixDwg(int RowOffset, int ColOffset, TSheetInfo SheetInfo)
 {
     if (Dwg != null)
     {
         if (Dwg.Patriarch() == null)
         {
             XlsMessages.ThrowException(XlsErr.ErrLoadingEscher);
         }
         SheetInfo.IncCopiedGen();
         //We only copy DWG if we are copying rows/columns, when we copy sheets we dont have to.
         //now we have to copy dwg even in different sheets.
         Dwg = (TEscherClientDataRecord)Dwg.CopyDwg(RowOffset, ColOffset, SheetInfo);
         unchecked
         {
             ObjId = (UInt16)Dwg.ObjId;   //object id
         }
     }
 }
示例#8
0
        internal void ChangeFmla(ExcelFile Workbook, TEscherClientDataRecord Cd, TCellAddress LinkedCellAddress, TParsedTokenList LinkedCellFmla, bool ReadingXlsx)
        {
            //The line below would interfere with xlsx loading since it would build the tree and maybe remove links
            //before group boxes have been created.
            if (!ReadingXlsx)
            {
                BuildTree(Workbook);               //This avoids that 2 calls to different objects could have no secuential effects.
            }
            TRadioGroupCache rgc;

            if (!RadioButtonsById.TryGetValue(Cd.ObjId, out rgc))
            {
                //It is not in the built part.
                (Cd.ClientData as TMsObj).SetObjFormulaLink(Workbook, LinkedCellAddress, LinkedCellFmla);
                return;
            }
            (rgc.Buttons[0].ClientData as TMsObj).SetObjFormulaLink(Workbook, LinkedCellAddress, LinkedCellFmla);
        }
示例#9
0
        private void ProcessNewEntries(IRowColSize Workbook)
        {
            Dictionary <int, TEscherClientDataRecord> OtherRb = new Dictionary <int, TEscherClientDataRecord>();

            for (int i = NewEntries.Count - 1; i >= 0; i--)
            {
                TEscherClientDataRecord obj = NewEntries[i];
                if (obj.IsFirstRadioButton)
                {
                    if (AddToTree(obj, false, Workbook))
                    {
                        NewEntries.RemoveAt(i);
                    }
                }
                else
                {
                    OtherRb.Add(obj.ObjId, obj);
                }
            }

            for (int i = 0; i < Tree.Count; i++) //0 is root
            {
                if (Tree[i].Buttons.Count == 1)
                {
                    TEscherClientDataRecord Current = Tree[i].Buttons[0];
                    do
                    {
                        int NextId = Current.NextRbId;
                        if (NextId == 0)
                        {
                            break;              //if not careful, we could have an infinite loop here. for example is NextId = NextNextId, or maybe NextId = NextNextNextId
                        }
                        if (!OtherRb.TryGetValue(NextId, out Current))
                        {
                            break;
                        }
                        OtherRb.Remove(NextId); //to avoid infinite loop commented above.
                        NewEntries.Remove(Current);
                        Tree[i].Buttons.Add(Current);
                        RadioButtonsById[NextId] = Tree[i];
                    } while (true);
                }
            }
        }
示例#10
0
/*Now we keep range to insert on dwgofs. Inserting here could lead to inserting rows on the cells (and moving the red triangle down), but not on the note. Both must move together.
 *         internal override void ArrangeInsertRange(int Row, TXlsCellRange CellRange, int aRowCount, int aColCount, TSheetInfo SheetInfo)
 *      {
 *          if ((SheetInfo.InsSheet<0) || (SheetInfo.SourceFormulaSheet != SheetInfo.InsSheet)) return;  //this is also on the base.arrangeinsertrange, but we want to keep both inserts together. If we insert on the red triangle, we insert on the shape. If we don't we don't no matter that the shape is on range to insert.
 *
 *          base.ArrangeInsertRange (Row, CellRange, aRowCount, aColCount, SheetInfo);
 *          if ((Dwg!=null) && (Dwg.FindRoot()!=null))
 *          {
 *              Dwg.FindRoot().ArrangeInsertRange(CellRange, aRowCount, aColCount, SheetInfo, true);
 *          }
 *      }
 */
        internal void FixDwgIds(TDrawing Drawing, int Row, TSheet sSheet, bool UseObjId, TCopiedGen CopiedGen)
        {
            if (UseObjId)
            {
                Dwg = Drawing.FindObjId(ObjId);
            }
            else
            {
                if (Dwg != null)
                {
                    Dwg = Dwg.CopiedTo(CopiedGen) as TEscherClientDataRecord;
                }
                if (Dwg != null)
                {
                    ObjId = (UInt16)Dwg.ObjId;
                }
            }
            TEscherImageAnchorRecord Anchor = GetImageRecord();

            if (Anchor != null)
            {
                NoteTextBox = Anchor.SaveCommentCoords(sSheet, Row, Col);
            }
        }
示例#11
0
        internal void Remove(TEscherClientDataRecord ms)
        {
            TMsObj obj = ms.ClientData as TMsObj;

            if (obj == null)
            {
                return;
            }
            switch ((TObjectType)(obj.ObjType))
            {
            case TObjectType.GroupBox:
                //remove from RadioButtonsById; and send all of those to copied.
                for (int i = Tree.Count - 1; i >= 1; i--)
                {
                    if (Tree[i].Group == ms)
                    {
                        for (int k = 0; k < Tree[i].Buttons.Count; k++)
                        {
                            RadioButtonsById.Remove(Tree[i].Buttons[k].ObjId);
                            CopiedEntries.Add(Tree[i].Buttons[k]);
                        }
                        Tree.RemoveAt(i);
                        return;
                    }
                }
                return;

            case TObjectType.OptionButton:
                for (int i = NewEntries.Count - 1; i >= 0; i--)
                {
                    if (NewEntries[i] == ms)
                    {
                        NewEntries.RemoveAt(i);
                        return;
                    }
                }
                for (int i = CopiedEntries.Count - 1; i >= 0; i--)
                {
                    if (CopiedEntries[i] == ms)
                    {
                        CopiedEntries.RemoveAt(i);
                        return;
                    }
                }

                TRadioGroupCache rb;
                if (RadioButtonsById.TryGetValue(ms.ObjId, out rb))
                {
                    RadioButtonsById.Remove(ms.ObjId);
                    for (int i = rb.Buttons.Count - 1; i >= 0; i--)
                    {
                        if (rb.Buttons[i] == ms)
                        {
                            rb.Buttons.RemoveAt(i);
                            break;
                        }
                    }
                }
                return;
            }
        }
示例#12
0
 public TRadioGroupCache(TEscherClientDataRecord grp)
 {
     Group   = grp;
     Buttons = new List <TEscherClientDataRecord>();
 }