Example #1
0
        /// <summary>
        /// 输出报表项
        /// </summary>
        /// <param name="p_item">报表项</param>
        public void OutputItem(RptOutputInst p_item)
        {
            PrepareItem(p_item);

            // 报表项所在页位置
            int     pageX = GetPageIndex(Cols, p_item.Region.Col);
            int     pageY = GetPageIndex(Rows, p_item.Region.Row);
            RptPage page  = GetPage(pageX, pageY);

            if (page == null)
            {
                page = CreatePage(pageX, pageY);
            }

            if (p_item.Parent is RptTblRowInst && p_item.Region.Row != p_item.Parent.Region.Row)
            {
                p_item.Region.Row = p_item.Parent.Region.Row;
            }

            page.AddItem(p_item);
        }
Example #2
0
        /// <summary>
        /// 自动行高时重置行高,前提:
        /// 1. AutoHeight为true
        /// 2. 只占一行
        /// 3. 当前输出位置在页的末尾
        /// 4. 测量高度大于原高度
        /// </summary>
        /// <param name="p_item"></param>
        /// <param name="p_height"></param>
        public void SyncRowHeight(RptTextInst p_item, double p_height)
        {
            PageDefine rows   = p_item.Page.Rows;
            RptRegion  region = p_item.Region;

            // 只支持当前输出位置在页的末尾,非末尾情况效率太低!
            if (region.Row != rows.Start + rows.Count - 1)
            {
                return;
            }

            // 无需调整
            int index = rows.Count - 1;

            if (p_height <= rows.Size[index] || _pageEnding)
            {
                return;
            }

            // 上部高度
            double topHeight = 0;

            for (int i = 0; i < index; i++)
            {
                topHeight += rows.Size[i];
            }

            // 当前页能放下
            if (topHeight + p_height <= BodyHeight - TblFooterHeight)
            {
                rows.Size[index] = p_height;
                return;
            }

            // 需要垂直分页

            // 记录同行项
            RptPage prePage      = p_item.Page;
            var     sameRowItems = (from item in prePage.Items
                                    where item.Region.Row == region.Row
                                    select item).ToList();

            rows.Size.RemoveAt(index);

            if (VerPageEnd != null)
            {
                _pageEnding = true;
                VerPageEnd(this, rows);
                _pageEnding = false;
            }

            PageDefine next = new PageDefine();

            next.Start = rows.Start + rows.Count;
            Rows.Add(next);

            // 重新计算行位置
            int    newIndex    = next.Start + next.Count;
            double validHeight = BodyHeight - TblFooterHeight - next.Size.Sum();

            if (p_height > validHeight)
            {
                p_height = validHeight;
            }
            next.Size.Add(p_height);

            // 处理同行项
            RptPage page = CreatePage(prePage.X, prePage.Y + 1);

            foreach (var item in sameRowItems)
            {
                item.Region.Row = newIndex;
                prePage.Items.Remove(item);
                page.AddItem(item);
            }
        }