Ejemplo n.º 1
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);
        }
Ejemplo n.º 2
0
        /// <summary>
        /// Assigns another <see cref="TableCellData"/> instance at run time.
        /// </summary>
        /// <param name="cell">The table cell data that used as a source.</param>
        /// <param name="copyChildren">This flag shows should children be copied or not.</param>
        /// <remarks>This method is called when we print a table. We should create a copy of the cell and set the style.</remarks>
        public void RunTimeAssign(TableCell cell, bool copyChildren)
        {
            Text           = cell.Text;
            Value          = cell.Value;
            HyperlinkValue = cell.Hyperlink.Value;
            // don't copy ColSpan, RowSpan - they will be handled in the TableHelper.
            //ColSpan = cell.ColSpan;
            //RowSpan = cell.RowSpan;

            // clone objects
            objects = null;
            if (cell.Objects != null && copyChildren)
            {
                objects = new ReportComponentCollection();
                foreach (ReportComponentBase obj in cell.Objects)
                {
                    if (obj.Visible)
                    {
                        ReportComponentBase cloneObj = Activator.CreateInstance(obj.GetType()) as ReportComponentBase;
                        cloneObj.AssignAll(obj);
                        cloneObj.Name = obj.Name;
                        objects.Add(cloneObj);
                    }
                }
            }

            // add the cell to the style list. If the list contains such style,
            // return the existing style; in other case, create new style based
            // on the given cell.
            SetStyle(cell);
            // FCell is used to reference the original cell. It is necessary to use Alias, OriginalComponent
            this.cell = cell;

            // reset object's location as if we set ColSpan and RowSpan to 1.
            // It is nesessary when printing spanned cells because the span of such cells will be corrected
            // when print new rows/columns and thus will move cell objects.
            if (objects != null)
            {
                UpdateLayout(Width, Height, Width - cell.CellData.Width, Height - cell.CellData.Height);
            }
        }
Ejemplo 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();
            }
        }