@@ -43,7 +43,9 @@ public partial class AccessibleObject :
4343 UiaCore . ISelectionItemProvider ,
4444 UiaCore . IRawElementProviderHwndOverride ,
4545 UiaCore . IScrollItemProvider ,
46- UiaCore . IMultipleViewProvider
46+ UiaCore . IMultipleViewProvider ,
47+ UiaCore . ITextProvider ,
48+ UiaCore . ITextProvider2
4749 {
4850 /// <summary>
4951 /// Specifies the <see cref='IAccessible'/> interface used by this <see cref='AccessibleObject'/>.
@@ -64,6 +66,9 @@ public partial class AccessibleObject :
6466 // Indicates this object is being used ONLY to wrap a system IAccessible
6567 private readonly bool systemWrapper ;
6668
69+ private UiaTextProvider ? _textProvider ;
70+ private UiaTextProvider2 ? _textProvider2 ;
71+
6772 // The support for the UIA Notification event begins in RS3.
6873 // Assume the UIA Notification event is available until we learn otherwise.
6974 // If we learn that the UIA Notification event is not available,
@@ -350,15 +355,13 @@ internal virtual int ProviderOptions
350355
351356 internal virtual UiaCore . IRawElementProviderSimple ? HostRawElementProvider => null ;
352357
353- internal virtual object ? GetPropertyValue ( UiaCore . UIA propertyID )
354- {
355- if ( propertyID == UiaCore . UIA . IsInvokePatternAvailablePropertyId )
358+ internal virtual object ? GetPropertyValue ( UiaCore . UIA propertyID ) =>
359+ propertyID switch
356360 {
357- return IsInvokePatternAvailable ;
358- }
359-
360- return null ;
361- }
361+ UiaCore . UIA . IsInvokePatternAvailablePropertyId => IsInvokePatternAvailable ,
362+ UiaCore . UIA . BoundingRectanglePropertyId => Bounds ,
363+ _ => null
364+ } ;
362365
363366 private bool IsInvokePatternAvailable
364367 {
@@ -474,6 +477,29 @@ internal virtual void Toggle()
474477
475478 internal virtual void Invoke ( ) => DoDefaultAction ( ) ;
476479
480+ internal virtual UiaCore . ITextRangeProvider ? DocumentRangeInternal => _textProvider ? . DocumentRange ;
481+
482+ internal virtual UiaCore . ITextRangeProvider [ ] ? GetTextSelection ( ) => _textProvider ? . GetSelection ( ) ;
483+
484+ internal virtual UiaCore . ITextRangeProvider [ ] ? GetTextVisibleRanges ( ) => _textProvider ? . GetVisibleRanges ( ) ;
485+
486+ internal virtual UiaCore . ITextRangeProvider ? GetTextRangeFromChild ( UiaCore . IRawElementProviderSimple childElement )
487+ => _textProvider ? . RangeFromChild ( childElement ) ;
488+
489+ internal virtual UiaCore . ITextRangeProvider ? GetTextRangeFromPoint ( Point screenLocation ) => _textProvider ? . RangeFromPoint ( screenLocation ) ;
490+
491+ internal virtual UiaCore . SupportedTextSelection SupportedTextSelectionInternal
492+ => _textProvider ? . SupportedTextSelection ?? UiaCore . SupportedTextSelection . None ;
493+
494+ internal virtual UiaCore . ITextRangeProvider ? GetTextCaretRange ( out BOOL isActive )
495+ {
496+ isActive = BOOL . FALSE ;
497+ return _textProvider2 ? . GetCaretRange ( out isActive ) ;
498+ }
499+
500+ internal virtual UiaCore . ITextRangeProvider ? GetRangeFromAnnotation ( UiaCore . IRawElementProviderSimple annotationElement ) =>
501+ _textProvider2 ? . RangeFromAnnotation ( annotationElement ) ;
502+
477503 internal virtual bool IsReadOnly => false ;
478504
479505 internal virtual void SetValue ( string ? newValue )
@@ -673,6 +699,37 @@ UiaCore.IRawElementProviderSimple[] UiaCore.ILegacyIAccessibleProvider.GetSelect
673699
674700 void UiaCore . IInvokeProvider . Invoke ( ) => Invoke ( ) ;
675701
702+ UiaCore . ITextRangeProvider ? UiaCore . ITextProvider . DocumentRange => DocumentRangeInternal ;
703+
704+ UiaCore . ITextRangeProvider [ ] ? UiaCore . ITextProvider . GetSelection ( ) => GetTextSelection ( ) ;
705+
706+ UiaCore . ITextRangeProvider [ ] ? UiaCore . ITextProvider . GetVisibleRanges ( ) => GetTextVisibleRanges ( ) ;
707+
708+ UiaCore . ITextRangeProvider ? UiaCore . ITextProvider . RangeFromChild ( UiaCore . IRawElementProviderSimple childElement ) =>
709+ GetTextRangeFromChild ( childElement ) ;
710+
711+ UiaCore . ITextRangeProvider ? UiaCore . ITextProvider . RangeFromPoint ( Point screenLocation ) => GetTextRangeFromPoint ( screenLocation ) ;
712+
713+ UiaCore . SupportedTextSelection UiaCore . ITextProvider . SupportedTextSelection => SupportedTextSelectionInternal ;
714+
715+ UiaCore . ITextRangeProvider ? UiaCore . ITextProvider2 . DocumentRange => DocumentRangeInternal ;
716+
717+ UiaCore . ITextRangeProvider [ ] ? UiaCore . ITextProvider2 . GetSelection ( ) => GetTextSelection ( ) ;
718+
719+ UiaCore . ITextRangeProvider [ ] ? UiaCore . ITextProvider2 . GetVisibleRanges ( ) => GetTextVisibleRanges ( ) ;
720+
721+ UiaCore . ITextRangeProvider ? UiaCore . ITextProvider2 . RangeFromChild ( UiaCore . IRawElementProviderSimple childElement ) =>
722+ GetTextRangeFromChild ( childElement ) ;
723+
724+ UiaCore . ITextRangeProvider ? UiaCore . ITextProvider2 . RangeFromPoint ( Point screenLocation ) => GetTextRangeFromPoint ( screenLocation ) ;
725+
726+ UiaCore . SupportedTextSelection UiaCore . ITextProvider2 . SupportedTextSelection => SupportedTextSelectionInternal ;
727+
728+ UiaCore . ITextRangeProvider ? UiaCore . ITextProvider2 . GetCaretRange ( out BOOL isActive ) => GetTextCaretRange ( out isActive ) ;
729+
730+ UiaCore . ITextRangeProvider ? UiaCore . ITextProvider2 . RangeFromAnnotation ( UiaCore . IRawElementProviderSimple annotationElement ) =>
731+ GetRangeFromAnnotation ( annotationElement ) ;
732+
676733 BOOL UiaCore . IValueProvider . IsReadOnly => IsReadOnly ? BOOL . TRUE : BOOL . FALSE ;
677734
678735 string ? UiaCore . IValueProvider . Value => Value ;
@@ -1595,6 +1652,12 @@ protected void UseStdAccessibleObjects(IntPtr handle, int objid)
15951652 }
15961653 }
15971654
1655+ internal void UseTextProviders ( UiaTextProvider textProvider , UiaTextProvider2 textProvider2 )
1656+ {
1657+ _textProvider = textProvider ?? throw new ArgumentNullException ( nameof ( textProvider ) ) ;
1658+ _textProvider2 = textProvider2 ?? throw new ArgumentNullException ( nameof ( textProvider2 ) ) ;
1659+ }
1660+
15981661 /// <summary>
15991662 /// Performs custom navigation between parent/child/sibling accessible
16001663 /// objects. This is basically just a wrapper for GetSysChild(), that
0 commit comments