Ejemplo n.º 1
0
        // Paste flow content into the current text selection
        // Returns false if pasting was not successful - assuming that the caller will choose another format for pasting
        private static bool PasteTextElement(TextEditor This, TextElement sectionOrSpan)
        {
            bool success = false;

            This.Selection.BeginChange();
            try
            {
                ((TextRange)This.Selection).SetXmlVirtual(sectionOrSpan);

                // Merge new Lists with surrounding Lists.
                TextRangeEditLists.MergeListsAroundNormalizedPosition((TextPointer)This.Selection.Start);
                TextRangeEditLists.MergeListsAroundNormalizedPosition((TextPointer)This.Selection.End);

                // Merge flow direction of the new content if it matches its surroundings.
                TextRangeEdit.MergeFlowDirection((TextPointer)This.Selection.Start);
                TextRangeEdit.MergeFlowDirection((TextPointer)This.Selection.End);

                success = true;
            }
            finally
            {
                This.Selection.EndChange();
            }

            return(success);
        }
        // Token: 0x06003B84 RID: 15236 RVA: 0x0010F178 File Offset: 0x0010D378
        internal static void IndentListItems(TextRange range)
        {
            ListItem immediateListItem  = TextPointerBase.GetImmediateListItem(range.Start);
            ListItem immediateListItem2 = TextPointerBase.GetImmediateListItem((TextPointer)TextRangeEdit.GetAdjustedRangeEnd(range.Start, range.End));

            if (immediateListItem == null || immediateListItem2 == null || immediateListItem.Parent != immediateListItem2.Parent || !(immediateListItem.Parent is List))
            {
                return;
            }
            ListItem previousListItem = immediateListItem.PreviousListItem;

            if (previousListItem == null)
            {
                return;
            }
            List element = (List)immediateListItem.Parent;
            List list    = (List)TextRangeEdit.InsertElementClone(immediateListItem.ElementStart, immediateListItem2.ElementEnd, element);

            previousListItem.Reposition(previousListItem.ContentStart, list.ElementEnd);
            Paragraph paragraph = immediateListItem2.Blocks.FirstBlock as Paragraph;

            if (paragraph != null)
            {
                List list2 = paragraph.NextBlock as List;
                if (list2 != null && list2.NextBlock == null)
                {
                    immediateListItem2.Reposition(immediateListItem2.ContentStart, list2.ElementStart);
                    list2.Reposition(null, null);
                }
            }
            TextRangeEditLists.MergeLists(list.ElementStart);
        }
 // Token: 0x06003876 RID: 14454 RVA: 0x000FCE58 File Offset: 0x000FB058
 private static void ToggleNumbering(TextSelection thisSelection, ListItem parentListItem, ListItem immediateListItem, List list)
 {
     if (immediateListItem != null && TextEditorLists.HasNumericMarker(list))
     {
         if (list.Parent is ListItem)
         {
             TextRangeEditLists.UnindentListItems(thisSelection);
             TextRangeEditLists.ConvertListItemsToParagraphs(thisSelection);
             return;
         }
         TextRangeEditLists.UnindentListItems(thisSelection);
         return;
     }
     else
     {
         if (immediateListItem != null)
         {
             list.MarkerStyle = TextMarkerStyle.Decimal;
             return;
         }
         if (parentListItem != null)
         {
             TextRangeEditLists.ConvertParagraphsToListItems(thisSelection, TextMarkerStyle.Decimal);
             TextRangeEditLists.IndentListItems(thisSelection);
             return;
         }
         TextRangeEditLists.ConvertParagraphsToListItems(thisSelection, TextMarkerStyle.Decimal);
         return;
     }
 }
Ejemplo n.º 4
0
 private static void ToggleBullets(TextSelection thisSelection, ListItem parentListItem, ListItem immediateListItem, List list)
 {
     if (immediateListItem != null && HasBulletMarker(list))
     {
         if (list.Parent is ListItem)
         {
             TextRangeEditLists.UnindentListItems(thisSelection);
             TextRangeEditLists.ConvertListItemsToParagraphs(thisSelection);
         }
         else
         {
             TextRangeEditLists.UnindentListItems(thisSelection);
         }
     }
     else if (immediateListItem != null)
     {
         list.MarkerStyle = TextMarkerStyle.Disc;
     }
     else if (parentListItem != null)
     {
         TextRangeEditLists.ConvertParagraphsToListItems(thisSelection, TextMarkerStyle.Disc);
         TextRangeEditLists.IndentListItems(thisSelection);
     }
     else
     {
         TextRangeEditLists.ConvertParagraphsToListItems(thisSelection, TextMarkerStyle.Disc);
     }
 }
