Example #1
0
        /// <summary>
        /// 克隆列头
        /// </summary>
        /// <param name="p_mtx"></param>
        /// <returns></returns>
        public RptMtxColHeader Clone(RptMatrix p_mtx)
        {
            RptMtxColHeader header = new RptMtxColHeader(p_mtx);

            foreach (RptMtxLevel level in Levels)
            {
                header.Levels.Add(level.Clone(header));
            }
            return(header);
        }
Example #2
0
        public override object Execute(object p_args)
        {
            SubTitleCmdArgs args  = (SubTitleCmdArgs)p_args;
            RptMtxSubtitle  title = args.SubTitle;
            RptMatrix       mtx   = title.Level.Matrix;

            args.OldSpan = title.Span;
            title.Span   = args.NewSpan;
            mtx.Update(true);
            return(null);
        }
Example #3
0
        public override object Execute(object p_args)
        {
            SubTotalCmdArgs args  = (SubTotalCmdArgs)p_args;
            RptMtxSubtotal  total = args.SubTotal;
            RptMatrix       mtx   = total.Level.Matrix;

            args.OldSpan = total.Span;
            total.Span   = args.NewSpan;
            mtx.Update(true);
            return(null);
        }
Example #4
0
        /// <summary>
        /// 克隆行
        /// </summary>
        /// <param name="p_mat"></param>
        /// <returns></returns>
        public RptMtxRow Clone(RptMatrix p_mat)
        {
            RptMtxRow row = new RptMtxRow(p_mat);

            foreach (RptText txt in Cells)
            {
                RptText newtxt = new RptText(row);
                newtxt.Data.Copy(txt.Data);
                row.Cells.Add(newtxt);
            }
            return(row);
        }
Example #5
0
        /// <summary>
        /// 添加新行
        /// </summary>
        /// <param name="p_matrix">矩阵</param>
        /// <param name="p_index">插入位置</param>
        /// <returns>新增行</returns>
        RptMtxRow InsertNewRow(RptMatrix p_matrix, int p_index)
        {
            RptMtxRow row      = new RptMtxRow(p_matrix);
            int       rowCount = p_matrix.GetCellsCount();

            for (int i = 0; i < p_matrix.Rows[0].Cells.Count; i++)
            {
                RptText text = new RptText(row);
                text.Val = string.Format("cell{0}", (rowCount + i).ToString());
                row.Cells.Add(text);
            }
            p_matrix.Rows.Insert(p_index, row);
            return(row);
        }
Example #6
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();
        }
Example #7
0
        /// <summary>
        /// 生成新的矩阵
        /// </summary>
        /// <returns></returns>
        public override RptItem Clone()
        {
            RptMatrix mtx = new RptMatrix(this.Part);

            mtx._data.Copy(_data);
            mtx.Corner    = Corner.Clone(mtx);
            mtx.ColHeader = ColHeader.Clone(mtx);
            mtx.RowHeader = RowHeader.Clone(mtx);
            foreach (RptMtxRow row in Rows)
            {
                mtx.Rows.Add(row.Clone(mtx));
            }
            return(mtx);
        }
Example #8
0
        void OnInsertMtx(object sender, Mi e)
        {
            _owner.Excel.DecorationRange = null;
            CellRange range = _owner.Excel.ActiveSheet.Selections[0];
            var       item  = new RptMatrix(_owner.GetContainer());

            range = new CellRange(range.Row, range.Column, 2, 2);
            if (RptItem.ValidEmptyRange(item.Part, range))
            {
                Kit.Error("对象创建后与其他对象位置冲突,请确认。");
                return;
            }
            _owner.Excel.ActiveSheet.SetSelection(range);
            _owner.Info.ExecuteCmd(RptCmds.InsertMatrix, new InsertCmdArgs(item, range));
            _owner.UpdateSelection();
        }
Example #9
0
 /// <summary>
 /// 获取数据行(行头时有效)
 /// </summary>
 /// <param name="p_index"></param>
 /// <returns></returns>
 internal List <RptMtxRow> GetRptRows(out int p_index)
 {
     if (Level.Parent is RptMtxRowHeader)
     {
         List <RptMtxRow> opsRows = new List <RptMtxRow>();
         RptMatrix        mat     = Level.Matrix;
         int curIndex             = Row - (mat.Row + mat.ColHeader.RowSpan);
         for (int i = 0; i < RowSpan; i++)
         {
             opsRows.Add(mat.Rows[curIndex + i]);
         }
         p_index = curIndex;
         return(opsRows);
     }
     p_index = -1;
     return(null);
 }
