MCPcopy Create free account
hub / github.com/SOUI2/soui / GetFormatText

Method GetFormatText

controls.extend/SChatEdit.cpp:237–304  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

235 }
236
237 SStringW SChatEdit::GetFormatText()
238 {
239 SStringW strTxt;
240
241
242 TEXTRANGE txtRng;
243 txtRng.chrg.cpMin =0;
244 txtRng.chrg.cpMax = (LONG)SSendMessage(WM_GETTEXTLENGTH);
245 txtRng.lpstrText = (LPTSTR)strTxt.GetBufferSetLength(txtRng.chrg.cpMax);
246
247 SSendMessage(EM_GETTEXTRANGE,0,(LPARAM)&txtRng);
248 strTxt.ReleaseBuffer();
249
250 SComPtr<IRichEditOle> ole;
251 SSendMessage(EM_GETOLEINTERFACE,0,(LPARAM)(void**)&ole);
252
253 SStringW strMsg;
254 int iPlainTxtBegin = 0;
255 for(int i=0;i<strTxt.GetLength();i++)
256 {
257 if(strTxt[i] == 0xfffc)
258 {//�ҵ�һ��OLE����
259 strMsg += strTxt.Mid(iPlainTxtBegin,i-iPlainTxtBegin);
260 iPlainTxtBegin = i+1;
261
262 REOBJECT reobj={sizeof(reobj),0};
263 reobj.cp = i;
264 HRESULT hr = ole->GetObject( REO_IOB_USE_CP , &reobj, REO_GETOBJ_POLEOBJ);
265 if(SUCCEEDED(hr) && reobj.poleobj)
266 {
267 if(reobj.clsid == CLSID_SSmileyCtrl)
268 {
269 SComPtr<ISmileyCtrl> smiley;
270 hr = reobj.poleobj->QueryInterface(__uuidof(ISmileyCtrl), (void**)&smiley);
271 if(SUCCEEDED(hr))
272 {
273 SComPtr<ISmileySource> source;
274 hr = smiley->GetSource(&source);
275 SASSERT(SUCCEEDED(hr));
276 UINT uID = -1;
277 SStringW strSmiley = L"<smiley";
278 if(SUCCEEDED(source->GetID(&uID)))
279 {
280 strSmiley += SStringW().Format(L" id=\"%d\"",uID);
281 }
282
283 BSTR strFile;
284 if(SUCCEEDED(source->GetFile(&strFile)))
285 {
286 strSmiley += SStringW().Format(L" path=\"%s\"",strFile);
287 ::SysFreeString(strFile);
288 }
289 strSmiley += L"/>";
290
291 strMsg += strSmiley;
292
293 }
294 }

Callers

nothing calls this directly

Calls 12

SysFreeStringFunction · 0.85
GetBufferSetLengthMethod · 0.80
ReleaseBufferMethod · 0.80
GetSourceMethod · 0.80
RightMethod · 0.80
GetLengthMethod · 0.45
MidMethod · 0.45
QueryInterfaceMethod · 0.45
GetIDMethod · 0.45
FormatMethod · 0.45
GetFileMethod · 0.45
ReleaseMethod · 0.45

Tested by

no test coverage detected