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

Method _InsertFormatText

controls.extend/SChatEdit.cpp:100–214  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

98 }
99
100 int SChatEdit::_InsertFormatText(int iCaret,CHARFORMATW cf,pugi::xml_node xmlText,BOOL bCanUndo)
101 {
102 SStringW strText = xmlText.value();
103 if(xmlText.name() == KLabelSmiley)
104 {//insert smiley
105 SComPtr<ISmileyCtrl> pSmiley;
106 HRESULT hr=::CoCreateInstance(CLSID_SSmileyCtrl,NULL,CLSCTX_INPROC,__uuidof(ISmileyCtrl),(LPVOID*)&pSmiley);
107 if(FAILED(hr)) return 0;
108
109 SComPtr<IRichEditOle> ole;
110 if(SSendMessage(EM_GETOLEINTERFACE,0,(LPARAM)(void**)&ole) && ole)
111 {
112 SComPtr<IRichEditOleCallback> pCallback;
113 hr=ole->QueryInterface(IID_IRichEditOleCallback,(void**)&pCallback);
114 if(FAILED(hr)) return 0;
115 SComPtr<ISmileyHost> host;
116 hr = pCallback->QueryInterface(__uuidof(ISmileyHost),(void**)&host);
117 if(FAILED(hr)) return 0;
118 SComPtr<ISmileySource> pSource;
119 hr = host->CreateSource(&pSource);
120 if(FAILED(hr)) return 0;
121 {
122 UINT uID = xmlText.attribute(L"id").as_uint(-1);
123 SStringW strPath = xmlText.attribute(L"path").value();
124 if(uID != -1)
125 hr = pSource->LoadFromID(uID);
126 else
127 hr = pSource->LoadFromFile(strPath);
128 if(SUCCEEDED(hr))
129 {
130 pSmiley->SetSource(pSource);
131 SSendMessage(EM_SETSEL,iCaret,iCaret);
132 pSmiley->Insert2Richedit(ole);
133 }
134 }
135 }
136 return SUCCEEDED(hr)?1:0;
137 }
138
139 CHARFORMATW cfNew = cf;
140 cfNew.dwMask = 0;
141 if(xmlText.name() == KLabelColor)
142 {
143 cfNew.crTextColor = GETCOLOR(xmlText.attribute(L"value").value());
144 if(cfNew.crTextColor!=CR_INVALID)
145 {
146 cfNew.crTextColor &= 0x00ffffff;
147 cfNew.dwMask |= CFM_COLOR;
148 }
149 }else if(xmlText.name()== KLabelFont)
150 {
151 wcscpy(cf.szFaceName,cfNew.szFaceName);
152 wcscpy_s(cfNew.szFaceName,LF_FACESIZE-1,xmlText.attribute(L"value").value());
153 cfNew.dwMask |= CFM_FACE;
154 }else if(xmlText.name()==KLabelUnderline)
155 {
156 cfNew.dwMask |=CFM_UNDERLINE;
157 cfNew.dwEffects |= CFE_UNDERLINE;

Callers

nothing calls this directly

Calls 15

GetDCFunction · 0.85
ReleaseDCFunction · 0.85
CreateSourceMethod · 0.80
LoadFromIDMethod · 0.80
SetSourceMethod · 0.80
Insert2RicheditMethod · 0.80
valueMethod · 0.45
nameMethod · 0.45
QueryInterfaceMethod · 0.45
as_uintMethod · 0.45
attributeMethod · 0.45
LoadFromFileMethod · 0.45

Tested by

no test coverage detected