Example #10
0
        public override void Undo(object p_args)
        {
            MatrixArgs args = p_args as MatrixArgs;
            RptMatrix  mtx  = args.Matrix;

            if (args.HeaderType == RptMtxHeaderType.Col)
            {
                mtx.HideColHeader = !args.Val;
                mtx.RowSpan      += mtx.ColHeader.RowSpan * (!args.Val ? -1 : 1);
            }
            else
            {
                mtx.HideRowHeader = !args.Val;
                mtx.ColSpan      += mtx.RowHeader.ColSpan * (!args.Val ? -1 : 1);
            }
            mtx.Update(true);
        }
Example #11
0
        public override object Execute(object p_args)
        {
            InsertCmdArgs args = (InsertCmdArgs)p_args;
            RptMatrix     mat  = args.RptItem as RptMatrix;
            RptPart       con  = mat.Part;

            // 是通过重做来执行的,直接返回对象。
            if (mat.RowHeader != null || mat.ColHeader != null)
            {
                con.Items.Add(mat);
                return(mat);
            }

            CellRange range = args.CellRange;

            mat.Row     = range.Row;
            mat.Col     = range.Column;
            mat.RowSpan = range.RowCount;
            mat.ColSpan = range.ColumnCount;
            mat.Corner  = new RptMtxCorner(mat);
            RptMtxRowHeader rowheader = new RptMtxRowHeader(mat);

            mat.RowHeader = rowheader;
            RptMtxLevel level2 = new RptMtxLevel(rowheader);

            level2.Item.Val = "level2";
            rowheader.Levels.Add(level2);

            RptMtxColHeader colheader = new RptMtxColHeader(mat);

            mat.ColHeader = colheader;
            RptMtxLevel level1 = new RptMtxLevel(colheader);

            level1.Item.Val = "level1";
            colheader.Levels.Add(level1);

            RptMtxRow row = new RptMtxRow(mat);

            row.Cells.Add(new RptText(row)
            {
                Val = "cell0"
            });
            mat.Rows.Add(row);
            con.Items.Add(mat);
            return(mat);
        }
Example #12
0
        public override object Execute(object p_args)
        {
            MatrixArgs args = p_args as MatrixArgs;
            RptMatrix  mtx  = args.Matrix;

            if (args.HeaderType == RptMtxHeaderType.Col)
            {
                //重做
                if (!args.IsFirst)
                {
                    mtx.HideColHeader = args.Val;
                }
                else
                {
                    args.Val = mtx.HideColHeader;
                }
                mtx.RowSpan += mtx.ColHeader.RowSpan * (args.Val ? -1 : 1);
            }
            else
            {
                //重做
                if (!args.IsFirst)
                {
                    mtx.HideRowHeader = args.Val;
                }
                else
                {
                    args.Val = mtx.HideRowHeader;
                }
                mtx.ColSpan += mtx.RowHeader.ColSpan * (args.Val ? -1 : 1);
            }
            if (args.IsFirst)
            {
                args.IsFirst = false;
            }
            mtx.Update(true);
            return(mtx);
        }
Example #13
0
        public override void Undo(object p_args)
        {
            SubTitleCmdArgs args   = (SubTitleCmdArgs)p_args;
            RptMtxSubtitle  title  = args.SubTitle;
            RptItemBase     parent = args.Parent;
            RptMatrix       mtx    = null;

            if (parent is RptMtxLevel)
            {
                RptMtxLevel pLevel = parent as RptMtxLevel;
                mtx = pLevel.Matrix;
                args.DelMtxRows();
                pLevel.SubTitles.Remove(title);
            }
            else
            {
                RptMtxSubtitle pTitle = parent as RptMtxSubtitle;
                mtx = pTitle.Level.Matrix;
                args.DelMtxRows();
                pTitle.SubTitles.Remove(title);
            }
            mtx.Update(true);
        }
Example #14
0
 /// <summary>
 /// 获取相关数据列(列头时有效)
 /// </summary>
 /// <param name="p_index"></param>
 /// <returns></returns>
 internal Dictionary <RptMtxRow, List <RptText> > GetRptCells(out int p_index)
 {
     if (Level.Parent is RptMtxColHeader)
     {
         Dictionary <RptMtxRow, List <RptText> > opsCells = new Dictionary <RptMtxRow, List <RptText> >();
         RptMatrix      mat      = Level.Matrix;
         int            curIndex = Col - (mat.Col + mat.RowHeader.ColSpan);
         List <RptText> cells;
         foreach (RptMtxRow row in mat.Rows)
         {
             cells = new List <RptText>();
             for (int i = 0; i < ColSpan; i++)
             {
                 cells.Add(row.Cells[curIndex + i]);
             }
             opsCells.Add(row, cells);
         }
         p_index = curIndex;
         return(opsCells);
     }
     p_index = -1;
     return(null);
 }
