// Token: 0x06003D15 RID: 15637 RVA: 0x0011BB88 File Offset: 0x00119D88 private TextTreeNode CopyElementNode(TextTreeTextElementNode elementNode, out TextTreeDeleteContentUndoUnit.ContentContainer container) { if (elementNode.TextElement is Table) { container = new TextTreeDeleteContentUndoUnit.TableElementContentContainer(elementNode.TextElement as Table, TextTreeUndoUnit.GetPropertyRecordArray(elementNode.TextElement), this.CopyContent((TextTreeNode)elementNode.GetFirstContainedNode(), null)); } else { container = new TextTreeDeleteContentUndoUnit.ElementContentContainer(elementNode.TextElement.GetType(), TextTreeUndoUnit.GetPropertyRecordArray(elementNode.TextElement), elementNode.TextElement.Resources, this.CopyContent((TextTreeNode)elementNode.GetFirstContainedNode(), null)); } return((TextTreeNode)elementNode.GetNextNode()); }
// Copies a TextElement and all its contained content into a ContentContainer. // Returns the next node to examine. private TextTreeNode CopyElementNode(TextTreeTextElementNode elementNode, out ContentContainer container) { if (elementNode.TextElement is Table) { container = new TableElementContentContainer(elementNode.TextElement as Table, GetPropertyRecordArray(elementNode.TextElement), CopyContent((TextTreeNode)elementNode.GetFirstContainedNode(), null)); } else { container = new ElementContentContainer(elementNode.TextElement.GetType(), GetPropertyRecordArray(elementNode.TextElement), elementNode.TextElement.Resources, CopyContent((TextTreeNode)elementNode.GetFirstContainedNode(), null)); } return((TextTreeNode)elementNode.GetNextNode()); }
// Copies a TextElement and all its contained content into a ContentContainer. // Returns the next node to examine. private TextTreeNode CopyElementNode(TextTreeTextElementNode elementNode, out ContentContainer container) { if(elementNode.TextElement is Table) { container = new TableElementContentContainer(elementNode.TextElement as Table, GetPropertyRecordArray(elementNode.TextElement), CopyContent((TextTreeNode)elementNode.GetFirstContainedNode(), null)); } else { container = new ElementContentContainer(elementNode.TextElement.GetType(), GetPropertyRecordArray(elementNode.TextElement), elementNode.TextElement.Resources, CopyContent((TextTreeNode)elementNode.GetFirstContainedNode(), null)); } return (TextTreeNode)elementNode.GetNextNode(); }
// Removes an element node from its sibling tree. // // If deep == true, then this method also removes any contained nodes // and returns a deep copy of them. // // If deep == false, any contained nodes are inserted into the original // node's sibling tree. private void ExtractElementFromSiblingTree(SplayTreeNode containingNode, TextTreeTextElementNode elementNode, bool deep) { TextTreeNode previousNode; ElementEdge previousEdge; TextTreeNode nextNode; ElementEdge nextEdge; SplayTreeNode childNode; SplayTreeNode minChildNode; SplayTreeNode maxChildNode; SplayTreeNode localRootNode; TextTreeNode firstContainedNode; TextTreeNode lastContainedNode; // Remember the nodes surrounding the one we're going to remove. previousNode = (TextTreeNode)elementNode.GetPreviousNode(); previousEdge = ElementEdge.AfterEnd; if (previousNode == null) { previousNode = (TextTreeNode)containingNode; previousEdge = ElementEdge.AfterStart; } nextNode = (TextTreeNode)elementNode.GetNextNode(); nextEdge = ElementEdge.BeforeStart; if (nextNode == null) { nextNode = (TextTreeNode)containingNode; nextEdge = ElementEdge.BeforeEnd; } // Remove the element node. elementNode.Remove(); Invariant.Assert(elementNode.Role == SplayTreeNodeRole.LocalRoot); if (deep) { // Increment previous/nextNode reference counts. This may involve // splitting a text node, so we use refs. AdjustRefCountsForContentDelete(ref previousNode, previousEdge, ref nextNode, nextEdge, elementNode); // Reparent the removed node with a FixupNode, so that any orphaned // positions can find their way back to the tree. // We have to do this after the AdjustRefCountsForContentDelete call, because the fixup // node doesn't act like a regular node. elementNode.ParentNode = new TextTreeFixupNode(previousNode, previousEdge, nextNode, nextEdge); DeepCopy(elementNode); } else { // Reparent contained nodes to elementNode's parent. childNode = elementNode.ContainedNode; elementNode.ContainedNode = null; if (childNode != null) { childNode.ParentNode = null; firstContainedNode = (TextTreeNode)childNode.GetMinSibling(); lastContainedNode = (TextTreeNode)childNode.GetMaxSibling(); } else { firstContainedNode = null; lastContainedNode = null; } // Increment previous/nextNode reference counts. This may involve // splitting a text node, so we use refs. AdjustRefCountsForShallowDelete(ref previousNode, previousEdge, ref nextNode, nextEdge, ref firstContainedNode, ref lastContainedNode, elementNode); // Reparent the removed node with a FixupNode, so that any orphaned // positions can find their way back to the tree. // We have to do this after the AdjustRefCountsForContentDelete call, because the fixup // node doesn't act like a regular node. elementNode.ParentNode = new TextTreeFixupNode(previousNode, previousEdge, nextNode, nextEdge, firstContainedNode, lastContainedNode); if (childNode != null) { // Get previous/next nodes into roots of individual trees. // Then merge them with the element's children. // We need to splay childNode because it may no longer be a local root. // The addrefs in AdjustRefCountsForShallowDelete may have created new nodes // and shuffled the tree. childNode.Splay(); localRootNode = childNode; if (previousNode != containingNode) { previousNode.Split(); Invariant.Assert(previousNode.Role == SplayTreeNodeRole.LocalRoot); Invariant.Assert(previousNode.RightChildNode == null); minChildNode = childNode.GetMinSibling(); minChildNode.Splay(); previousNode.RightChildNode = minChildNode; minChildNode.ParentNode = previousNode; localRootNode = previousNode; } if (nextNode != containingNode) { nextNode.Splay(); Invariant.Assert(nextNode.Role == SplayTreeNodeRole.LocalRoot); Invariant.Assert(nextNode.LeftChildNode == null); maxChildNode = childNode.GetMaxSibling(); maxChildNode.Splay(); nextNode.LeftChildNode = maxChildNode; nextNode.LeftSymbolCount += maxChildNode.LeftSymbolCount + maxChildNode.SymbolCount; nextNode.LeftCharCount += maxChildNode.LeftCharCount + maxChildNode.IMECharCount; maxChildNode.ParentNode = nextNode; localRootNode = nextNode; } containingNode.ContainedNode = localRootNode; if (localRootNode != null) { localRootNode.ParentNode = containingNode; } } } }