|
13 | 13 | from comtypes import GUID |
14 | 14 | from comInterfaces import UIAutomationClient as UIA |
15 | 15 | import winVersion |
| 16 | +from logHandler import log |
16 | 17 | from ._remoteOps import remoteAlgorithms |
17 | 18 | from ._remoteOps.remoteTypes import ( |
18 | 19 | RemoteExtensionTarget, |
@@ -69,40 +70,41 @@ def code(ra: remoteAPI.RemoteAPI): |
69 | 70 | remoteDocElement = ra.newElement(docElement) |
70 | 71 | remoteTextRange = ra.newTextRange(textRange) |
71 | 72 | remoteCustomAttribValue = ra.newVariant() |
72 | | - with ra.ifBlock(remoteDocElement.isExtensionSupported(guid_msWord_extendedTextRangePattern)): |
73 | | - ra.logRuntimeMessage("docElement supports extendedTextRangePattern") |
74 | | - remoteResult = ra.newVariant() |
75 | | - ra.logRuntimeMessage("doing callExtension for extendedTextRangePattern") |
76 | | - remoteDocElement.callExtension( |
77 | | - guid_msWord_extendedTextRangePattern, |
78 | | - remoteResult |
79 | | - ) |
80 | | - with ra.ifBlock(remoteResult.isNull()): |
81 | | - ra.logRuntimeMessage("extendedTextRangePattern is null") |
82 | | - ra.halt() |
83 | | - with ra.elseBlock(): |
84 | | - ra.logRuntimeMessage("got extendedTextRangePattern") |
85 | | - remoteExtendedTextRangePattern = remoteResult.asType(RemoteExtensionTarget) |
86 | | - with ra.ifBlock( |
87 | | - remoteExtendedTextRangePattern.isExtensionSupported(guid_msWord_getCustomAttributeValue) |
88 | | - ): |
89 | | - ra.logRuntimeMessage("extendedTextRangePattern supports getCustomAttributeValue") |
90 | | - ra.logRuntimeMessage("doing callExtension for getCustomAttributeValue") |
91 | | - remoteExtendedTextRangePattern.callExtension( |
92 | | - guid_msWord_getCustomAttributeValue, |
93 | | - remoteTextRange, |
94 | | - customAttribID, |
95 | | - remoteCustomAttribValue |
96 | | - ) |
97 | | - ra.logRuntimeMessage("got customAttribValue of ", remoteCustomAttribValue) |
98 | | - ra.Return(remoteCustomAttribValue) |
99 | | - with ra.elseBlock(): |
100 | | - ra.logRuntimeMessage("extendedTextRangePattern does not support getCustomAttributeValue") |
101 | | - with ra.elseBlock(): |
| 73 | + extendedTextRangeIsSupported = remoteDocElement.isExtensionSupported(guid_msWord_extendedTextRangePattern) |
| 74 | + with ra.ifBlock(extendedTextRangeIsSupported.inverse()): |
102 | 75 | ra.logRuntimeMessage("docElement does not support extendedTextRangePattern") |
103 | | - ra.logRuntimeMessage("msWord_getCustomAttributeValue end") |
| 76 | + ra.Return(None) |
| 77 | + ra.logRuntimeMessage("docElement supports extendedTextRangePattern") |
| 78 | + remoteResult = ra.newVariant() |
| 79 | + ra.logRuntimeMessage("doing callExtension for extendedTextRangePattern") |
| 80 | + remoteDocElement.callExtension( |
| 81 | + guid_msWord_extendedTextRangePattern, |
| 82 | + remoteResult |
| 83 | + ) |
| 84 | + with ra.ifBlock(remoteResult.isNull()): |
| 85 | + ra.logRuntimeMessage("extendedTextRangePattern is null") |
| 86 | + ra.Return(None) |
| 87 | + ra.logRuntimeMessage("got extendedTextRangePattern") |
| 88 | + remoteExtendedTextRangePattern = remoteResult.asType(RemoteExtensionTarget) |
| 89 | + customAttributeValueIsSupported = remoteExtendedTextRangePattern.isExtensionSupported(guid_msWord_getCustomAttributeValue) |
| 90 | + with ra.ifBlock(customAttributeValueIsSupported.inverse()): |
| 91 | + ra.logRuntimeMessage("extendedTextRangePattern does not support getCustomAttributeValue") |
| 92 | + ra.Return(None) |
| 93 | + ra.logRuntimeMessage("extendedTextRangePattern supports getCustomAttributeValue") |
| 94 | + ra.logRuntimeMessage("doing callExtension for getCustomAttributeValue") |
| 95 | + remoteExtendedTextRangePattern.callExtension( |
| 96 | + guid_msWord_getCustomAttributeValue, |
| 97 | + remoteTextRange, |
| 98 | + customAttribID, |
| 99 | + remoteCustomAttribValue |
| 100 | + ) |
| 101 | + ra.logRuntimeMessage("got customAttribValue of ", remoteCustomAttribValue) |
| 102 | + ra.Return(remoteCustomAttribValue) |
104 | 103 |
|
105 | 104 | customAttribValue = op.execute() |
| 105 | + if customAttribValue is None: |
| 106 | + log.debugWarning("Custom attribute value not available") |
| 107 | + return None |
106 | 108 | return customAttribValue |
107 | 109 |
|
108 | 110 |
|
|
0 commit comments