Example #15
0
        public override void Undo(object p_args)
        {
            SubTotalCmdArgs args   = (SubTotalCmdArgs)p_args;
            RptMtxSubtotal  total  = args.SubTotal;
            RptItemBase     parent = args.Parent;
            RptMatrix       mtx    = null;

            if (parent is RptMtxLevel)
            {
                RptMtxLevel pLevel = parent as RptMtxLevel;
                mtx = pLevel.Matrix;
                args.DelMtxRows();
                pLevel.SubTotals.Remove(total);
            }
            else
            {
                RptMtxSubtotal pTotal = parent as RptMtxSubtotal;
                mtx = pTotal.Level.Matrix;
                args.DelMtxRows();
                pTotal.SubTotals.Remove(total);
            }
            mtx.Update(true);
        }
Example #16
0
        public override void Undo(object p_args)
        {
            SubTitleCmdArgs args   = (SubTitleCmdArgs)p_args;
            RptMtxSubtitle  title  = args.SubTitle;
            RptItemBase     parent = args.Parent;
            RptMatrix       mtx    = null;

            if (parent is RptMtxLevel)
            {
                RptMtxLevel pLevel = parent as RptMtxLevel;
                mtx = pLevel.Matrix;
                args.BackMtxRow();
                pLevel.SubTitles.Insert(args.TilteIndex, title);
            }
            else
            {
                RptMtxSubtitle pTotal = parent as RptMtxSubtitle;
                mtx = pTotal.Level.Matrix;
                args.BackMtxRow();
                pTotal.SubTitles.Insert(args.TilteIndex, title);
            }
            mtx.Update(true);
        }
Example #17
0
        public override object Execute(object p_args)
        {
            SubTitleCmdArgs  args       = (SubTitleCmdArgs)p_args;
            RptItemBase      parent     = args.Parent;
            RptMtxSubtitle   title      = args.SubTitle;
            RptMtxHeaderType headerType = RptMtxHeaderType.Col;
            RptMatrix        mtx        = null;

            args.InitData();
            if (parent is RptMtxLevel)
            {
                RptMtxLevel pLevel = parent as RptMtxLevel;
                mtx = pLevel.Matrix;
                if (pLevel.Parent is RptMtxRowHeader)
                {
                    headerType = RptMtxHeaderType.Row;
                }
                DelRows(args, headerType, mtx, title);
                args.TilteIndex = pLevel.SubTitles.IndexOf(title);
                pLevel.SubTitles.Remove(title);
            }
            else
            {
                RptMtxSubtitle pTotal = parent as RptMtxSubtitle;
                mtx = pTotal.Level.Matrix;
                if (pTotal.Level.Parent is RptMtxRowHeader)
                {
                    headerType = RptMtxHeaderType.Row;
                }
                DelRows(args, headerType, mtx, title);
                args.TilteIndex = pTotal.SubTitles.IndexOf(title);
                pTotal.SubTitles.Remove(title);
            }
            mtx.Update(true);
            return(null);
        }
Example #18
0
 internal void LoadItem(RptMatrix p_matrix)
 {
     _matrix  = p_matrix;
     _fv.Data = _matrix.Data;
     ((CList)_fv["tbl"]).Data = p_matrix.Root.Data.DataSet;
 }
