Пример #1
0
        string TableGetRowElementName(TableRow tr)
        {
            for (ReportLink rl = tr.Parent; !(rl is Table); rl = rl.Parent)
            {
                if (rl is Header || rl is Footer)
                {
                    return(null);
                }

                if (rl is TableGroup)
                {
                    TableGroup tg = rl as TableGroup;
                    Grouping   g  = tg.Grouping;
                    return(g.DataElementName);
                }

                if (rl is Details)
                {
                    Table t = (Table)stkReportItem.Peek();

                    return(t.DetailDataElementOutput == DataElementOutputEnum.NoOutput?
                           null: t.DetailDataElementName);
                }
            }

            return(null);
        }
        List<TableGroup> _Items;			// list of TableGroup entries

		public TableGroups(ReportDefn r, ReportLink p, XmlNode xNode) : base(r, p)
		{
			TableGroup tg;
            _Items = new List<TableGroup>();
			// Loop thru all the child nodes
			foreach(XmlNode xNodeLoop in xNode.ChildNodes)
			{
				if (xNodeLoop.NodeType != XmlNodeType.Element)
					continue;
				switch (xNodeLoop.Name)
				{
					case "TableGroup":
						tg = new TableGroup(r, this, xNodeLoop);
						break;
					default:	
						tg=null;		// don't know what this is
						// don't know this element - log it
						OwnerReport.rl.LogError(4, "Unknown TableGroups element '" + xNodeLoop.Name + "' ignored.");
						break;
				}
				if (tg != null)
					_Items.Add(tg);
			}
			if (_Items.Count == 0)
				OwnerReport.rl.LogError(8, "For TableGroups at least one TableGroup is required.");
			else
                _Items.TrimExcess();
		}
Пример #3
0
        private void RunRecursiveGroups(IPresent ip, TableWorkClass wc)
        {
            List <Row> rows = wc.Data.Data;
            Row        r;

            // Get any header/footer information for use in loop
            Header     header = null;
            Footer     footer = null;
            TableGroup tg     = wc.RecursiveGroup.Parent as TableGroup;

            if (tg != null)
            {
                header = tg.Header;
                footer = tg.Footer;
            }

            bool bHeader = true;

            for (int iRow = 0; iRow < rows.Count; iRow++)
            {
                r = rows[iRow];
                wc.Data.CurrentGroups[0] = r.GroupEntry;
                wc.GroupNestCount        = r.GroupEntry.EndRow - r.GroupEntry.StartRow;
                if (bHeader)
                {
                    bHeader = false;
                    if (header != null)
                    {
                        header.Run(ip, r);
                    }
                }

                if (_Details != null)
                {
                    _Details.Run(ip, wc.Data, iRow, iRow);
                }

                // determine need for group headers and/or footers
                if (iRow < rows.Count - 1)
                {
                    Row r2 = rows[iRow + 1];
                    if (r.Level > r2.Level)
                    {
                        if (footer != null)
                        {
                            footer.Run(ip, r);
                        }
                    }
                    else if (r.Level < r2.Level)
                    {
                        bHeader = true;
                    }
                }
            }
            if (footer != null)
            {
                footer.Run(ip, rows[rows.Count - 1] as Row);
            }
        }
Пример #4
0
        Rows GetNestedData(Report rpt, Row row)
        {
            if (row == null)
            {
                return(null);
            }

            ReportLink rl = this.Parent;

            while (rl != null)
            {
                if (rl is TableGroup || rl is List || rl is MatrixCell)
                {
                    break;
                }
                rl = rl.Parent;
            }
            if (rl == null)
            {
                return(null);                                   // should have been caught as an error
            }
            Grouping g = null;

            if (rl is TableGroup)
            {
                TableGroup tg = rl as TableGroup;
                g = tg.Grouping;
            }
            else if (rl is List)
            {
                List l = rl as List;
                g = l.Grouping;
            }
            else if (rl is MatrixCell)
            {
                MatrixCellEntry mce = this.GetMC(rpt);
                return(new Rows(rpt, mce.Data));
            }
            if (g == null)
            {
                return(null);
            }

            GroupEntry ge = row.R.CurrentGroups[g.GetIndex(rpt)];

            return(new Rows(rpt, row.R, ge.StartRow, ge.EndRow, null));
        }
