// 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;
     }
 }
Пример #2
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);
     }
 }
Пример #3
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);
                }
            }
        }
        // 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: 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);
        }