Exemplo n.º 1
0
        public bool ContainsBand(Type bandType)
        {
            for (int i = 0; i < xmlItem.Count; i++)
            {
                XmlItem xi = xmlItem[i];

                BandBase obj = preparedPages.Dictionary.GetOriginalObject(xi.Name) as BandBase;
                if (obj != null && obj.GetType() == bandType)
                {
                    return(true);
                }
            }

            return(false);
        }
Exemplo n.º 2
0
        private BandBase CloneBand(BandBase band)
        {
            // clone a band and all its objects
            BandBase cloneBand = Activator.CreateInstance(band.GetType()) as BandBase;

            cloneBand.Assign(band);
            cloneBand.SetReport(Report);
            cloneBand.SetRunning(true);

            foreach (ReportComponentBase obj in band.Objects)
            {
                ReportComponentBase cloneObj = Activator.CreateInstance(obj.GetType()) as ReportComponentBase;
                cloneObj.AssignAll(obj);
                cloneBand.Objects.Add(cloneObj);
            }
            return(cloneBand);
        }
Exemplo n.º 3
0
        private void BreakBand(BandBase band)
        {
            BandBase cloneBand = Activator.CreateInstance(band.GetType()) as BandBase;

            cloneBand.Assign(band);
            cloneBand.SetRunning(true);
            cloneBand.FlagMustBreak = band.FlagMustBreak;

            // clone band objects:
            // - remove bands that can break, convert them to Text objects if necessary
            // - skip subreports
            foreach (Base c in band.Objects)
            {
                if (c is BandBase && (c as BandBase).CanBreak)
                {
                    BandBase b = c as BandBase;
                    if (b.HasBorder || b.HasFill)
                    {
                        TextObject textObj = new TextObject();
                        textObj.Bounds = b.Bounds;
                        textObj.Border = b.Border.Clone();
                        textObj.Fill   = b.Fill.Clone();
                        cloneBand.Objects.Add(textObj);
                    }

                    foreach (ReportComponentBase obj in b.Objects)
                    {
                        if (!(obj is BandBase))
                        {
                            ReportComponentBase cloneObj = Activator.CreateInstance(obj.GetType()) as ReportComponentBase;
                            cloneObj.AssignAll(obj);
                            cloneObj.Anchor = AnchorStyles.Left | AnchorStyles.Top;
                            cloneObj.Dock   = DockStyle.None;
                            cloneObj.Left   = obj.AbsLeft - band.AbsLeft;
                            cloneObj.Top    = obj.AbsTop - band.AbsTop;
                            if (cloneObj is TextObject)
                            {
                                (cloneObj as TextObject).Highlight.Clear();
                            }
                            cloneBand.Objects.Add(cloneObj);
                        }
                    }
                }
                else if (!(c is SubreportObject))
                {
                    Base cloneObj = Activator.CreateInstance(c.GetType()) as Base;
                    cloneObj.AssignAll(c);
                    cloneObj.Parent = cloneBand;
                }
            }

            BandBase breakTo = Activator.CreateInstance(band.GetType()) as BandBase;

            breakTo.Assign(band);
            breakTo.SetRunning(true);
            breakTo.Child             = null;
            breakTo.CanGrow           = true;
            breakTo.StartNewPage      = false;
            breakTo.OutlineExpression = "";
            breakTo.BeforePrintEvent  = "";
            breakTo.BeforeLayoutEvent = "";
            breakTo.AfterPrintEvent   = "";
            breakTo.AfterLayoutEvent  = "";
            // breakTo must be breaked because it will print on a new page.
            breakTo.FlagMustBreak = true;

            // to allow clone and breaked bands to access Report
            cloneBand.SetReport(Report);
            breakTo.SetReport(Report);

            try
            {
                // (case: object with Anchor = bottom on a breakable band)
                // disable re-layout
                cloneBand.SetUpdatingLayout(true);
                cloneBand.Height = FreeSpace;
                cloneBand.SetUpdatingLayout(false);

                if (cloneBand.Break(breakTo))
                {
                    AddToPreparedPages(cloneBand);
                    EndColumn();
                    ShowBand(breakTo, false);
                }
                else
                {
                    if (cloneBand.FlagMustBreak)
                    {
                        // show band as is
                        breakTo.FlagCheckFreeSpace = false;
                        AddToPreparedPages(breakTo);
                    }
                    else
                    {
                        EndColumn();
                        ShowBand(breakTo, false);
                    }
                }
            }
            finally
            {
                cloneBand.Dispose();
                breakTo.Dispose();
            }
        }