Ejemplo n.º 5
0
        private static void DecreaseIndentation(TextSelection thisSelection, ListItem parentListItem, ListItem immediateListItem)
        {
            if (immediateListItem != null)
            {
                TextRangeEditLists.UnindentListItems(thisSelection);
            }
            else if (parentListItem != null)
            {
                TextRangeEditLists.ConvertParagraphsToListItems(thisSelection, TextMarkerStyle.Disc);
                TextRangeEditLists.UnindentListItems(thisSelection);
            }
            else
            {
                if (thisSelection.IsEmpty)
                {
                    // When selection is empty, handle indentation based on current TextIndent property of the paragraph.
                    Block paragraphOrBlockUIContainer = thisSelection.Start.ParagraphOrBlockUIContainer;
                    if (paragraphOrBlockUIContainer is BlockUIContainer)
                    {
                        // Decrement BlockUIContainer's leading margin.
                        TextRangeEdit.IncrementParagraphLeadingMargin(thisSelection, /*increment:*/ 20, PropertyValueAction.DecreaseByAbsoluteValue);
                    }
                    else
                    {
                        // Create implicit paragraph if at a potential paragraph position, such as empty FlowDocument, TableCell.
                        CreateImplicitParagraphIfNeededAndUpdateSelection(thisSelection);

                        Paragraph paragraph = thisSelection.Start.Paragraph;
                        Invariant.Assert(paragraph != null, "EnsureInsertionPosition must guarantee a position in text content");

                        // When selection is empty, handle indentation based on current TextIndent property of the paragraph.
                        if (paragraph.TextIndent > 20)
                        {
                            // Reset text indent to 20.
                            TextRangeEdit.SetParagraphProperty(thisSelection.Start, thisSelection.End, Paragraph.TextIndentProperty, 20.0, PropertyValueAction.SetValue);
                        }
                        else if (paragraph.TextIndent > 0)
                        {
                            // Reset text indent to 0.
                            TextRangeEdit.SetParagraphProperty(thisSelection.Start, thisSelection.End, Paragraph.TextIndentProperty, 0.0, PropertyValueAction.SetValue);
                        }
                        else
                        {
                            // Decrement paragraph leading margin.
                            TextRangeEdit.IncrementParagraphLeadingMargin(thisSelection, /*increment:*/ 20, PropertyValueAction.DecreaseByAbsoluteValue);
                        }
                    }
                }
                else
                {
                    // For non-empty selection, always decrement paragraph margin.
                    TextRangeEdit.IncrementParagraphLeadingMargin(thisSelection, /*increment:*/ 20, PropertyValueAction.DecreaseByAbsoluteValue);
                }
            }
        }
