Esempio n. 1
0
        internal void LoadItem(RptText p_item, bool p_isGroup)
        {
            _txt     = p_item;
            _curRow  = p_item.Parent as RptTblPartRow;
            _part    = _curRow.Parent as RptTblPart;
            _table   = _part.Table;
            _fv.Data = _table.Data;

            UpdateHeaderFooterState();
            if (p_isGroup)
            {
                _fvGrp.Show("field");
                foreach (RptTblGroup grp in _table.Groups)
                {
                    if (grp.Header == _part || grp.Footer == _part)
                    {
                        _fvGrp.Data = grp.Data;
                        break;
                    }
                }
            }
            else
            {
                _fvGrp.Hide("field");
            }
        }
Esempio n. 2
0
        void OnInsertTbl(object sender, Mi e)
        {
            _owner.Excel.DecorationRange = null;
            CellRange range = _owner.Excel.ActiveSheet.Selections[0];
            var       item  = new RptTable(_owner.GetContainer());

            _owner.Info.ExecuteCmd(RptCmds.InsertTable, new InsertCmdArgs(item, range));
            _owner.UpdateSelection();
        }
Esempio n. 3
0
        /// <summary>
        /// 拷贝对象方法
        /// </summary>
        /// <returns></returns>
        public override RptItem Clone()
        {
            RptTable newOne = new RptTable(this._part);

            newOne._data.Copy(this._data);
            CopyTableStruct(this, newOne);

            return(newOne as RptItem);
        }
Esempio n. 4
0
        /// <summary>
        /// 输出单列表头表尾可重复表格布局
        /// </summary>
        void OutputTable()
        {
            _region.RowSpan = 0;
            _data.Current   = 0;
            RptRootInst root = Inst;
            RptRegion   region;

            if (_header != null)
            {
                _header.Output();
                region          = _header.Region;
                _region.RowSpan = region.Row + region.RowSpan - _region.Row;
            }

            root.VerPageBegin += OnPageBegin;
            root.VerPageEnd   += OnPageEnd;
            RptTable tbl = _item as RptTable;

            if (tbl.Footer != null && tbl.RepeatFooter)
            {
                root.TblFooterHeight = tbl.Footer.Height;
            }

            foreach (RptTblPartInst inst in _rows)
            {
                _curPart = inst;
                RptItemBase item = inst.Item;
                region = new RptRegion(
                    _region.Row + _region.RowSpan,
                    _region.Col,
                    item.RowSpan,
                    item.ColSpan);
                inst.Region = region;
                inst.Output();
                _region.RowSpan = region.Row + region.RowSpan - _region.Row;
            }

            _curPart             = null;
            root.TblFooterHeight = 0.0;
            root.VerPageBegin   -= OnPageBegin;
            root.VerPageEnd     -= OnPageEnd;

            if (_footer != null)
            {
                RptItemBase item = _footer.Item;
                region = new RptRegion(
                    _region.Row + _region.RowSpan,
                    _region.Col,
                    item.RowSpan,
                    item.ColSpan);
                _footer.Region = region;
                _footer.Output();
                _region.RowSpan = region.Row + region.RowSpan - _region.Row;
            }
            _data.Current = 0;
        }
Esempio n. 5
0
        public override void Undo(object p_args)
        {
            InsertTblRowCmdArgs args = (InsertTblRowCmdArgs)p_args;

            args.Part.Rows.RemoveAt(args.Index);
            RptTable tbl = args.Part.Table;

            tbl.CalcRowSpan();
            tbl.Update(true);
        }
Esempio n. 6
0
        public override void Undo(object p_args)
        {
            DeleRptTblColCmdArgs args   = (DeleRptTblColCmdArgs)p_args;
            RptTable             rptTab = args.Table;
            int index = args.Index;

            InsertTblCells(rptTab, index, args.Dict);
            rptTab.Data["colspan"] = rptTab.ColSpan + 1;
            rptTab.Update(false);
        }
Esempio n. 7
0
        public override void Undo(object p_args)
        {
            DeleTblRowCmdArgs args = (DeleTblRowCmdArgs)p_args;

            args.Row.TblPart.Rows.Insert(args.Index, args.Row);
            RptTable tbl = args.Row.Table;

            tbl.CalcRowSpan();
            tbl.Update(false);
        }