Example #19
0
        public override object Execute(object p_args)
        {
            SubTotalCmdArgs args   = (SubTotalCmdArgs)p_args;
            RptMtxLevel     pLevel = args.Parent as RptMtxLevel;
            RptMtxSubtotal  total  = args.SubTotal;
            RptMatrix       mtx    = pLevel.Matrix;

            if (pLevel != null)
            {
                int count    = 0;
                int newIndex = 0;
                int index    = 0;
                if (pLevel.Parent is RptMtxRowHeader)
                {
                    args.OpsRows = total.GetRptRows(out index);
                    mtx.Rows.RemoveRange(index, args.OpsRows.Count);
                    if (total.TotalLoc == TotalLocation.Before)
                    {
                        count = (from c in pLevel.SubTotals
                                 where c.TotalLoc == total.TotalLoc &&
                                 pLevel.SubTotals.IndexOf(c) >= pLevel.SubTotals.IndexOf(total)
                                 select c).Count();
                        newIndex = pLevel.Row - count - (mtx.Row + mtx.ColHeader.RowSpan);
                    }
                    else
                    {
                        count = (from c in pLevel.SubTotals
                                 where c.TotalLoc == total.TotalLoc &&
                                 pLevel.SubTotals.IndexOf(c) < pLevel.SubTotals.IndexOf(total)
                                 select c).Count();
                        newIndex = pLevel.Row + pLevel.RowSpan + count - (mtx.Row + mtx.ColHeader.RowSpan);
                    }
                    mtx.Rows.InsertRange(newIndex, args.OpsRows);
                }
                else
                {
                    args.OpsCells = total.GetRptCells(out index);
                    foreach (RptMtxRow row in args.OpsCells.Keys)
                    {
                        row.Cells.RemoveRange(index, args.OpsCells[row].Count);
                        if (total.TotalLoc == TotalLocation.Before)
                        {
                            count = (from c in pLevel.SubTotals
                                     where c.TotalLoc == total.TotalLoc &&
                                     pLevel.SubTotals.IndexOf(c) >= pLevel.SubTotals.IndexOf(total)
                                     select c).Count();
                            newIndex = pLevel.Col - count - (mtx.Col + mtx.RowHeader.ColSpan);
                        }
                        else
                        {
                            count = (from c in pLevel.SubTotals
                                     where c.TotalLoc == total.TotalLoc &&
                                     pLevel.SubTotals.IndexOf(c) < pLevel.SubTotals.IndexOf(total)
                                     select c).Count();
                            newIndex = pLevel.Col + pLevel.ColSpan + count - (mtx.Col + mtx.RowHeader.ColSpan);
                        }
                        row.Cells.InsertRange(newIndex, args.OpsCells[row]);
                    }
                }
                args.BefIndex = index;
                args.CurIndex = newIndex;
            }
            mtx.Update(true);
            return(null);
        }
Example #20
0
        public override object Execute(object p_args)
        {
            SubTotalCmdArgs  args       = (SubTotalCmdArgs)p_args;
            RptItemBase      parent     = args.Parent;
            RptMtxHeaderType headerType = RptMtxHeaderType.Col;
            RptMtxSubtotal   total      = args.SubTotal;
            RptMatrix        mtx        = null;

            if (total == null)
            {
                total = new RptMtxSubtotal(parent);
                args.InitData();
                if (parent is RptMtxLevel)
                {
                    RptMtxLevel pLevel = parent as RptMtxLevel;
                    mtx = pLevel.Matrix;
                    if (pLevel.Parent is RptMtxRowHeader)
                    {
                        headerType = RptMtxHeaderType.Row;
                    }
                    total.Item.Val = string.Format("subtotal{0}", mtx.GetMaxTotal());
                    int curIndex = 0;
                    if (headerType == RptMtxHeaderType.Row)
                    {
                        curIndex = pLevel.Row;
                        if (!mtx.HideRowHeader && !mtx.HideColHeader)
                        {
                            curIndex -= (mtx.Corner.Row + mtx.Corner.RowSpan);
                        }
                        args.OpsRows.Add(InsertNewRow(mtx, curIndex));
                    }
                    else
                    {
                        curIndex = pLevel.Col - mtx.Rows[0].Col;
                        foreach (RptMtxRow row in mtx.Rows)
                        {
                            args.OpsCells.Add(row, InsertNewCell(mtx, row, curIndex).ToList());
                        }
                    }
                    args.CurIndex = curIndex;
                }
                else
                {
                    RptMtxSubtotal pTotal = parent as RptMtxSubtotal;
                    mtx = pTotal.Level.Matrix;
                    if (pTotal.Level.Parent is RptMtxRowHeader)
                    {
                        headerType = RptMtxHeaderType.Row;
                    }
                    total.Item.Val = string.Format("subtotal{0}", mtx.GetMaxTotal());
                    if (pTotal.SubTotals.Count > 0)
                    {
                        int curIndex = 0;
                        if (headerType == RptMtxHeaderType.Row)
                        {
                            curIndex = pTotal.Row + pTotal.GetCount();
                            if (!mtx.HideColHeader && !mtx.HideRowHeader)
                            {
                                curIndex -= (mtx.Corner.Row + mtx.Corner.RowSpan);
                            }
                            args.OpsRows.Add(InsertNewRow(mtx, curIndex));
                        }
                        else
                        {
                            curIndex = pTotal.Col - mtx.Rows[0].Col + pTotal.GetCount();
                            foreach (RptMtxRow row in mtx.Rows)
                            {
                                args.OpsCells.Add(row, InsertNewCell(mtx, row, curIndex).ToList());
                            }
                        }
                        args.CurIndex = curIndex;
                    }
                }
            }
            else
            {
                mtx = total.Level.Matrix;
                args.BackMtxRow();
            }
            if (parent is RptMtxLevel)
            {
                (parent as RptMtxLevel).SubTotals.Add(total);
            }
            else
            {
                (parent as RptMtxSubtotal).SubTotals.Add(total);
            }
            args.SubTotal = total;
            mtx.Update(true);
            return(total);
        }