Пример #5
0
        public void RunPageHeader(Pages pgs, Row frow, bool bFirst, TableGroup stoptg)
        {
            // Do the table headers
            bool isEmpty = pgs.CurrentPage.IsEmpty();

            if (_Header != null && (_Header.RepeatOnNewPage || bFirst))
            {
                _Header.RunPage(pgs, frow);
                if (isEmpty)
                {
                    pgs.CurrentPage.SetEmpty();                                 // Consider this empty of data
                }
            }

            if (bFirst)                                                                 // the very first time we'll output the header (and not consider page empty)
            {
                return;
            }

            if (_TableGroups == null)
            {
                pgs.CurrentPage.SetEmpty();                             // Consider this empty of data
                return;
            }

            // Do the group headers
            foreach (TableGroup tg in _TableGroups.Items)
            {
                if (stoptg != null && tg == stoptg)
                {
                    break;
                }
                if (tg.Header != null)
                {
                    if (tg.Header.RepeatOnNewPage)
                    {
                        tg.Header.RunPage(pgs, frow);
                    }
                }
            }

            pgs.CurrentPage.SetEmpty();                         // Consider this empty of data

            return;
        }
Пример #6
0
        private float RunGroupsFooterHeight(Pages pgs, TableWorkClass wc, GroupEntry ge)
        {
            Grouping g = ge.Group;

            if (g == null)
            {
                return(0);
            }

            TableGroup tg = g.Parent as TableGroup;                     // detail groups will result in null

            if (tg == null || tg.Footer == null)
            {
                return(0);
            }

            return(tg.Footer.HeightOfRows(pgs, wc.Data.Data[ge.EndRow]));
        }
Пример #7
0
        List <TableGroup> _Items;                        // list of TableGroup entries

        public TableGroups(ReportDefn r, ReportLink p, XmlNode xNode) : base(r, p)
        {
            TableGroup tg;

            _Items = new List <TableGroup>();
            // Loop thru all the child nodes
            foreach (XmlNode xNodeLoop in xNode.ChildNodes)
            {
                if (xNodeLoop.NodeType != XmlNodeType.Element)
                {
                    continue;
                }
                switch (xNodeLoop.Name)
                {
                case "TableGroup":
                    tg = new TableGroup(r, this, xNodeLoop);
                    break;

                default:
                    tg = null;                                          // don't know what this is
                    // don't know this element - log it
                    OwnerReport.rl.LogError(4, "Unknown TableGroups element '" + xNodeLoop.Name + "' ignored.");
                    break;
                }
                if (tg != null)
                {
                    _Items.Add(tg);
                }
            }
            if (_Items.Count == 0)
            {
                OwnerReport.rl.LogError(8, "For TableGroups at least one TableGroup is required.");
            }
            else
            {
                _Items.TrimExcess();
            }
        }
Пример #8
0
 private int RunGroupsCount(List <GroupEntry> groupEntries, int count)
 {
     foreach (GroupEntry ge in groupEntries)
     {
         Grouping g = ge.Group;
         if (g != null)
         {
             TableGroup tg = g.Parent as TableGroup;
             if (tg != null)
             {
                 count += (tg.HeaderCount + tg.FooterCount);
             }
         }
         if (ge.NestedGroup.Count > 0)
         {
             count = RunGroupsCount(ge.NestedGroup, count);
         }
         else
         {
             count += (ge.EndRow - ge.StartRow + 1) * DetailsCount;
         }
     }
     return(count);
 }
