\r
selOffsetsAtLastCaretEvent=None\r
\r
+TA_BOTTOM=8\r
+\r
#Edit control window messages\r
EM_GETSEL=176\r
EM_SETSEL=177\r
o=None\r
if not o:\r
return None\r
+ # Outlook >=2007 exposes MSAA on its embedded objects thus we can use accName as the label\r
import oleacc\r
try:\r
label=o.QueryInterface(oleacc.IAccessible).accName(0);\r
pass\r
if label:\r
return label\r
+ # Outlook 2003 and Outlook Express write the embedded object text to the display with GDI thus we can use display model \r
left,top=embedRangeObj.GetPoint(comInterfaces.tom.tomStart)\r
- right,bottom=embedRangeObj.GetPoint(comInterfaces.tom.tomEnd)\r
+ right,bottom=embedRangeObj.GetPoint(comInterfaces.tom.tomEnd|TA_BOTTOM)\r
+ # Outlook Express bug: when expanding to the first embedded object on lines after the first, the range's start coordinates are the start coordinates of the previous character (on the line above)\r
+ # Therefore if we detect this, collapse the range and try getting left and top again\r
+ if left>=right:\r
+ r=embedRangeObj.duplicate\r
+ r.collapse(1)\r
+ left,top=r.GetPoint(comInterfaces.tom.tomStart)\r
import displayModel\r
- label=displayModel.DisplayModelTextInfo(self.obj, textInfos.Rect(left, top, right, bottom+10)).text\r
+ label=displayModel.DisplayModelTextInfo(self.obj, textInfos.Rect(left, top, right, bottom)).text\r
if label and not label.isspace():\r
return label\r
+ # Windows Live Mail exposes the label via the embedded object's data (IDataObject)\r
try:\r
dataObj=o.QueryInterface(oleTypes.IDataObject)\r
except comtypes.COMError:\r
pass\r
if label:\r
return label\r
+ # As a final fallback (e.g. could not get display model text for Outlook Express), use the embedded object's user type (e.g. "recipient").\r
try:\r
oleObj=o.QueryInterface(oleTypes.IOleObject)\r
label=oleObj.GetUserType(1)\r