Example #21
0
 public MatrixArgs(RptMatrix p_mtx, RptMtxHeaderType p_type)
 {
     Matrix     = p_mtx;
     HeaderType = p_type;
     IsFirst    = true;
 }
Example #22
0
 public RptMtxColHeader(RptMatrix p_matrix)
     : base(p_matrix)
 {
 }
Example #23
0
 public RptMtxHeader(RptMatrix p_matrix)
 {
     _matrix = p_matrix;
 }
Example #24
0
        /// <summary>
        /// 加载矩阵
        /// </summary>
        /// <param name="p_mat"></param>
        void LoadMatrix(RptMatrix p_mat)
        {
            //行头位置信息
            int rowHeaderCol     = p_mat.RowHeader.Col;
            int rowHeaderRowSpan = p_mat.RowHeader.RowSpan;
            int rowHeaderColSpan = p_mat.RowHeader.ColSpan;
            //列头位置信息
            int colHeaderRow     = p_mat.ColHeader.Row;
            int colHeaderRowSpan = p_mat.ColHeader.RowSpan;
            int colHeaderColSpan = p_mat.ColHeader.ColSpan;

            if (!p_mat.HideColHeader && !p_mat.HideRowHeader)
            {
                //1、矩阵角
                RptText cor = p_mat.Corner.Item;
                cor.Row     = p_mat.Corner.Row;
                cor.Col     = p_mat.Corner.Col;
                cor.RowSpan = colHeaderRowSpan;
                cor.ColSpan = rowHeaderColSpan;
                if (string.IsNullOrEmpty(cor.Val))
                {
                    cor.Val = "矩阵角";
                }
                LoadText(cor);
            }

            if (!p_mat.HideRowHeader)
            {
                //2、行头
                if (p_mat.RowHeader != null)
                {
                    LoadMtxLevel(p_mat.RowHeader.Levels);
                }
                //更新矩阵所占列数
                p_mat.ColSpan = rowHeaderColSpan + colHeaderColSpan;
            }

            if (!p_mat.HideColHeader)
            {
                //3、列头
                if (p_mat.ColHeader != null)
                {
                    LoadMtxLevel(p_mat.ColHeader.Levels);
                }
                //更新矩阵所占行数
                p_mat.RowSpan = colHeaderRowSpan + rowHeaderRowSpan;
            }

            //4、数据行
            if (p_mat.Rows != null)
            {
                int sRow = colHeaderRow + (p_mat.HideColHeader ? 0 : colHeaderRowSpan);
                int sCol = rowHeaderCol + (p_mat.HideRowHeader ? 0 : rowHeaderColSpan);
                for (int i = 0; i < p_mat.Rows.Count; i++)
                {
                    RptMtxRow row = p_mat.Rows[i];
                    for (int j = 0; j < row.Cells.Count; j++)
                    {
                        RptText cell = row.Cells[j];
                        cell.Row = sRow + i;
                        cell.Col = sCol + j;
                        LoadText(cell);
                    }
                }
            }
        }
Example #25
0
 public RptMtxRowHeader(RptMatrix p_matrix)
     : base(p_matrix)
 {
 }
