@@ -18,14 +18,30 @@ CompositionTextRangeProvider::CompositionTextRangeProvider(
1818}
1919
2020HRESULT __stdcall CompositionTextRangeProvider::Clone (ITextRangeProvider **pRetVal) {
21- // no-op
22- *pRetVal = nullptr ;
21+ if (pRetVal == nullptr )
22+ return E_POINTER;
23+
24+ auto clone = winrt::make<winrt::Microsoft::ReactNative::implementation::CompositionTextRangeProvider>(
25+ m_view.view ().as <winrt::Microsoft::ReactNative::Composition::ComponentView>(), m_parentProvider.get ());
26+ *pRetVal = clone.detach ();
2327 return S_OK;
2428}
2529
2630HRESULT __stdcall CompositionTextRangeProvider::Compare (ITextRangeProvider *range, BOOL *pRetVal) {
27- // no-op
28- *pRetVal = false ;
31+ if (pRetVal == nullptr )
32+ return E_POINTER;
33+ if (range == nullptr ) {
34+ *pRetVal = FALSE ;
35+ return S_OK;
36+ }
37+
38+ // Try to cast to our type , considering provider only supports a single range per view
39+ auto other = dynamic_cast <CompositionTextRangeProvider *>(range);
40+ if (other && other->m_view .view () == m_view.view ()) {
41+ *pRetVal = TRUE ;
42+ } else {
43+ *pRetVal = FALSE ;
44+ }
2945 return S_OK;
3046}
3147
@@ -34,7 +50,10 @@ HRESULT __stdcall CompositionTextRangeProvider::CompareEndpoints(
3450 ITextRangeProvider *targetRange,
3551 TextPatternRangeEndpoint targetEndpoint,
3652 int *pRetVal) {
37- // no-op
53+ if (pRetVal == nullptr )
54+ return E_POINTER;
55+
56+ // For a single-range provider, always equal:
3857 *pRetVal = 0 ;
3958 return S_OK;
4059}
@@ -98,13 +117,13 @@ HRESULT __stdcall CompositionTextRangeProvider::GetAttributeValue(TEXTATTRIBUTEI
98117 textTransform = props->textAttributes .textTransform .value ();
99118 }
100119 if (fontVariant == facebook::react::FontVariant::SmallCaps) {
101- return CapStyle_SmallCap;
120+ pRetVal-> lVal = CapStyle_SmallCap;
102121 } else if (textTransform == facebook::react::TextTransform::Capitalize) {
103- return CapStyle_Titling;
122+ pRetVal-> lVal = CapStyle_Titling;
104123 } else if (textTransform == facebook::react::TextTransform::Lowercase) {
105- return CapStyle_None;
124+ pRetVal-> lVal = CapStyle_None;
106125 } else if (textTransform == facebook::react::TextTransform::Uppercase) {
107- return CapStyle_AllCap;
126+ pRetVal-> lVal = CapStyle_AllCap;
108127 }
109128 } else if (attributeId == UIA_FontNameAttributeId) {
110129 pRetVal->vt = VT_BSTR;
@@ -282,6 +301,8 @@ HRESULT __stdcall CompositionTextRangeProvider::ScrollIntoView(BOOL alignToTop)
282301 return S_OK;
283302}
284303
304+ // All the below methods should be implemented once the selection comes for paragraph and TextInput
305+
285306HRESULT __stdcall CompositionTextRangeProvider::AddToSelection () {
286307 // no-op
287308 return S_OK;
0 commit comments