Skip to content

Commit 3800717

Browse files
authored
Merge pull request #2701 from M-Lipin/dev/v-milipi/Issue_1588_TextPatternProviders
2 parents 1061538 + f2baffc commit 3800717

File tree

53 files changed

+4913
-146
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

53 files changed

+4913
-146
lines changed

src/System.Windows.Forms.Primitives/src/Interop/Richedit/Interop.SCF.cs

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -11,15 +11,15 @@ internal static partial class Richedit
1111
[Flags]
1212
public enum SCF : uint
1313
{
14-
SELECTION = 0x0001,
15-
WORD = 0x0002,
16-
DEFAULT = 0x0000,
17-
ALL = 0x0004,
18-
USEUIRULES = 0x0008,
19-
ASSOCIATEFONT = 0x0010,
20-
NOKBUPDATE = 0x0020,
21-
ASSOCIATEFONT2 = 0x0040,
22-
SMARTFONT = 0x0080,
14+
DEFAULT = 0x0000,
15+
SELECTION = 0x0001,
16+
WORD = 0x0002,
17+
ALL = 0x0004,
18+
USEUIRULES = 0x0008,
19+
ASSOCIATEFONT = 0x0010,
20+
NOKBUPDATE = 0x0020,
21+
ASSOCIATEFONT2 = 0x0040,
22+
SMARTFONT = 0x0080,
2323
CHARREPFROMLCID = 0x0100,
2424
}
2525
}
Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,30 @@
1+
// Licensed to the .NET Foundation under one or more agreements.
2+
// The .NET Foundation licenses this file to you under the MIT license.
3+
// See the LICENSE file in the project root for more information.
4+
5+
using System.Drawing;
6+
using System.Runtime.InteropServices;
7+
8+
internal static partial class Interop
9+
{
10+
internal static partial class UiaCore
11+
{
12+
[ComImport]
13+
[Guid("3589c92c-63f3-4367-99bb-ada653b77cf2")]
14+
[InterfaceType(ComInterfaceType.InterfaceIsIUnknown)]
15+
public interface ITextProvider
16+
{
17+
ITextRangeProvider[]? GetSelection();
18+
19+
ITextRangeProvider[]? GetVisibleRanges();
20+
21+
ITextRangeProvider? RangeFromChild(IRawElementProviderSimple childElement);
22+
23+
ITextRangeProvider? RangeFromPoint(Point screenLocation);
24+
25+
ITextRangeProvider? DocumentRange { get; }
26+
27+
SupportedTextSelection SupportedTextSelection { get; }
28+
}
29+
}
30+
}
Lines changed: 34 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,34 @@
1+
// Licensed to the .NET Foundation under one or more agreements.
2+
// The .NET Foundation licenses this file to you under the MIT license.
3+
// See the LICENSE file in the project root for more information.
4+
5+
using System.Drawing;
6+
using System.Runtime.InteropServices;
7+
8+
internal static partial class Interop
9+
{
10+
internal static partial class UiaCore
11+
{
12+
[ComImport]
13+
[Guid("0dc5e6ed-3e16-4bf1-8f9a-a979878bc195")]
14+
[InterfaceType(ComInterfaceType.InterfaceIsIUnknown)]
15+
public interface ITextProvider2 : ITextProvider
16+
{
17+
new ITextRangeProvider[]? GetSelection();
18+
19+
new ITextRangeProvider[]? GetVisibleRanges();
20+
21+
new ITextRangeProvider? RangeFromChild(IRawElementProviderSimple childElement);
22+
23+
new ITextRangeProvider? RangeFromPoint(Point screenLocation);
24+
25+
new ITextRangeProvider? DocumentRange { get; }
26+
27+
new SupportedTextSelection SupportedTextSelection { get; }
28+
29+
ITextRangeProvider? RangeFromAnnotation(IRawElementProviderSimple annotation);
30+
31+
ITextRangeProvider? GetCaretRange(out BOOL isActive);
32+
}
33+
}
34+
}
Lines changed: 53 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,53 @@
1+
// Licensed to the .NET Foundation under one or more agreements.
2+
// The .NET Foundation licenses this file to you under the MIT license.
3+
// See the LICENSE file in the project root for more information.
4+
5+
using System.Runtime.InteropServices;
6+
7+
internal static partial class Interop
8+
{
9+
internal static partial class UiaCore
10+
{
11+
[ComImport]
12+
[Guid("5347ad7b-c355-46f8-aff5-909033582f63")]
13+
[InterfaceType(ComInterfaceType.InterfaceIsIUnknown)]
14+
public interface ITextRangeProvider
15+
{
16+
ITextRangeProvider Clone();
17+
18+
BOOL Compare(ITextRangeProvider range);
19+
20+
int CompareEndpoints(TextPatternRangeEndpoint endpoint, ITextRangeProvider targetRange, TextPatternRangeEndpoint targetEndpoint);
21+
22+
void ExpandToEnclosingUnit(TextUnit unit);
23+
24+
ITextRangeProvider? FindAttribute(int attribute, object value, BOOL backward);
25+
26+
ITextRangeProvider? FindText(string text, BOOL backward, BOOL ignoreCase);
27+
28+
object? GetAttributeValue(int attribute);
29+
30+
double[] GetBoundingRectangles();
31+
32+
IRawElementProviderSimple GetEnclosingElement();
33+
34+
string GetText(int maxLength);
35+
36+
int Move(TextUnit unit, int count);
37+
38+
int MoveEndpointByUnit(TextPatternRangeEndpoint endpoint, TextUnit unit, int count);
39+
40+
void MoveEndpointByRange(TextPatternRangeEndpoint endpoint, ITextRangeProvider targetRange, TextPatternRangeEndpoint targetEndpoint);
41+
42+
void Select();
43+
44+
void AddToSelection();
45+
46+
void RemoveFromSelection();
47+
48+
void ScrollIntoView(BOOL alignToTop);
49+
50+
IRawElementProviderSimple[] GetChildren();
51+
}
52+
}
53+
}
Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
// Licensed to the .NET Foundation under one or more agreements.
2+
// The .NET Foundation licenses this file to you under the MIT license.
3+
// See the LICENSE file in the project root for more information.
4+
5+
using System;
6+
7+
internal static partial class Interop
8+
{
9+
internal static partial class UiaCore
10+
{
11+
[Flags]
12+
public enum SupportedTextSelection
13+
{
14+
None = 0,
15+
Single = 1,
16+
Multiple = 2
17+
}
18+
}
19+
}
Lines changed: 56 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,56 @@
1+
// Licensed to the .NET Foundation under one or more agreements.
2+
// The .NET Foundation licenses this file to you under the MIT license.
3+
// See the LICENSE file in the project root for more information.
4+
5+
internal static partial class Interop
6+
{
7+
internal static partial class UiaCore
8+
{
9+
public enum TextAttributeIdentifier
10+
{
11+
AnimationStyleAttributeId = 40000,
12+
BackgroundColorAttributeId = 40001,
13+
BulletStyleAttributeId = 40002,
14+
CapStyleAttributeId = 40003,
15+
CultureAttributeId = 40004,
16+
FontNameAttributeId = 40005,
17+
FontSizeAttributeId = 40006,
18+
FontWeightAttributeId = 40007,
19+
ForegroundColorAttributeId = 40008,
20+
HorizontalTextAlignmentAttributeId = 40009,
21+
IndentationFirstLineAttributeId = 40010,
22+
IndentationLeadingAttributeId = 40011,
23+
IndentationTrailingAttributeId = 40012,
24+
IsHiddenAttributeId = 40013,
25+
IsItalicAttributeId = 40014,
26+
IsReadOnlyAttributeId = 40015,
27+
IsSubscriptAttributeId = 40016,
28+
IsSuperscriptAttributeId = 40017,
29+
MarginBottomAttributeId = 40018,
30+
MarginLeadingAttributeId = 40019,
31+
MarginTopAttributeId = 40020,
32+
MarginTrailingAttributeId = 40021,
33+
OutlineStylesAttributeId = 40022,
34+
OverlineColorAttributeId = 40023,
35+
OverlineStyleAttributeId = 40024,
36+
StrikethroughColorAttributeId = 40025,
37+
StrikethroughStyleAttributeId = 40026,
38+
TabsAttributeId = 40027,
39+
TextFlowDirectionsAttributeId = 40028,
40+
UnderlineColorAttributeId = 40029,
41+
UnderlineStyleAttributeId = 40030,
42+
AnnotationTypesAttributeId = 40031,
43+
AnnotationObjectsAttributeId = 40032,
44+
StyleNameAttributeId = 40033,
45+
StyleIdAttributeId = 40034,
46+
LinkAttributeId = 40035,
47+
IsActiveAttributeId = 40036,
48+
SelectionActiveEndAttributeId = 40037,
49+
CaretPositionAttributeId = 40038,
50+
CaretBidiModeAttributeId = 40039,
51+
LineSpacingAttributeId = 40040,
52+
BeforeParagraphSpacingAttributeId = 40041,
53+
AfterParagraphSpacingAttributeId = 40042
54+
}
55+
}
56+
}
Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
// Licensed to the .NET Foundation under one or more agreements.
2+
// The .NET Foundation licenses this file to you under the MIT license.
3+
// See the LICENSE file in the project root for more information.
4+
5+
using System;
6+
using System.Runtime.InteropServices;
7+
8+
internal static partial class Interop
9+
{
10+
internal static partial class UiaCore
11+
{
12+
public enum TextPatternRangeEndpoint
13+
{
14+
Start = 0,
15+
End = 1
16+
}
17+
}
18+
}
Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
// Licensed to the .NET Foundation under one or more agreements.
2+
// The .NET Foundation licenses this file to you under the MIT license.
3+
// See the LICENSE file in the project root for more information.
4+
5+
using System.Runtime.InteropServices;
6+
7+
internal static partial class Interop
8+
{
9+
internal static partial class UiaCore
10+
{
11+
public enum TextUnit
12+
{
13+
Character = 0,
14+
Format = 1,
15+
Word = 2,
16+
Line = 3,
17+
Paragraph = 4,
18+
Page = 5,
19+
Document = 6
20+
}
21+
}
22+
}
Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,26 @@
1+
// Licensed to the .NET Foundation under one or more agreements.
2+
// The .NET Foundation licenses this file to you under the MIT license.
3+
// See the LICENSE file in the project root for more information.
4+
5+
using System.Runtime.InteropServices;
6+
7+
internal static partial class Interop
8+
{
9+
internal static partial class UiaCore
10+
{
11+
private static object? s_notSupportedValue;
12+
13+
[DllImport(Libraries.UiaCore, ExactSpelling = true)]
14+
private static extern int UiaGetReservedNotSupportedValue([MarshalAs(UnmanagedType.IUnknown)] out object notSupportedValue);
15+
16+
public static object UiaGetReservedNotSupportedValue()
17+
{
18+
if (s_notSupportedValue == null)
19+
{
20+
UiaGetReservedNotSupportedValue(out s_notSupportedValue);
21+
}
22+
23+
return s_notSupportedValue;
24+
}
25+
}
26+
}
Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,32 @@
1+
// Licensed to the .NET Foundation under one or more agreements.
2+
// The .NET Foundation licenses this file to you under the MIT license.
3+
// See the LICENSE file in the project root for more information.
4+
5+
using System;
6+
7+
internal static partial class Interop
8+
{
9+
/// <summary>
10+
/// Simple wrapper for an ATOM
11+
/// </summary>
12+
public struct Atom
13+
{
14+
// #define MAXINTATOM 0xC000
15+
// #define MAKEINTATOM(i) (LPTSTR)((ULONG_PTR)((WORD)(i)))
16+
// #define INVALID_ATOM ((ATOM)0)
17+
18+
// Strange uses for window class atoms
19+
// https://blogs.msdn.microsoft.com/oldnewthing/20080501-00/?p=22503/
20+
21+
public ushort ATOM;
22+
23+
public Atom(ushort atom) => ATOM = atom;
24+
25+
public static Atom Null = new Atom(0);
26+
27+
public bool IsValid => ATOM != 0;
28+
29+
public static implicit operator uint(Atom atom) => atom.ATOM;
30+
public static implicit operator Atom(IntPtr atom) => new Atom((ushort)atom);
31+
}
32+
}

0 commit comments

Comments
 (0)