Пример #9
0
        private void RunGroupsPage(Pages pgs, TableWorkClass wc, List <GroupEntry> groupEntries, int endRow, float groupHeight)
        {
            Report rpt = pgs.Report;

            foreach (GroupEntry ge in groupEntries)
            {
                // set the group entry value
                int index;
                if (ge.Group != null)                   // groups?
                {
                    ge.Group.ResetHideDuplicates(rpt);  // reset duplicate checking
                    index = ge.Group.GetIndex(rpt);     // yes
                }
                else                                    // no; must be main dataset
                {
                    index = 0;
                }
                wc.Data.CurrentGroups[index] = ge;

                if (ge.NestedGroup.Count > 0)
                {
                    RunGroupsSetGroups(rpt, wc, ge.NestedGroup);
                }

                // Handle the group header
                if (ge.Group != null)
                {
                    TableGroup tg = ge.Group.Parent as TableGroup;
                    if (ge.Group.PageBreakAtStart && !pgs.CurrentPage.IsEmpty())
                    {
                        RunPageNew(pgs, pgs.CurrentPage);
                        RunPageHeader(pgs, wc.Data.Data[ge.StartRow], false, tg);
                    }

                    if (tg != null && tg.Header != null)
                    {
                        // Calculate the number of table rows below this group; header, footer, details count
                        if (ge.NestedGroup.Count > 0)
                        {
                            wc.GroupNestCount = RunGroupsCount(ge.NestedGroup, 0);
                        }
                        else
                        {
                            wc.GroupNestCount = (ge.EndRow - ge.StartRow + 1) * DetailsCount;
                        }

                        tg.Header.RunPage(pgs, wc.Data.Data[ge.StartRow]);
                        wc.GroupNestCount = 0;
                    }
                }
                float footerHeight = RunGroupsFooterHeight(pgs, wc, ge);
                if (ge.EndRow == endRow)
                {
                    footerHeight += groupHeight;
                }
                // Handle the nested groups if any
                if (ge.NestedGroup.Count > 0)
                {
                    RunGroupsPage(pgs, wc, ge.NestedGroup, ge.EndRow, footerHeight);
                }
                // If no nested groups then handle the detail rows for the group
                else if (_Details != null)
                {
                    if (ge.Group != null &&
                        ge.Group.Parent as TableGroup == null)
                    {                           // Group defined on table; means that Detail rows only put out once per group
                        _Details.RunPage(pgs, wc.Data, ge.StartRow, ge.StartRow, footerHeight);
                    }
                    else
                    {
                        _Details.RunPage(pgs, wc.Data, ge.StartRow, ge.EndRow, footerHeight);
                    }
                }
                else                    // When no details we need to figure out whether any more fits on a page
                {
                    Page p = pgs.CurrentPage;
                    if (p.YOffset + footerHeight > pgs.BottomOfPage)                     //	Do we need new page to fit footer?
                    {
                        p = RunPageNew(pgs, p);
                        RunPageHeader(pgs, wc.Data.Data[ge.EndRow], false, null);
                    }
                }

                // Do the group footer
                if (ge.Group != null && ge.Group.Parent != null)
                {
                    TableGroup tg = ge.Group.Parent as TableGroup;                      // detail groups will result in null
                    if (tg != null && tg.Footer != null)
                    {
                        tg.Footer.RunPage(pgs, wc.Data.Data[ge.EndRow]);
                    }

                    if (ge.Group.PageBreakAtEnd && !pgs.CurrentPage.IsEmpty())
                    {
                        RunPageNew(pgs, pgs.CurrentPage);
                        RunPageHeader(pgs, wc.Data.Data[ge.StartRow], false, tg);
                    }
                }
            }
        }