Example #26
0
        /// <summary>
        /// 切换页面时在新页重复行头
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        void OnHorPageBegin(object sender, RptPage e)
        {
            RptMatrix matrix = base._item as RptMatrix;

            if (!matrix.HideRowHeader && matrix.RepeatRowHeader)
            {
                _isHasHorBreak = true;
                RptRootInst root = sender as RptRootInst;
                //不存在定义,取第一页定义添加到当前页定义
                //添加的定义应该以矩阵开始行(列)为开始位置
                if (!e.IsColHasDefine())
                {
                    e.Cols.Size.InsertRange(0, root.Cols[0].Size.GetRange(matrix.Col, matrix.RowHeader.ColSpan));
                }
                else if (!e.IsRowHasDefine())
                {
                    e.Rows.Size.InsertRange(0, root.Rows[0].Size.GetRange(matrix.Row, matrix.ColHeader.RowSpan));
                }

                int span  = matrix.RowHeader.ColSpan;
                int start = e.Cols.Start;
                //外层列号变更
                if (_outPutPart == MtxOutPutPart.Cells)
                {
                    _regCells.Col = start + span;
                }
                else
                {
                    _regColHeader.Col = start + span;
                }

                //再次递归调用时确保数据完整
                //行头Region
                RptRegion headerClone = _regRowHeader.Clone();

                //数据源记录索引
                int index = RptData.Current;

                //外部输出的行头索引
                int rowIndex = _rowIndex;

                //外部正在输出的部分
                RptMtxHeaderInst curPart = _rowPart;
                if (!matrix.HideColHeader && !matrix.HideRowHeader)
                {
                    RptTextInst newCorner = CornerInst.Clone();
                    newCorner.Region = new RptRegion(_regRowHeader.Row - matrix.ColHeader.RowSpan, start, matrix.ColHeader.RowSpan, matrix.RowHeader.ColSpan);
                    newCorner.Output();
                }

                //从已输出的索引处开始输出
                for (int i = rowIndex; i < RowHeaderInsts.Count; i++)
                {
                    RptMtxHeaderInst instClone = RowHeaderInsts[i].Clone();
                    _rowPart         = instClone;
                    instClone.Region = new RptRegion(_regRowHeader.Row, start, instClone.Item.RowSpan, instClone.Item.ColSpan);
                    //输出过程中可能触发分页事件,提前计算新行位置,输出后还原
                    _regRowHeader.Row += matrix.ColHeader.RowSpan;
                    instClone.Output();
                    _regRowHeader.Row -= matrix.ColHeader.RowSpan;
                    _regRowHeader.Row += 1;
                    //下次输出位置已经输出过,不再输出
                    if (_rowUsed.Contains(_regRowHeader.Row) && _colUsed.Contains(start))
                    {
                        break;
                    }
                    _rowIndex++;
                }
                _rowPart        = curPart;
                _rowIndex       = rowIndex;
                RptData.Current = index;
                _regRowHeader   = headerClone.Clone();
                //后移 span 个格
                if (_outPutPart == MtxOutPutPart.Cells)
                {
                    _cellPart.Region.Col = start + span;
                }
                else
                {
                    _colPart.TxtInsts[0].Region.Col = start + span;
                }
                //将占用列加入到列表
                for (int i = 0; i < span; i++)
                {
                    if (!_colUsed.Contains(start + i))
                    {
                        _colUsed.Add(start + i);
                    }
                }
            }
        }
Example #27
0
        /// <summary>
        /// 切换页面时在新页重复列头
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        void OnVerPageBegin(object sender, RptPage e)
        {
            RptMatrix matrix = base._item as RptMatrix;

            if (!matrix.HideColHeader && matrix.RepeatColHeader)
            {
                RptRootInst root = sender as RptRootInst;
                //当不存在水平分页时,加入列头的定义
                if (!_isHasHorBreak)
                {
                    e.Rows.Size.InsertRange(0, root.Rows[0].Size.GetRange(matrix.Row, matrix.ColHeader.RowSpan));
                }

                int span  = matrix.ColHeader.RowSpan;
                int start = e.Rows.Start;
                //外层列号变更

                if (_outPutPart == MtxOutPutPart.Cells)
                {
                    _regCells.Row = start + span;
                }
                else
                {
                    _regRowHeader.Row = start + span;
                }

                //再次递归调用时确保数据完整
                //行头Region
                RptRegion headerClone = _regColHeader.Clone();

                //数据源记录索引
                int index = RptData.Current;

                //外部输出的列头索引
                int colIndex = _colIndex;

                //外部正在输出的部分
                RptMtxHeaderInst curPart = _colPart;
                if (!matrix.HideColHeader && !matrix.HideRowHeader)
                {
                    RptTextInst newCorner = CornerInst.Clone();
                    newCorner.Region = new RptRegion(start, _regColHeader.Col - matrix.RowHeader.ColSpan, matrix.ColHeader.RowSpan, matrix.RowHeader.ColSpan);
                    newCorner.Output();
                }

                for (int i = _colIndex; i < ColHeaderInsts.Count; i++)
                {
                    RptMtxHeaderInst instClone = ColHeaderInsts[i].Clone();
                    _colPart         = instClone;
                    instClone.Region = new RptRegion(start, _regColHeader.Col, instClone.Item.RowSpan, instClone.Item.ColSpan);
                    //输出过程中可能触发分页事件,提前计算新列位置,输出后还原
                    _regColHeader.Col += matrix.RowHeader.ColSpan;
                    instClone.Output();
                    _regColHeader.Col -= matrix.RowHeader.ColSpan;
                    _regColHeader.Col += 1;
                    //下次输出位置已经输出过,不再输出
                    if (_colUsed.Contains(_regColHeader.Col) && _rowUsed.Contains(start))
                    {
                        break;
                    }
                    _colIndex++;
                }
                _colPart        = curPart;
                _colIndex       = colIndex;
                RptData.Current = index;
                _regColHeader   = headerClone.Clone();
                //后移 span 个格
                if (_outPutPart == MtxOutPutPart.Cells)
                {
                    _cellPart.Region.Row = start + span;
                }
                else
                {
                    _rowPart.TxtInsts[0].Region.Row = start + span;
                }

                //将占用行加入到列表
                for (int i = 0; i < span; i++)
                {
                    if (!_rowUsed.Contains(start + i))
                    {
                        _rowUsed.Add(start + i);
                    }
                }
            }
        }