Esempio n. 8
0
        public override void Undo(object p_args)
        {
            InsertRptTblColCmdArgs args = (InsertRptTblColCmdArgs)p_args;
            RptTable rptTab             = args.Table;
            int      index = args.Index;

            RmvTblCells(rptTab, index);
            rptTab.Data["colspan"] = rptTab.ColSpan - 1;
            rptTab.Update(true);
        }
Esempio n. 9
0
        public override object Execute(object p_args)
        {
            DeleTblRowCmdArgs args = (DeleTblRowCmdArgs)p_args;

            args.Row.TblPart.Rows.RemoveAt(args.Index);
            RptTable tbl = args.Row.Table;

            tbl.CalcRowSpan();
            tbl.Update(true);
            return(args.Row);
        }
Esempio n. 10
0
        public override object Execute(object p_args)
        {
            InsertRptTblColCmdArgs args = (InsertRptTblColCmdArgs)p_args;
            RptTable rptTab             = args.Table;
            int      index = args.Index;

            BldTblCells(rptTab, index);
            // 此处直接为data赋值,触发valueChanged事件。
            rptTab.Data["colspan"] = rptTab.ColSpan + 1;
            rptTab.Update(false);
            return(null);
        }
Esempio n. 11
0
        public override object Execute(object p_args)
        {
            DeleRptTblColCmdArgs args   = (DeleRptTblColCmdArgs)p_args;
            RptTable             rptTab = args.Table;
            int index = args.Index;

            args.Dict.Clear();
            RmvTblCells(rptTab, index, args.Dict);
            rptTab.Data["colspan"] = rptTab.ColSpan - 1;
            rptTab.Update(true);
            return(null);
        }
Esempio n. 12
0
        public override object Execute(object p_args)
        {
            InsertTblRowCmdArgs args = (InsertTblRowCmdArgs)p_args;
            RptTblPartRow       row  = new RptTblPartRow(args.Part);

            InsertTableCmd.BuildCells(row, args.Part.Table.ColSpan);
            args.Part.Rows.Insert(args.Index, row);
            RptTable tbl = args.Part.Table;

            tbl.CalcRowSpan();
            tbl.Update(false);
            return(row);
        }
Esempio n. 13
0
        /// <summary>
        /// 输出报表项内容
        /// </summary>
        protected override void DoOutput()
        {
            RptTable tbl = _item as RptTable;

            if (tbl.RowBreakCount == 0)
            {
                OutputTable();
            }
            else
            {
                OutputList();
            }
        }
Esempio n. 14
0
        /// <summary>
        /// 加载xml
        /// </summary>
        /// <param name="p_reader"></param>
        public virtual void ReadXml(XmlReader p_reader)
        {
            p_reader.MoveToElement();
            if (p_reader.IsEmptyElement)
            {
                p_reader.Read();
                return;
            }

            string name = p_reader.Name;

            p_reader.Read();
            while (p_reader.NodeType != XmlNodeType.None)
            {
                if (p_reader.NodeType == XmlNodeType.EndElement && p_reader.Name == name)
                {
                    break;
                }

                RptItem item = null;
                switch (p_reader.Name)
                {
                case "Text":
                    item = new RptText(this);
                    break;

                case "Table":
                    item = new RptTable(this);
                    break;

                case "Matrix":
                    item = new RptMatrix(this);
                    break;

                case "Chart":
                    item = new RptChart(this);
                    break;

                default:
                    if (item == null)
                    {
                        Kit.Error(string.Format("反序列化报表模板时错误,无法识别报表项【{0}】!", p_reader.Name));
                    }
                    break;
                }
                item.ReadXml(p_reader);
                Items.Add(item);
            }
            p_reader.Read();
        }
Esempio n. 15
0
 void InsertTblCells(RptTable p_table, int p_index, Dictionary <string, RptText> p_dict)
 {
     InsertCells(p_table.Header, p_index, p_dict, "header");
     if (p_table.Groups != null && p_table.Groups.Count > 0)
     {
         for (int i = 0; i < p_table.Groups.Count; i++)
         {
             RptTblGroup grp = p_table.Groups[i];
             InsertCells(grp.Header, p_index, p_dict, "grpHeader" + i.ToString());
             InsertCells(grp.Footer, p_index, p_dict, "grpFooter" + i.ToString());
         }
     }
     InsertCells(p_table.Body, p_index, p_dict, "body");
     InsertCells(p_table.Footer, p_index, p_dict, "footer");
 }
