// Returns true if all paragraphs in a range belong to the same block, // so they can be easily grouped and ungrouped. internal static bool IsListOperationApplicable(TextRange range) { // First check, if range start/end are parented by ListItems within the same parent list. if (IsRangeWithinSingleList(range)) { return(true); } // Adjust range end so that it does not affect a following paragraph. TextPointer end = (TextPointer)TextRangeEdit.GetAdjustedRangeEnd(range.Start, range.End); // Now try plain Paragraphs Block firstBlock = range.Start.ParagraphOrBlockUIContainer; Block lastBlock = end.ParagraphOrBlockUIContainer; if (firstBlock != null && lastBlock != null && firstBlock.Parent == lastBlock.Parent) { return(true); } // Allow list editing at potential paragraph positions, this includes // positions in initial RichTextBox, empty TableCell, empty ListItem where paragraphs were not yet created. if (range.IsEmpty && TextPointerBase.IsAtPotentialParagraphPosition(range.Start)) { return(true); } return(false); }
// Token: 0x06003879 RID: 14457 RVA: 0x000FD0D4 File Offset: 0x000FB2D4 private static void CreateImplicitParagraphIfNeededAndUpdateSelection(TextSelection thisSelection) { TextPointer textPointer = thisSelection.Start; if (TextPointerBase.IsAtPotentialParagraphPosition(textPointer)) { textPointer = TextRangeEditTables.EnsureInsertionPosition(textPointer); thisSelection.Select(textPointer, textPointer); } }
private static void CreateImplicitParagraphIfNeededAndUpdateSelection(TextSelection thisSelection) { // Create implicit paragraph if we are at a potential paragraph position, such as empty FlowDocument, TableCell. TextPointer position = thisSelection.Start; if (TextPointerBase.IsAtPotentialParagraphPosition(position)) { position = TextRangeEditTables.EnsureInsertionPosition(position); thisSelection.Select(position, position); } }
// Token: 0x06003B82 RID: 15234 RVA: 0x0010EF28 File Offset: 0x0010D128 internal static bool ConvertParagraphsToListItems(TextRange range, TextMarkerStyle markerStyle) { if (range.IsEmpty && TextPointerBase.IsAtPotentialParagraphPosition(range.Start)) { TextPointer textPointer = TextRangeEditTables.EnsureInsertionPosition(range.Start); ((ITextRange)range).Select(textPointer, textPointer); } Block paragraphOrBlockUIContainer = range.Start.ParagraphOrBlockUIContainer; TextPointer textPointer2 = (TextPointer)TextRangeEdit.GetAdjustedRangeEnd(range.Start, range.End); Block paragraphOrBlockUIContainer2 = textPointer2.ParagraphOrBlockUIContainer; if (paragraphOrBlockUIContainer == null || paragraphOrBlockUIContainer2 == null || paragraphOrBlockUIContainer.Parent != paragraphOrBlockUIContainer2.Parent || (paragraphOrBlockUIContainer.Parent is ListItem && paragraphOrBlockUIContainer.PreviousBlock == null)) { return(false); } Block block = paragraphOrBlockUIContainer; while (block != paragraphOrBlockUIContainer2 && block != null) { if (block is Table || block is Section) { return(false); } block = block.NextBlock; } ListItem listItem = paragraphOrBlockUIContainer.Parent as ListItem; if (listItem != null) { Block block3; for (Block block2 = paragraphOrBlockUIContainer; block2 != null; block2 = block3) { block3 = ((block2 == paragraphOrBlockUIContainer2) ? null : (block2.ElementEnd.GetAdjacentElement(LogicalDirection.Forward) as Block)); Invariant.Assert(block2.Parent is ListItem); TextRangeEdit.SplitElement(block2.ElementStart); } } else { new List { MarkerStyle = markerStyle }.Apply(paragraphOrBlockUIContainer, paragraphOrBlockUIContainer2); } return(true); }
internal static bool ConvertParagraphsToListItems(TextRange range, TextMarkerStyle markerStyle) { if (range.IsEmpty && TextPointerBase.IsAtPotentialParagraphPosition(range.Start)) { TextPointer insertionPosition = TextRangeEditTables.EnsureInsertionPosition(range.Start); ((ITextRange)range).Select(insertionPosition, insertionPosition); } Block firstBlock = range.Start.ParagraphOrBlockUIContainer; TextPointer end = (TextPointer)TextRangeEdit.GetAdjustedRangeEnd(range.Start, range.End); Block lastBlock = end.ParagraphOrBlockUIContainer; // We assume that a range contains a sequence of one-level paragraphs. // Otherwise the operation is disabled. if (firstBlock == null || lastBlock == null || firstBlock.Parent != lastBlock.Parent || firstBlock.Parent is ListItem && firstBlock.PreviousBlock == null) { // Either the paragraphs belong to different scopes or first of them has a bullet already. // We cannot convert them into bulleted lists. return(false); } // Check that all top-level elements of selection are Paragraphs. // We do not apply the command to Tables or Sections. for (Block block = firstBlock; block != lastBlock && block != null; block = block.NextBlock) { if (block is Table || block is Section) { return(false); } } ListItem parentListItem = firstBlock.Parent as ListItem; if (parentListItem != null) { // Paragraphs are inside of ListItem already. // Split a current ListItem before each of selected blocks Block block = firstBlock; while (block != null) { Block nextBlock = block == lastBlock ? null : block.ElementEnd.GetAdjacentElement(LogicalDirection.Forward) as Block; Invariant.Assert(block.Parent is ListItem); TextRangeEdit.SplitElement(block.ElementStart); block = nextBlock; } } else { // Create a list around all paragraphs List list = new List(); list.MarkerStyle = markerStyle; list.Apply(firstBlock, lastBlock); // Merge with neighboring lists //MergeLists(list.ElementEnd); // start with End to not loose an instance of "list" during merging with the following list //MergeLists(list.ElementStart); } 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))); }