| | 277 | def _getTextRangeWithEmbeddedObjects(self,start,end): |
| | 278 | ptr=ctypes.POINTER(comInterfaces.tom.ITextDocument)() |
| | 279 | ctypes.windll.oleacc.AccessibleObjectFromWindow(self.obj.windowHandle,-16,ctypes.byref(ptr._iid_),ctypes.byref(ptr)) |
| | 280 | r=ptr.Range(self._startOffset,self._endOffset) |
| | 281 | bufText=r.text |
| | 282 | if bufText is None: |
| | 283 | bufText="" |
| | 284 | newTextList=[] |
| | 285 | for offset in range(len(bufText)): |
| | 286 | if ord(bufText[offset])==0xfffc: |
| | 287 | embedRange=ptr.Range(start+offset,start+offset) |
| | 288 | o=embedRange.GetEmbeddedObject() |
| | 289 | o=o.QueryInterface(oleTypes.IOleObject) |
| | 290 | dataObj=o.GetClipboardData(0) |
| | 291 | dataObj=pythoncom._univgw.interface(hash(dataObj),pythoncom.IID_IDataObject) |
| | 292 | format=(win32clipboard.CF_UNICODETEXT, None, pythoncom.DVASPECT_CONTENT, -1, pythoncom.TYMED_HGLOBAL) |
| | 293 | medium=dataObj.GetData(format) |
| | 294 | buf=ctypes.create_string_buffer(medium.data) |
| | 295 | buf=ctypes.cast(buf,ctypes.c_wchar_p) |
| | 296 | newTextList.append(buf.value) |
| | 297 | else: |
| | 298 | newTextList.append(bufText[offset]) |
| | 299 | return "".join(newTextList) |
| | 300 | |