Esempio n. 16
0
        void RmvTblCells(RptTable p_table, int p_index)
        {
            if (p_table == null)
            {
                return;
            }

            RemoveCells(p_table.Header, p_index);
            if (p_table.Groups != null && p_table.Groups.Count > 0)
            {
                foreach (RptTblGroup grp in p_table.Groups)
                {
                    RemoveCells(grp.Header, p_index);
                    RemoveCells(grp.Footer, p_index);
                }
            }
            RemoveCells(p_table.Body, p_index);
            RemoveCells(p_table.Footer, p_index);
        }
Esempio n. 17
0
        void BldTblCells(RptTable p_table, int p_index)
        {
            if (p_table == null)
            {
                return;
            }

            BuildCells(p_table.Header, p_index);
            BuildCells(p_table.Body, p_index);
            BuildCells(p_table.Footer, p_index);
            if (p_table.Groups != null && p_table.Groups.Count > 0)
            {
                foreach (RptTblGroup grp in p_table.Groups)
                {
                    BuildCells(grp.Header, p_index);
                    BuildCells(grp.Footer, p_index);
                }
            }
        }
Esempio n. 18
0
        public override object Execute(object p_args)
        {
            InsertTblGrpCmdArgs args  = (InsertTblGrpCmdArgs)p_args;
            RptTable            table = args.Table;

            if (table.Groups == null)
            {
                table.Groups = new List <RptTblGroup>();
            }
            RptTblPartRow row = new RptTblPartRow(args.Grp.Header);

            InsertTableCmd.BuildCells(row, table.ColSpan);
            args.Grp.Header.Rows.Add(row);
            RptTblPartRow r = new RptTblPartRow(args.Grp.Footer);

            InsertTableCmd.BuildCells(r, table.ColSpan);
            args.Grp.Footer.Rows.Add(r);
            args.Table.Groups.Add(args.Grp);
            args.Table.CalcRowSpan();
            args.Table.Update(false);
            return(null);
        }
Esempio n. 19
0
 public RptTblGroup(RptTable p_table)
 {
     Table = p_table;
     // 分组字段
     _data.AddCell <string>("field");
 }
Esempio n. 20
0
 public RptTblGroupFooter(RptTable p_table)
     : base(p_table)
 {
 }
