/// <summary> /// Creates unique names for all table elements such as rows, columns, cells. /// </summary> public void CreateUniqueNames() { if (Report == null) { return; } FastNameCreator nameCreator = new FastNameCreator(Report.AllNamedObjects); foreach (TableRow row in Rows) { if (String.IsNullOrEmpty(row.Name)) { nameCreator.CreateUniqueName(row); } } foreach (TableColumn column in Columns) { if (String.IsNullOrEmpty(column.Name)) { nameCreator.CreateUniqueName(column); } } for (int y = 0; y < Rows.Count; y++) { for (int x = 0; x < Columns.Count; x++) { TableCell cell = this[x, y]; if (String.IsNullOrEmpty(cell.Name)) { nameCreator.CreateUniqueName(cell); cell.Font = DrawUtils.DefaultReportFont; } if (cell.Objects != null) { foreach (ReportComponentBase obj in cell.Objects) { if (String.IsNullOrEmpty(obj.Name)) { nameCreator.CreateUniqueName(obj); } } } } } }
// update existing columns - add new, delete non-existent, update PropDescriptor public void UpdateExistingObjects(Column column, int maxNestingLevel) { FMaxNestingLevel = maxNestingLevel; FNameCreator = new FastNameCreator(FDictionary.Report.AllNamedObjects); UpdateExistingObjects(column); }
public void Paste() { if (!CanPaste) { return; } using (ClipboardParent parent = new ClipboardParent()) using (MemoryStream stream = Clipboard.GetData("FastReport") as MemoryStream) using (FRReader reader = new FRReader(null)) { reader.Load(stream); reader.Read(parent); PageBase page = FDesigner.ActiveReportTab.ActivePage; if (page.GetType() == parent.PageType) { // prepare to create unique name ObjectCollection allObjects = page.Report.AllNamedObjects; // prepare a list of existing names Hashtable names = new Hashtable(); foreach (Base c in allObjects) { names[c.Name] = 0; } // since we are trying to preserve pasted object's name, add all names to the // allObjects list to guarantee that FastNameCreator will work correctly foreach (Base c in parent.AllObjects) { allObjects.Add(c); // there is an existing object with the same name. Clear the name to indicate // that we should create an unique name for this object if (names.ContainsKey(c.Name)) { c.Name = ""; } } FastNameCreator nameCreator = new FastNameCreator(allObjects); FDesigner.SelectedObjects.Clear(); foreach (Base c in parent.Objects) { c.Parent = FDesigner.ActiveReportTab.ActivePageDesigner.GetParentForPastedObjects(); if (c.Name == "") { nameCreator.CreateUniqueName(c); } // reset group index if (c is ComponentBase) { (c as ComponentBase).GroupIndex = 0; } FDesigner.Objects.Add(c); if (c is IParent) { foreach (Base c1 in c.AllObjects) { if (c1.Name == "") { nameCreator.CreateUniqueName(c1); } FDesigner.Objects.Add(c1); } } FDesigner.SelectedObjects.Add(c); } FDesigner.ActiveReportTab.ActivePageDesigner.Paste(parent.Objects, InsertFrom.Clipboard); } } }