Пример #10
0
        private void RunGroups(IPresent ip, List <GroupEntry> groupEntries, TableWorkClass wc)
        {
            Report     rpt = ip.Report();
            GroupEntry fge = (GroupEntry)(groupEntries[0]);

            if (fge.Group != null)
            {
                ip.GroupingStart(fge.Group);
            }

            foreach (GroupEntry ge in groupEntries)
            {
                // set the group entry value
                int index;
                if (ge.Group != null)                   // groups?
                {
                    ip.GroupingInstanceStart(ge.Group);
                    ge.Group.ResetHideDuplicates(rpt);                  // reset duplicate checking
                    index = ge.Group.GetIndex(rpt);                     // yes
                }
                else                                                    // no; must be main dataset
                {
                    index = 0;
                }
                wc.Data.CurrentGroups[index] = ge;

                if (ge.NestedGroup.Count > 0)
                {
                    RunGroupsSetGroups(rpt, wc, ge.NestedGroup);
                }

                // Handle the group header
                if (ge.Group != null && ge.Group.Parent != null)
                {
                    TableGroup tg = ge.Group.Parent as TableGroup;
                    if (tg != null && tg.Header != null)
                    {
                        // Calculate the number of table rows below this group; header, footer, details count
                        if (ge.NestedGroup.Count > 0)
                        {
                            wc.GroupNestCount = RunGroupsCount(ge.NestedGroup, 0);
                        }
                        else
                        {
                            wc.GroupNestCount = (ge.EndRow - ge.StartRow + 1) * DetailsCount;
                        }
                        tg.Header.Run(ip, wc.Data.Data[ge.StartRow]);
                        wc.GroupNestCount = 0;
                    }
                }
                // Handle the nested groups if any
                if (ge.NestedGroup.Count > 0)
                {
                    RunGroups(ip, ge.NestedGroup, wc);
                }
                // If no nested groups then handle the detail rows for the group
                else if (_Details != null)
                {
                    if (ge.Group != null &&
                        ge.Group.Parent as TableGroup == null)
                    {                           // Group defined on table; means that Detail rows only put out once per group
                        _Details.Run(ip, wc.Data, ge.StartRow, ge.StartRow);
                    }
                    else
                    {
                        _Details.Run(ip, wc.Data, ge.StartRow, ge.EndRow);
                    }
                }

                // Do the group footer
                if (ge.Group != null)
                {
                    if (ge.Group.Parent != null)
                    {
                        TableGroup tg = ge.Group.Parent as TableGroup;                          // detail groups will result in null
                        if (tg != null && tg.Footer != null)
                        {
                            tg.Footer.Run(ip, wc.Data.Data[ge.EndRow]);
                        }
                    }
                    ip.GroupingInstanceEnd(ge.Group);
                }
            }
            if (fge.Group != null)
            {
                ip.GroupingEnd(fge.Group);
            }
        }
Пример #11
0
        private void RunRecursiveGroupsPage(Pages pgs, TableWorkClass wc)
        {
            List <Row> rows = wc.Data.Data;
            Row        r;

            // Get any header/footer information for use in loop
            Header     header = null;
            Footer     footer = null;
            TableGroup tg     = wc.RecursiveGroup.Parent as TableGroup;

            if (tg != null)
            {
                header = tg.Header;
                footer = tg.Footer;
            }

            bool bHeader = true;

            for (int iRow = 0; iRow < rows.Count; iRow++)
            {
                r = rows[iRow];
                wc.Data.CurrentGroups[0] = r.GroupEntry;
                wc.GroupNestCount        = r.GroupEntry.EndRow - r.GroupEntry.StartRow;
                if (bHeader)
                {
                    bHeader = false;
                    if (header != null)
                    {
                        Page  p      = pgs.CurrentPage;                                         // this can change after running a row
                        float height = p.YOffset + header.HeightOfRows(pgs, r);
                        if (height > pgs.BottomOfPage)
                        {
                            p = RunPageNew(pgs, p);
                            RunPageHeader(pgs, r, false, null);
                            if (!header.RepeatOnNewPage)
                            {
                                header.RunPage(pgs, r);
                            }
                        }
                        else
                        {
                            header.RunPage(pgs, r);
                        }
                    }
                }

                // determine need for group headers and/or footers
                bool  bFooter      = false;
                float footerHeight = 0;

                if (iRow < rows.Count - 1)
                {
                    Row r2 = rows[iRow + 1];
                    if (r.Level > r2.Level)
                    {
                        if (footer != null)
                        {
                            bFooter      = true;
                            footerHeight = footer.HeightOfRows(pgs, r);
                        }
                    }
                    else if (r.Level < r2.Level)
                    {
                        bHeader = true;
                    }
                }

                if (_Details != null)
                {
                    _Details.RunPage(pgs, wc.Data, iRow, iRow, footerHeight);
                }

                // and output the footer if needed
                if (bFooter)
                {
                    footer.RunPage(pgs, r);
                }
            }
            if (footer != null)
            {
                footer.RunPage(pgs, rows[rows.Count - 1] as Row);
            }
        }