// ======================================== // method // ======================================== public override void Execute() { _command = null; int blockIndex, charIndexInBlock; var block = _target.GetBlockAtLocal(_index, out blockIndex, out charIndexInBlock); var isLastIndexInLine = false; if (charIndexInBlock == 0) { /// blockの最初の文字を指している場合,blockの直前に空のBlockを作成して挿入する var para = new Paragraph(); block.Transfer(para); _command = new InsertBlockToStyledTextCommand(_target, para, blockIndex); } else { /// blockの途中の文字を指している場合,blockをそこで分割する int lineIndex, charIndexInLine; var line = block.GetLineSegmentAtLocal(charIndexInBlock, out lineIndex, out charIndexInLine); isLastIndexInLine = charIndexInLine == line.Length - 1; if (charIndexInLine == 0) { /// LineSegmentの先頭を指している場合 _command = new InsertLineSegmentToBlockCommand(block, new LineSegment(), lineIndex); _command = _command.Chain(new SplitBlockCommand(block, lineIndex)); } else { _command = new EnsureBlockBreakCommand(_target, _index); } } _command.Execute(); if (charIndexInBlock != 0 && isLastIndexInLine && block.HasNextSibling) { var nextPara = block.NextSibling as Paragraph; var setPara = new SetParagraphPropertiesCommand( nextPara, GetNewPadding(nextPara.GetDefaultPadding(ParagraphKind.Normal), nextPara.ListKind, nextPara.ListLevel), //nextPara.Padding, nextPara.LineSpace, nextPara.HorizontalAlignment, ParagraphKind.Normal, nextPara.ListKind, nextPara.ListLevel, nextPara.ListState ); setPara.Execute(); _command.Chain(setPara); } }