Esempio n. 21
0
        /// <summary>
        /// 输出单列布局
        /// </summary>
        void OutputList()
        {
            RptItemBase      tempItem;
            RptRootInst      root    = Inst;
            List <RptRegion> regions = new List <RptRegion>();
            RptRegion        region  = new RptRegion(_region.Row, _region.Col, 0, _item.ColSpan);

            regions.Add(region);

            if (_header != null)
            {
                _header.Output();
                region.RowSpan += _header.Region.RowSpan;
            }

            RptTable tbl      = _item as RptTable;
            int      rowCount = tbl.RowBreakCount;
            int      colCount = tbl.ColBreakCount;
            int      rowNum   = 0;

            foreach (RptTblPartInst tabInst in _rows)
            {
                RptItemBase item = tabInst.Item;
                tabInst.Region = new RptRegion(
                    region.Row + region.RowSpan,
                    region.Col,
                    item.RowSpan,
                    item.ColSpan);

                bool rowBreak = false;
                bool colBreak = false;
                if (rowCount == -1)
                {
                    // 自动计算重复行数
                    if (root.TestPageBreak(tabInst))
                    {
                        // 需要换页
                        if (colCount != 0 && (regions.Count % colCount) == 0)
                        {
                            rowBreak = true;
                            colBreak = true;
                        }
                        else
                        {
                            rowBreak = false;
                            colBreak = true;
                        }
                    }
                }
                else if (rowNum == rowCount)
                {
                    // 应该换列
                    if (colCount != 0 && (regions.Count % colCount) == 0)
                    {
                        rowBreak = true;
                        colBreak = true;
                    }
                    else
                    {
                        rowBreak = false;
                        colBreak = true;
                    }
                }

                if (colBreak)
                {
                    // 换新列,重新累计行数
                    rowNum = 0;
                    if (rowBreak)
                    {
                        // 列数达到后换行显示
                        RptRegion region2 = regions[regions.Count - colCount];
                        region = new RptRegion(
                            region2.Row + region2.RowSpan,
                            region2.Col,
                            0,
                            region2.ColSpan);
                        regions.Add(region);
                    }
                    else
                    {
                        RptRegion region3 = regions[regions.Count - 1];
                        region = new RptRegion(
                            region3.Row,
                            region3.Col + region3.ColSpan,
                            0,
                            region3.ColSpan);
                        regions.Add(region);
                    }

                    // 输出表头
                    if (_header != null)
                    {
                        RptTblHeaderInst header = _header.Clone() as RptTblHeaderInst;
                        header.Region         = region.Clone() as RptRegion;
                        header.Region.RowSpan = header.Item.RowSpan;
                        header.Output();
                        region.RowSpan = (header.Region.Row + header.Region.RowSpan) - region.Row;
                    }

                    tempItem       = tabInst.Item;
                    tabInst.Region = new RptRegion(
                        region.Row + region.RowSpan,
                        region.Col,
                        tempItem.RowSpan,
                        tempItem.ColSpan);
                    tabInst.Output();
                }
                else
                {
                    tabInst.Output();
                }

                region.RowSpan = (tabInst.Region.Row + tabInst.Region.RowSpan) - region.Row;
                if (((tabInst.Region.Row + tabInst.Region.RowSpan) - _region.Row) > _region.RowSpan)
                {
                    _region.RowSpan = (tabInst.Region.Row + tabInst.Region.RowSpan) - _region.Row;
                }

                if (((tabInst.Region.Col + tabInst.Region.ColSpan) - _region.Col) > _region.ColSpan)
                {
                    _region.ColSpan = (tabInst.Region.Col + tabInst.Region.ColSpan) - _region.Col;
                }
                rowNum++;
            }

            if (_footer != null)
            {
                region = _region;
                if (regions.Count > 0)
                {
                    region = regions[regions.Count - 1];
                }
                tempItem       = _footer.Item;
                _footer.Region = new RptRegion(
                    region.Row + region.RowSpan,
                    region.Col,
                    tempItem.RowSpan,
                    tempItem.ColSpan);
                _footer.Output();

                if (((_footer.Region.Row + _footer.Region.RowSpan) - _region.Row) > _region.RowSpan)
                {
                    _region.RowSpan = (_footer.Region.Row + _footer.Region.RowSpan) - _region.Row;
                }

                if (((_footer.Region.Col + _footer.Region.ColSpan) - _region.Col) > _region.ColSpan)
                {
                    _region.ColSpan = (_footer.Region.Col + _footer.Region.ColSpan) - _region.Col;
                }
            }
        }
Esempio n. 22
0
 public RptTblRow(RptTable p_table)
     : base(p_table)
 {
     // 最少行数
     _data.AddCell("minrowcount", 0);
 }
Esempio n. 23
0
 public RptTblPart(RptTable p_table)
 {
     Table = p_table;
     Rows  = new List <RptTblPartRow>();
 }
Esempio n. 24
0
 public InsertTblGrpCmdArgs(RptTable p_table, RptTblGroup p_grp)
 {
     Table = p_table;
     Grp   = p_grp;
 }
Esempio n. 25
0
 public ClearTblGrpCmdArgs(RptTable p_table, List <RptTblGroup> p_grps)
 {
     Table = p_table;
     Grps  = p_grps;
 }
Esempio n. 26
0
 public DeleRptTblColCmdArgs(RptTable p_table, int p_index, Dictionary <string, RptText> p_dict)
 {
     Dict  = p_dict;
     Index = p_index;
     Table = p_table;
 }
