/// <summary> /// Returns all the layout entities of the specified node. /// </summary> /// <remarks>Note that this method does not work with Run nodes or nodes in the header or footer.</remarks> public LayoutCollection <LayoutEntity> GetLayoutEntitiesOfNode(Node node) { if (!mLayoutCollector.Document.Equals(node.Document)) { throw new ArgumentException("Node does not belong to the same document which was rendered."); } if (node.NodeType == NodeType.Document) { return(new LayoutCollection <LayoutEntity>(mChildEntities)); } List <LayoutEntity> entities = new List <LayoutEntity>(); // Retrieve all entities from the layout document (inversion of LayoutEntityType.None). foreach (LayoutEntity entity in GetChildEntities(~LayoutEntityType.None, true)) { if (entity.ParentNode == node) { entities.Add(entity); } // There is no table entity in rendered output, so manually check if rows belong to a table node. if (entity.Type == LayoutEntityType.Row) { RenderedRow row = (RenderedRow)entity; if (row.Table == node) { entities.Add(entity); } } } return(new LayoutCollection <LayoutEntity>(entities)); }
private LayoutEntity CreateLayoutEntityFromType(LayoutEnumerator it) { LayoutEntity childEntity; switch (it.Type) { case LayoutEntityType.Cell: childEntity = new RenderedCell(); break; case LayoutEntityType.Column: childEntity = new RenderedColumn(); break; case LayoutEntityType.Comment: childEntity = new RenderedComment(); break; case LayoutEntityType.Endnote: childEntity = new RenderedEndnote(); break; case LayoutEntityType.Footnote: childEntity = new RenderedFootnote(); break; case LayoutEntityType.HeaderFooter: childEntity = new RenderedHeaderFooter(); break; case LayoutEntityType.Line: childEntity = new RenderedLine(); break; case LayoutEntityType.NoteSeparator: childEntity = new RenderedNoteSeparator(); break; case LayoutEntityType.Page: childEntity = new RenderedPage(); break; case LayoutEntityType.Row: childEntity = new RenderedRow(); break; case LayoutEntityType.Span: childEntity = new RenderedSpan(it.Text); break; case LayoutEntityType.TextBox: childEntity = new RenderedTextBox(); break; default: throw new InvalidOperationException("Unknown layout type"); } childEntity.mKind = it.Kind; childEntity.mPageIndex = it.PageIndex; childEntity.mRectangle = it.Rectangle; childEntity.mType = it.Type; childEntity.LayoutObject = it.Current; childEntity.mParent = this; return(childEntity); }