Example #28
0
        protected override void DoOutput()
        {
            RptRootInst root     = Inst;
            RptMatrix   matrix   = base._item as RptMatrix;
            RptRegion   regClone = _region.Clone();

            _region.RowSpan = 0;
            _region.ColSpan = 0;
            //矩阵角
            if (!matrix.HideColHeader && !matrix.HideRowHeader)
            {
                CornerInst.Region = new RptRegion(_region.Row, _region.Col, matrix.ColHeader.RowSpan, matrix.RowHeader.ColSpan);
                CornerInst.Output();
                _region.RowSpan += matrix.Corner.RowSpan;
                _region.ColSpan += matrix.Corner.ColSpan;
            }

            root.HorPageBegin += OnHorPageBegin;
            root.VerPageBegin += OnVerPageBegin;
            _rowIndex          = _colIndex = 0;
            //列头
            //可能出现水平分页、垂直分页相互调用,所以行、列Region都定义
            _regColHeader = regClone.Clone();
            _regRowHeader = regClone.Clone();
            if (!matrix.HideRowHeader)
            {
                _regColHeader.Col += matrix.RowHeader.ColSpan;
            }
            if (!matrix.HideColHeader)
            {
                _outPutPart        = MtxOutPutPart.ColHeader;
                _regRowHeader.Row += matrix.ColHeader.RowSpan;
                foreach (RptMtxHeaderInst inst in ColHeaderInsts)
                {
                    _colPart    = inst;
                    inst.Region = new RptRegion(_regColHeader.Row, _regColHeader.Col, inst.Item.RowSpan, inst.Item.ColSpan);
                    inst.Output();
                    _regColHeader.Col += 1;
                    _colIndex++;
                    _region.ColSpan++;
                }
            }

            //行头
            //可能出现水平分页、垂直分页相互调用,所以行、列Region都定义
            _colIndex     = 0;
            _regColHeader = regClone.Clone();
            _regRowHeader = regClone.Clone();
            if (!matrix.HideColHeader)
            {
                _regRowHeader.Row += matrix.ColHeader.RowSpan;
            }
            if (!matrix.HideRowHeader)
            {
                _outPutPart        = MtxOutPutPart.RowHeader;
                _regColHeader.Col += matrix.RowHeader.ColSpan;
                foreach (RptMtxHeaderInst inst in RowHeaderInsts)
                {
                    _rowPart    = inst;
                    inst.Region = new RptRegion(_regRowHeader.Row, _regRowHeader.Col, inst.Item.RowSpan, inst.Item.ColSpan);
                    inst.Output();
                    _regRowHeader.Row += 1;
                    _rowIndex++;
                    _region.RowSpan++;
                }
            }

            //数据
            //还原行头、列头为开始状态(用于分页)
            _rowIndex     = _colIndex = 0;
            _regColHeader = regClone.Clone();
            _regRowHeader = regClone.Clone();
            _regCells     = regClone.Clone();
            if (!matrix.HideRowHeader)
            {
                _regColHeader.Col += matrix.RowHeader.ColSpan;
                _regCells.Col     += matrix.RowHeader.ColSpan;
            }
            if (!matrix.HideColHeader)
            {
                _regRowHeader.Row += matrix.ColHeader.RowSpan;
                _regCells.Row     += matrix.ColHeader.RowSpan;
            }
            int colindex = 0;
            int col      = _regCells.Col;

            _outPutPart = MtxOutPutPart.Cells;
            foreach (RptTextInst inst in _cellInsts)
            {
                _cellPart       = inst;
                RptData.Current = GetCurrent(inst.Filter);
                //换行
                if (colindex == ColHeaderInsts.Count)
                {
                    _regCells.Row += 1;
                    //当前行被占用,下移
                    while (_rowUsed.Contains(_regCells.Row))
                    {
                        _regCells.Row++;
                    }
                    _regCells.Col = col;
                    colindex      = 0;
                }
                if (colindex != 0)
                {
                    _regCells.Col++;
                    //当前列被占用,下移
                    while (_colUsed.Contains(_regCells.Col))
                    {
                        _regCells.Col++;
                    }
                }
                inst.Region = new RptRegion(_regCells.Row, _regCells.Col, inst.Item.RowSpan, inst.Item.ColSpan);
                inst.Output();
                colindex++;
            }
            root.HorPageBegin -= OnHorPageBegin;
            root.VerPageBegin -= OnVerPageBegin;
        }
