123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121 |
- using FastReport.Table;
- using System;
- using System.Collections.Generic;
- using System.Linq.Expressions;
- namespace FastReport.Engine
- {
- partial class ReportEngine
- {
- private void InitializePages()
- {
- for (int i = 0; i < Report.Pages.Count; i++)
- {
- ReportPage page = Report.Pages[i] as ReportPage;
- if (page != null)
- {
- PreparedPages.AddSourcePage(page);
- }
- }
- }
- /// <summary>
- /// Translate RichObject to series of ReportComponentBase objects
- /// </summary>
- /// <param name="rich"></param>
- internal float Translate_Rich(RichObject rich)
- {
- BandBase parentBand = rich.Parent as BandBase;
- float height = 0;
- bool isRich = rich.Text.StartsWith(@"{\rtf");
- if (rich.localVisibleStorage && rich.ConvertRichText)
- {
- height = rich.Convert2ReportObjects();
- }
- return height;
- }
- private void TranslateTableObject(TableBase table)
- {
- foreach (Base obj in table.AllObjects)
- {
- if (obj is RichObject)
- {
- RichObject rich = obj as RichObject;
- if (rich.Visible && rich.ConvertRichText)
- {
- float height = rich.Convert2ReportObjects();
- TableCell cell = rich.Parent as TableCell;
- foreach (ComponentBase trnslated_ojbect in rich.TransltedObjects)
- {
- trnslated_ojbect.Parent = cell;
- }
- rich.Visible = false;
- }
- }
- }
- }
- /// <summary>
- /// This code splits RichObject to report objects
- /// </summary>
- /// <param name="parentBand"></param>
- public void TranslateObjects(BandBase parentBand)
- {
- int originalObjectsCount = parentBand.Objects.Count;
- float shift = 0;
- for (int i = 0; i < originalObjectsCount; i++)
- {
- ComponentBase obj = parentBand.Objects[i];
- obj.Top += shift;
- if (obj is RichObject)
- {
- bool useVisibleExpression = !String.IsNullOrEmpty(obj.VisibleExpression);
- RichObject rich = obj as RichObject;
- if (rich.ConvertRichText)
- {
- if(useVisibleExpression)
- {
- obj.Visible = (bool) Report.Calc(Code.CodeUtils.FixExpressionWithBrackets(obj.VisibleExpression));
- if (!obj.Visible)
- continue;
- }
- Translate_Rich(rich);
- rich.SecondStageTranslation();
- if (useVisibleExpression)
- rich.FlagPreviewVisible = false;
- }
- }
- if (obj is TableObject)
- {
- TranslateTableObject(obj as TableBase);
- }
- }
- }
- internal void RestoreRich(RichObject rich)
- {
- BandBase parentBand = rich.Parent as BandBase;
- foreach (ComponentBase obj in rich.TransltedObjects)
- {
- if (parentBand != null)
- {
- parentBand.RemoveChild(obj);
- parentBand.Objects.Remove(obj);
- }
- else if (rich.Parent is TableCell)
- {
- TableCell cell = rich.Parent as TableCell;
- cell.RemoveChild(obj);
- cell.Objects.Remove(obj);
- }
- obj.SetParent(null);
- }
- rich.TransltedObjects.Clear();
- }
- }
- }
|