Ejemplo n.º 6
0
        // Common handler for all list editing commands
        private static void OnListCommand(object target, ExecutedRoutedEventArgs args)
        {
            TextEditor This = TextEditor._GetTextEditor(target);

            if (This == null || !This._IsEnabled || This.IsReadOnly || !This.AcceptsRichContent || !(This.Selection is TextSelection))
            {
                return;
            }

            TextEditorTyping._FlushPendingInputItems(This);

            if (!TextRangeEditLists.IsListOperationApplicable((TextSelection)This.Selection))
            {
                return;
            }

            using (This.Selection.DeclareChangeBlock())
            {
                TextSelection thisSelection = (TextSelection)This.Selection;

                ListItem parentListItem    = TextPointerBase.GetListItem(thisSelection.Start);
                ListItem immediateListItem = TextPointerBase.GetImmediateListItem(thisSelection.Start);
                List     list = parentListItem == null ? null : (List)parentListItem.Parent;

                // Forget previously suggested horizontal position
                TextEditorSelection._ClearSuggestedX(This);

                // Execute the command
                if (args.Command == EditingCommands.ToggleBullets)
                {
                    ToggleBullets(thisSelection, parentListItem, immediateListItem, list);
                }
                else if (args.Command == EditingCommands.ToggleNumbering)
                {
                    ToggleNumbering(thisSelection, parentListItem, immediateListItem, list);
                }
                else if (args.Command == EditingCommands.RemoveListMarkers)
                {
                    TextRangeEditLists.ConvertListItemsToParagraphs(thisSelection);
                }
                else if (args.Command == EditingCommands.IncreaseIndentation)
                {
                    IncreaseIndentation(thisSelection, parentListItem, immediateListItem);
                }
                else if (args.Command == EditingCommands.DecreaseIndentation)
                {
                    DecreaseIndentation(thisSelection, parentListItem, immediateListItem);
                }
                else
                {
                    Invariant.Assert(false);
                }
            }
        }
        // Token: 0x06003B88 RID: 15240 RVA: 0x0010F530 File Offset: 0x0010D730
        internal static bool SplitListsForFlowDirectionChange(TextPointer start, TextPointer end, object newFlowDirectionValue)
        {
            ListItem listAncestor = start.GetListAncestor();

            if (listAncestor != null && listAncestor.List != null && !TextSchema.ValuesAreEqual(newFlowDirectionValue, listAncestor.List.GetValue(Block.FlowDirectionProperty)))
            {
                while (listAncestor != null && listAncestor.List != null && listAncestor.List.Parent is ListItem)
                {
                    if (!TextRangeEditLists.UnindentListItems(new TextRange(start, TextRangeEditLists.GetPositionAfterList(listAncestor.List))))
                    {
                        return(false);
                    }
                    listAncestor = start.GetListAncestor();
                }
            }
            ListItem listItem = end.GetListAncestor();

            if (listItem != null && listItem.List != null && !TextSchema.ValuesAreEqual(newFlowDirectionValue, listItem.List.GetValue(Block.FlowDirectionProperty)))
            {
                if (listAncestor == null || listAncestor.List == null || listItem.List.ElementEnd.CompareTo(listAncestor.List.ElementEnd) >= 0)
                {
                    while (listItem != null && listItem.List != null && listItem.List.Parent is ListItem)
                    {
                        if (!TextRangeEditLists.UnindentListItems(new TextRange(listItem.List.ContentStart, TextRangeEditLists.GetPositionAfterList(listItem.List))))
                        {
                            return(false);
                        }
                        listItem = end.GetListAncestor();
                    }
                }
            }
            if ((listAncestor = start.GetListAncestor()) != null && listAncestor.PreviousListItem != null && listAncestor.List != null && !TextSchema.ValuesAreEqual(newFlowDirectionValue, listAncestor.List.GetValue(Block.FlowDirectionProperty)))
            {
                Invariant.Assert(!(listAncestor.List.Parent is ListItem), "startListItem's list must not be nested!");
                TextRangeEdit.SplitElement(listAncestor.ElementStart);
            }
            if ((listItem = end.GetListAncestor()) != null && listItem.List != null && !TextSchema.ValuesAreEqual(newFlowDirectionValue, listItem.List.GetValue(Block.FlowDirectionProperty)))
            {
                if (listItem.List.Parent is ListItem)
                {
                    while (listItem.List != null && listItem.List.Parent is ListItem)
                    {
                        listItem = (ListItem)listItem.List.Parent;
                    }
                }
                if (listItem.List != null && listItem.NextListItem != null)
                {
                    Invariant.Assert(!(listItem.List.Parent is ListItem), "endListItem's list must not be nested!");
                    TextRangeEdit.SplitElement(listItem.ElementEnd);
                }
            }
            return(true);
        }
        // Token: 0x06003B81 RID: 15233 RVA: 0x0010EEB8 File Offset: 0x0010D0B8
        internal static bool IsListOperationApplicable(TextRange range)
        {
            if (TextRangeEditLists.IsRangeWithinSingleList(range))
            {
                return(true);
            }
            TextPointer textPointer = (TextPointer)TextRangeEdit.GetAdjustedRangeEnd(range.Start, range.End);
            Block       paragraphOrBlockUIContainer  = range.Start.ParagraphOrBlockUIContainer;
            Block       paragraphOrBlockUIContainer2 = textPointer.ParagraphOrBlockUIContainer;

            return((paragraphOrBlockUIContainer != null && paragraphOrBlockUIContainer2 != null && paragraphOrBlockUIContainer.Parent == paragraphOrBlockUIContainer2.Parent) || (range.IsEmpty && TextPointerBase.IsAtPotentialParagraphPosition(range.Start)));
        }
        // Token: 0x06003874 RID: 14452 RVA: 0x000FCCBC File Offset: 0x000FAEBC
        private static void OnListCommand(object target, ExecutedRoutedEventArgs args)
        {
            TextEditor textEditor = TextEditor._GetTextEditor(target);

            if (textEditor == null || !textEditor._IsEnabled || textEditor.IsReadOnly || !textEditor.AcceptsRichContent || !(textEditor.Selection is TextSelection))
            {
                return;
            }
            TextEditorTyping._FlushPendingInputItems(textEditor);
            if (!TextRangeEditLists.IsListOperationApplicable((TextSelection)textEditor.Selection))
            {
                return;
            }
            using (textEditor.Selection.DeclareChangeBlock())
            {
                TextSelection textSelection     = (TextSelection)textEditor.Selection;
                ListItem      listItem          = TextPointerBase.GetListItem(textSelection.Start);
                ListItem      immediateListItem = TextPointerBase.GetImmediateListItem(textSelection.Start);
                List          list = (listItem == null) ? null : ((List)listItem.Parent);
                TextEditorSelection._ClearSuggestedX(textEditor);
                if (args.Command == EditingCommands.ToggleBullets)
                {
                    TextEditorLists.ToggleBullets(textSelection, listItem, immediateListItem, list);
                }
                else if (args.Command == EditingCommands.ToggleNumbering)
                {
                    TextEditorLists.ToggleNumbering(textSelection, listItem, immediateListItem, list);
                }
                else if (args.Command == EditingCommands.RemoveListMarkers)
                {
                    TextRangeEditLists.ConvertListItemsToParagraphs(textSelection);
                }
                else if (args.Command == EditingCommands.IncreaseIndentation)
                {
                    TextEditorLists.IncreaseIndentation(textSelection, listItem, immediateListItem);
                }
                else if (args.Command == EditingCommands.DecreaseIndentation)
                {
                    TextEditorLists.DecreaseIndentation(textSelection, listItem, immediateListItem);
                }
                else
                {
                    Invariant.Assert(false);
                }
            }
        }
        // Token: 0x06003863 RID: 14435 RVA: 0x000FC504 File Offset: 0x000FA704
        private static bool PasteTextElement(TextEditor This, TextElement sectionOrSpan)
        {
            bool result = false;

            This.Selection.BeginChange();
            try
            {
                ((TextRange)This.Selection).SetXmlVirtual(sectionOrSpan);
                TextRangeEditLists.MergeListsAroundNormalizedPosition((TextPointer)This.Selection.Start);
                TextRangeEditLists.MergeListsAroundNormalizedPosition((TextPointer)This.Selection.End);
                TextRangeEdit.MergeFlowDirection((TextPointer)This.Selection.Start);
                TextRangeEdit.MergeFlowDirection((TextPointer)This.Selection.End);
                result = true;
            }
            finally
            {
                This.Selection.EndChange();
            }
            return(result);
        }
        // Token: 0x06003878 RID: 14456 RVA: 0x000FCFC8 File Offset: 0x000FB1C8
        private static void DecreaseIndentation(TextSelection thisSelection, ListItem parentListItem, ListItem immediateListItem)
        {
            if (immediateListItem != null)
            {
                TextRangeEditLists.UnindentListItems(thisSelection);
                return;
            }
            if (parentListItem != null)
            {
                TextRangeEditLists.ConvertParagraphsToListItems(thisSelection, TextMarkerStyle.Disc);
                TextRangeEditLists.UnindentListItems(thisSelection);
                return;
            }
            if (!thisSelection.IsEmpty)
            {
                TextRangeEdit.IncrementParagraphLeadingMargin(thisSelection, 20.0, PropertyValueAction.DecreaseByAbsoluteValue);
                return;
            }
            Block paragraphOrBlockUIContainer = thisSelection.Start.ParagraphOrBlockUIContainer;

            if (paragraphOrBlockUIContainer is BlockUIContainer)
            {
                TextRangeEdit.IncrementParagraphLeadingMargin(thisSelection, 20.0, PropertyValueAction.DecreaseByAbsoluteValue);
                return;
            }
            TextEditorLists.CreateImplicitParagraphIfNeededAndUpdateSelection(thisSelection);
            Paragraph paragraph = thisSelection.Start.Paragraph;

            Invariant.Assert(paragraph != null, "EnsureInsertionPosition must guarantee a position in text content");
            if (paragraph.TextIndent > 20.0)
            {
                TextRangeEdit.SetParagraphProperty(thisSelection.Start, thisSelection.End, Paragraph.TextIndentProperty, 20.0, PropertyValueAction.SetValue);
                return;
            }
            if (paragraph.TextIndent > 0.0)
            {
                TextRangeEdit.SetParagraphProperty(thisSelection.Start, thisSelection.End, Paragraph.TextIndentProperty, 0.0, PropertyValueAction.SetValue);
                return;
            }
            TextRangeEdit.IncrementParagraphLeadingMargin(thisSelection, 20.0, PropertyValueAction.DecreaseByAbsoluteValue);
        }
        // Token: 0x06003B7F RID: 15231 RVA: 0x0010EDDC File Offset: 0x0010CFDC
        internal static bool MergeListsAroundNormalizedPosition(TextPointer mergePosition)
        {
            TextPointer textPointer = mergePosition.CreatePointer();

            while (textPointer.GetPointerContext(LogicalDirection.Forward) == TextPointerContext.ElementEnd)
            {
                textPointer.MoveToNextContextPosition(LogicalDirection.Forward);
            }
            bool flag = TextRangeEditLists.MergeLists(textPointer);

            if (!flag)
            {
                textPointer.MoveToPosition(mergePosition);
                while (textPointer.GetPointerContext(LogicalDirection.Backward) == TextPointerContext.ElementStart)
                {
                    textPointer.MoveToNextContextPosition(LogicalDirection.Backward);
                }
                flag = TextRangeEditLists.MergeLists(textPointer);
            }
            return(flag);
        }
        // Token: 0x06003B7E RID: 15230 RVA: 0x0010EB84 File Offset: 0x0010CD84
        internal static bool MergeParagraphs(Block firstParagraphOrBlockUIContainer, Block secondParagraphOrBlockUIContainer)
        {
            if (!TextRangeEditLists.ParagraphsAreMergeable(firstParagraphOrBlockUIContainer, secondParagraphOrBlockUIContainer))
            {
                return(false);
            }
            ListItem listItem = (secondParagraphOrBlockUIContainer.PreviousBlock == null) ? (secondParagraphOrBlockUIContainer.Parent as ListItem) : null;

            if (listItem != null && listItem.PreviousListItem == null && secondParagraphOrBlockUIContainer.NextBlock is List)
            {
                List list = (List)secondParagraphOrBlockUIContainer.NextBlock;
                if (list.ElementEnd.CompareTo(listItem.ContentEnd) == 0)
                {
                    listItem.Reposition(null, null);
                }
                else
                {
                    listItem.Reposition(list.ElementEnd, listItem.ContentEnd);
                }
                list.Reposition(null, null);
            }
            while (secondParagraphOrBlockUIContainer.ElementStart.GetPointerContext(LogicalDirection.Backward) == TextPointerContext.ElementStart)
            {
                TextElement textElement = (TextElement)secondParagraphOrBlockUIContainer.Parent;
                Invariant.Assert(textElement != null);
                Invariant.Assert(TextSchema.AllowsParagraphMerging(textElement.GetType()));
                if (secondParagraphOrBlockUIContainer.ElementEnd.CompareTo(textElement.ContentEnd) == 0)
                {
                    textElement.Reposition(null, null);
                }
                else
                {
                    textElement.Reposition(secondParagraphOrBlockUIContainer.ElementEnd, textElement.ContentEnd);
                }
            }
            TextPointer frozenPointer = secondParagraphOrBlockUIContainer.ElementEnd.GetFrozenPointer(LogicalDirection.Forward);

            for (;;)
            {
                TextElement textElement2 = secondParagraphOrBlockUIContainer.ElementStart.GetAdjacentElement(LogicalDirection.Backward) as TextElement;
                Invariant.Assert(textElement2 != null);
                if (textElement2 is Paragraph || textElement2 is BlockUIContainer)
                {
                    break;
                }
                Invariant.Assert(TextSchema.AllowsParagraphMerging(textElement2.GetType()));
                textElement2.Reposition(textElement2.ContentStart, secondParagraphOrBlockUIContainer.ElementEnd);
            }
            if (secondParagraphOrBlockUIContainer.TextRange.IsEmpty)
            {
                secondParagraphOrBlockUIContainer.RepositionWithContent(null);
            }
            else if (firstParagraphOrBlockUIContainer.TextRange.IsEmpty)
            {
                firstParagraphOrBlockUIContainer.RepositionWithContent(null);
            }
            else if (firstParagraphOrBlockUIContainer is Paragraph && secondParagraphOrBlockUIContainer is Paragraph)
            {
                Invariant.Assert(firstParagraphOrBlockUIContainer.ElementEnd.CompareTo(secondParagraphOrBlockUIContainer.ElementStart) == 0);
                firstParagraphOrBlockUIContainer.Reposition(firstParagraphOrBlockUIContainer.ContentStart, secondParagraphOrBlockUIContainer.ElementEnd);
                TextPointer elementStart = secondParagraphOrBlockUIContainer.ElementStart;
                secondParagraphOrBlockUIContainer.Reposition(null, null);
                TextRangeEdit.MergeFormattingInlines(elementStart);
            }
            ListItem listItem2 = (frozenPointer.GetPointerContext(LogicalDirection.Forward) == TextPointerContext.ElementStart) ? (frozenPointer.GetAdjacentElement(LogicalDirection.Forward) as ListItem) : null;

            if (listItem2 != null && listItem2 == listItem)
            {
                ListItem listItem3 = frozenPointer.GetAdjacentElement(LogicalDirection.Backward) as ListItem;
                if (listItem3 != null)
                {
                    Invariant.Assert(frozenPointer.GetPointerContext(LogicalDirection.Forward) == TextPointerContext.ElementStart);
                    Invariant.Assert(frozenPointer.GetPointerContext(LogicalDirection.Backward) == TextPointerContext.ElementEnd);
                    listItem3.Reposition(listItem3.ContentStart, listItem2.ElementEnd);
                    listItem2.Reposition(null, null);
                }
            }
            TextRangeEditLists.MergeLists(frozenPointer);
            return(true);
        }
        // Token: 0x06003B85 RID: 15237 RVA: 0x0010F26C File Offset: 0x0010D46C
        internal static bool UnindentListItems(TextRange range)
        {
            if (!TextRangeEditLists.IsRangeWithinSingleList(range))
            {
                return(false);
            }
            ListItem listItem  = TextPointerBase.GetListItem(range.Start);
            ListItem listItem2 = TextPointerBase.GetListItem((TextPointer)TextRangeEdit.GetAdjustedRangeEnd(range.Start, range.End));

            for (TextElement textElement = (TextElement)listItem2.Parent; textElement != listItem.Parent; textElement = (TextElement)textElement.Parent)
            {
                listItem2 = (textElement as ListItem);
            }
            if (listItem2 == null)
            {
                return(false);
            }
            if (listItem.PreviousListItem != null)
            {
                TextRangeEdit.SplitElement(listItem.ElementStart);
            }
            if (listItem2.NextListItem != null)
            {
                TextRangeEdit.SplitElement(listItem2.ElementEnd);
            }
            List     list      = (List)listItem.Parent;
            ListItem listItem3 = list.Parent as ListItem;

            if (listItem3 != null)
            {
                list.Reposition(null, null);
                TextPointer contentEnd = listItem3.ContentEnd;
                if (listItem3.ContentStart.CompareTo(listItem.ElementStart) == 0)
                {
                    listItem3.Reposition(null, null);
                }
                else
                {
                    listItem3.Reposition(listItem3.ContentStart, listItem.ElementStart);
                }
                if (contentEnd.CompareTo(listItem2.ElementEnd) != 0)
                {
                    TextPointer contentEnd2 = listItem2.ContentEnd;
                    listItem2.Reposition(listItem2.ContentStart, contentEnd);
                    TextRangeEditLists.MergeLists(contentEnd2);
                }
            }
            else
            {
                TextPointer elementStart = list.ElementStart;
                TextPointer elementEnd   = list.ElementEnd;
                object      value        = list.GetValue(Block.FlowDirectionProperty);
                list.Reposition(null, null);
                ListItem listItem5;
                for (ListItem listItem4 = listItem; listItem4 != null; listItem4 = ((listItem4 == listItem2) ? null : listItem5))
                {
                    listItem5 = (listItem4.ElementEnd.GetAdjacentElement(LogicalDirection.Forward) as ListItem);
                    if (listItem4.ContentStart.CompareTo(listItem4.ContentEnd) == 0)
                    {
                        TextRangeEditTables.EnsureInsertionPosition(listItem4.ContentStart);
                    }
                    listItem4.Reposition(null, null);
                }
                TextRangeEdit.SetParagraphProperty(elementStart, elementEnd, Block.FlowDirectionProperty, value);
                TextRangeEditLists.MergeLists(elementStart);
                TextRangeEditLists.MergeLists(elementEnd);
            }
            return(true);
        }