Esempio n. 27
0
        /// <summary>
        /// 加载table
        /// </summary>
        /// <param name="p_tbl"></param>
        void LoadTable(RptTable p_tbl)
        {
            int rowCount;
            int grpCount = p_tbl.Groups == null ? 0 : p_tbl.Groups.Count;
            List <RptTblGroup> listGrp = p_tbl.Groups;
            int           rowIndex     = p_tbl.Row;
            int           colIndex     = p_tbl.Col;
            RptTblPartRow tblRow;

            //加载表头。
            if (p_tbl.Header != null)
            {
                rowCount = p_tbl.Header.Rows.Count;
                for (int i = 0; i < rowCount; i++)
                {
                    tblRow = p_tbl.Header.Rows[i];
                    LoadTblRow(tblRow, rowIndex, colIndex);
                    rowIndex += tblRow.RowSpan == 0 ? 1 : tblRow.RowSpan;
                }
            }

            //加载分组头
            if (grpCount > 0)
            {
                for (int i = 0; i < grpCount; i++)
                {
                    rowCount = listGrp[i].Header == null ? 0 : listGrp[i].Header.Rows.Count;
                    for (int j = 0; j < rowCount; j++)
                    {
                        tblRow = listGrp[i].Header.Rows[j];
                        LoadTblRow(tblRow, rowIndex, colIndex);
                        rowIndex += tblRow.RowSpan == 0 ? 1 : tblRow.RowSpan;
                    }
                }
            }

            //添加数据
            if (p_tbl.Body != null)
            {
                rowCount = p_tbl.Body.Rows.Count;
                for (int i = 0; i < rowCount; i++)
                {
                    tblRow = p_tbl.Body.Rows[i];
                    LoadTblRow(tblRow, rowIndex, colIndex);
                    rowIndex += tblRow.RowSpan == 0 ? 1 : tblRow.RowSpan;
                }
            }

            //添加分组尾
            if (grpCount > 0)
            {
                for (int i = grpCount; i > 0; i--)
                {
                    rowCount = listGrp[i - 1].Footer == null ? 0 : listGrp[i - 1].Footer.Rows.Count;
                    for (int j = 0; j < rowCount; j++)
                    {
                        tblRow = listGrp[i - 1].Footer.Rows[j];
                        LoadTblRow(tblRow, rowIndex, colIndex);
                        rowIndex += tblRow.RowSpan == 0 ? 1 : tblRow.RowSpan;
                    }
                }
            }

            //加载表尾。
            if (p_tbl.Footer != null)
            {
                rowCount = p_tbl.Footer.Rows.Count;
                for (int i = 0; i < rowCount; i++)
                {
                    tblRow = p_tbl.Footer.Rows[i];
                    LoadTblRow(tblRow, rowIndex, colIndex);
                    rowIndex += tblRow.RowSpan == 0 ? 1 : tblRow.RowSpan;
                }
            }
        }
Esempio n. 28
0
        public override object Execute(object p_args)
        {
            InsertCmdArgs args = (InsertCmdArgs)p_args;
            RptTable      tbl  = args.RptItem as RptTable;
            RptPart       con  = tbl.Part;

            //通过重做重新加载table,不用处理
            if (tbl.Header != null || tbl.Body != null || tbl.Footer != null)
            {
                con.Items.Add(tbl);
                return(tbl);
            }

            CellRange range = args.CellRange;

            tbl.Row     = range.Row;
            tbl.Col     = range.Column;
            tbl.RowSpan = range.RowCount;
            tbl.ColSpan = range.ColumnCount;
            RptTblPartRow tblRow;

            switch (tbl.RowSpan)
            {
            case 1:
                tbl.Body = new RptTblRow(tbl);
                tblRow   = new RptTblPartRow(tbl.Body);
                tbl.Body.Rows.Add(tblRow);
                BuildCells(tblRow, tbl.ColSpan);
                break;

            case 2:
                tbl.Header = new RptTblHeader(tbl);
                tblRow     = new RptTblPartRow(tbl.Header);
                tbl.Header.Rows.Add(tblRow);
                BuildCells(tblRow, tbl.ColSpan);
                tbl.Body = new RptTblRow(tbl);
                tblRow   = new RptTblPartRow(tbl.Body);
                tbl.Body.Rows.Add(tblRow);
                BuildCells(tblRow, tbl.ColSpan);
                break;

            default:
                tbl.Header = new RptTblHeader(tbl);
                tblRow     = new RptTblPartRow(tbl.Header);
                tbl.Header.Rows.Add(tblRow);
                BuildCells(tblRow, tbl.ColSpan);
                tbl.Body = new RptTblRow(tbl);
                for (int i = 0; i < tbl.RowSpan - 2; i++)
                {
                    tblRow = new RptTblPartRow(tbl.Body);
                    tbl.Body.Rows.Add(tblRow);
                    BuildCells(tblRow, tbl.ColSpan);
                }
                tbl.Footer = new RptTblFooter(tbl);
                tblRow     = new RptTblPartRow(tbl.Footer);
                tbl.Footer.Rows.Add(tblRow);
                BuildCells(tblRow, tbl.ColSpan);
                break;
            }
            con.Items.Add(tbl);
            return(tbl);
        }
Esempio n. 29
0
 public RptTblHeader(RptTable p_table)
     : base(p_table)
 {
 }
Esempio n. 30
0
 public InsertRptTblColCmdArgs(RptTable p_table, int p_index)
 {
     Index = p_index;
     Table = p_table;
 }