Exemplo n.º 4
0
        internal void AddToPreparedPages(BandBase band)
        {
            bool isReportSummary = band is ReportSummaryBand;

            // check if band is service band (e.g. page header/footer/overlay).
            BandBase mainBand = band;

            // for child bands, check its parent band.
            if (band is ChildBand)
            {
                mainBand = (band as ChildBand).GetTopParentBand;
            }
            bool isPageBand   = mainBand is PageHeaderBand || mainBand is PageFooterBand || mainBand is OverlayBand;
            bool isColumnBand = mainBand is ColumnHeaderBand || mainBand is ColumnFooterBand;

            // check if we have enough space for a band.
            bool checkFreeSpace = !isPageBand && !isColumnBand && band.FlagCheckFreeSpace;

            if (checkFreeSpace && FreeSpace < band.Height)
            {
                // we don't have enough space. What should we do?
                // - if band can break, break it
                // - if band cannot break, check the band height:
                //   - it's the first row of a band and is bigger than page: break it immediately.
                //   - in other case, add a new page/column and tell the band that it must break next time.
                if (band.CanBreak || band.FlagMustBreak || (band.AbsRowNo == 1 && band.Height > PageHeight - PageFooterHeight))
                {
                    // since we don't show the column footer band in the EndLastPage, do it here.
                    if (isReportSummary)
                    {
                        ShowReprintFooters();
                        ShowBand(page.ColumnFooter);
                    }
                    BreakBand(band);
                    return;
                }
                else
                {
                    EndColumn();
                    band.FlagMustBreak = true;
                    AddToPreparedPages(band);
                    band.FlagMustBreak = false;
                    return;
                }
            }
            else
            {
                // since we don't show the column footer band in the EndLastPage, do it here.
                if (isReportSummary)
                {
                    if ((band as ReportSummaryBand).KeepWithData)
                    {
                        EndKeep();
                    }
                    ShowReprintFooters(false);
                    ShowBand(page.ColumnFooter);
                }
            }

            // check if we have a child band with FillUnusedSpace flag
            if (band.Child != null && band.Child.FillUnusedSpace)
            {
                // if we reprint a data/group footer, do not include the band height into calculation:
                // it is already counted in FreeSpace
                float bandHeight = band.Height;
                if (band.Repeated)
                {
                    bandHeight = 0;
                }
                while (FreeSpace - bandHeight - band.Child.Height >= 0)
                {
                    float saveCurY = CurY;
                    ShowBand(band.Child);
                    // nothing was printed, break to avoid an endless loop
                    if (CurY == saveCurY)
                    {
                        break;
                    }
                }
            }

            // adjust the band location
            if (band is PageFooterBand && !UnlimitedHeight)
            {
                CurY = PageHeight - GetBandHeightWithChildren(band);
            }
            if (!isPageBand)
            {
                band.Left += originX + CurX;
            }
            if (band.PrintOnBottom)
            {
                CurY = PageHeight - PageFooterHeight - ColumnFooterHeight;
                // if PrintOnBottom is applied to a band like DataFooter, print it with all its child bands
                // if PrintOnBottom is applied to a child band, print this band only.
                if (band is ChildBand)
                {
                    CurY -= band.Height;
                }
                else
                {
                    CurY -= GetBandHeightWithChildren(band);
                }
            }
            band.Top = CurY;

            // shift the band and decrease its width when printing hierarchy
            float saveLeft  = band.Left;
            float saveWidth = band.Width;

            if (!isPageBand && !isColumnBand)
            {
                band.Left  += hierarchyIndent;
                band.Width -= hierarchyIndent;
            }

            // add outline
            AddBandOutline(band);

            // add bookmarks
            band.AddBookmarks();

            // put the band to prepared pages. Do not put page bands twice
            // (this may happen when we render a subreport, or append a report to another one).
            bool bandAdded         = true;
            bool bandAlreadyExists = false;

            if (isPageBand)
            {
                if (band is ChildBand)
                {
                    bandAlreadyExists = PreparedPages.ContainsBand(band.Name);
                }
                else
                {
                    bandAlreadyExists = PreparedPages.ContainsBand(band.GetType());
                }
            }

            if (!bandAlreadyExists)
            {
                bandAdded = PreparedPages.AddBand(band);
            }

            // shift CurY
            if (bandAdded && !(mainBand is OverlayBand))
            {
                CurY += band.Height;
            }

            // set left&width back
            band.Left  = saveLeft;
            band.Width = saveWidth;
        }