Example #29
0
 public RptMtxRow(RptMatrix p_matrix)
 {
     _matrix = p_matrix;
     Cells   = new List <RptText>();
 }
Example #30
0
        public override object Execute(object p_args)
        {
            SubTitleCmdArgs  args       = (SubTitleCmdArgs)p_args;
            RptItemBase      parent     = args.Parent;
            RptMtxHeaderType headerType = RptMtxHeaderType.Col;
            RptMtxSubtitle   title      = args.SubTitle;
            RptMatrix        mtx        = null;

            if (title == null)
            {
                title = new RptMtxSubtitle(parent);
                args.InitData();
                if (parent is RptMtxLevel)
                {
                    RptMtxLevel pLevel = parent as RptMtxLevel;
                    mtx = pLevel.Matrix;
                    if (pLevel.Parent is RptMtxRowHeader)
                    {
                        headerType = RptMtxHeaderType.Row;
                    }
                    title.Item.Val = string.Format("subtitle{0}", mtx.GetMaxTitle());

                    RptMtxHeader header = pLevel.Parent as RptMtxHeader;
                    if (pLevel.SubTitles.Count > 0 || header.Levels.Count > header.Levels.IndexOf(pLevel) + 1)
                    {
                        int curIndex = 0;
                        if (headerType == RptMtxHeaderType.Row)
                        {
                            int subLevelSpan = 0;
                            if (header.Levels.Count > header.Levels.IndexOf(pLevel) + 1)
                            {
                                subLevelSpan = header.Levels[header.Levels.IndexOf(pLevel) + 1].RowSpan;
                            }

                            curIndex = pLevel.Row - mtx.ColHeader.Row - mtx.ColHeader.RowSpan + subLevelSpan + pLevel.GetTitleSpan(pLevel.SubTitles);
                            args.OpsRows.Add(InsertNewRow(mtx, curIndex));
                        }
                        else
                        {
                            int subLevelSpan = 0;
                            if (header.Levels.Count > header.Levels.IndexOf(pLevel) + 1)
                            {
                                subLevelSpan = header.Levels[header.Levels.IndexOf(pLevel) + 1].ColSpan;
                            }

                            curIndex = pLevel.Col - mtx.RowHeader.Col - mtx.RowHeader.ColSpan + subLevelSpan + pLevel.GetTitleSpan(pLevel.SubTitles);
                            foreach (RptMtxRow row in mtx.Rows)
                            {
                                args.OpsCells.Add(row, InsertNewCell(mtx, row, curIndex).ToList());
                            }
                        }
                        args.CurIndex = curIndex;
                    }
                    pLevel.SubTitles.Add(title);
                }
                else
                {
                    RptMtxSubtitle pTitle = parent as RptMtxSubtitle;
                    mtx = pTitle.Level.Matrix;
                    if (pTitle.Level.Parent is RptMtxRowHeader)
                    {
                        headerType = RptMtxHeaderType.Row;
                    }
                    title.Item.Val = string.Format("subtitle{0}", mtx.GetMaxTitle());
                    if (pTitle.SubTitles.Count > 0)
                    {
                        int curIndex = 0;
                        if (headerType == RptMtxHeaderType.Row)
                        {
                            curIndex = pTitle.Row + pTitle.RowSpan - mtx.ColHeader.Row - mtx.ColHeader.RowSpan;
                            args.OpsRows.Add(InsertNewRow(mtx, curIndex));
                        }
                        else
                        {
                            curIndex = pTitle.Col + pTitle.ColSpan - mtx.RowHeader.Col - mtx.RowHeader.ColSpan;
                            foreach (RptMtxRow row in mtx.Rows)
                            {
                                args.OpsCells.Add(row, InsertNewCell(mtx, row, curIndex).ToList());
                            }
                        }
                        args.CurIndex = curIndex;
                    }
                    pTitle.SubTitles.Add(title);
                }
                args.SubTitle = title;
            }
            else
            {
                mtx = title.Level.Matrix;
                if (parent is RptMtxLevel)
                {
                    args.BackMtxRow();
                    (parent as RptMtxLevel).SubTitles.Add(title);
                }
                else
                {
                    (parent as RptMtxSubtitle).SubTitles.Add(title);
                }
            }
            mtx.Update(true);
            return(title);
        }