Ejemplo n.º 1
0
        // Paste a node in or after another node.
        protected virtual urakawa.command.Command PasteCommandNode(ProjectView.ProjectView view, bool allowAutoSpecialRoleAssign)   //@AssociateNode
        {
            Commands.Node.Paste paste = new Commands.Node.Paste(view);
            paste.AllowRoleChangeAccordingToSurroundingSpecialNodes = allowAutoSpecialRoleAssign;   //@AssociateNode
            CompositeCommand p = view.Presentation.CreateCompositeCommand(paste.ShortDescription);

            p.ChildCommands.Insert(p.ChildCommands.Count, paste);
            if (paste.DeleteSelectedBlock)
            {
                Commands.Node.Delete delete = new Commands.Node.Delete(view, view.Selection.Node);
                delete.UpdateSelection = false;
                p.ChildCommands.Insert(p.ChildCommands.Count, delete);
            }
            // If the node to paste is a heading phrase, revert to a plain phrase.
            // We consider that being a heading is more of a section things (copying sections conserve the heading.)
            if (paste.Copy is PhraseNode && ((PhraseNode)paste.Copy).Role_ == EmptyNode.Role.Heading)
            {
                Commands.Node.AssignRole behead =
                    new Commands.Node.AssignRole(view, (EmptyNode)paste.Copy, EmptyNode.Role.Plain);
                behead.UpdateSelection = false;
                p.ChildCommands.Insert(p.ChildCommands.Count, behead);
            }
            if (paste.Copy.Used && !paste.CopyParent.Used)
            {
                view.AppendMakeUnused(p, paste.Copy);
            }
            return(p);
        }