| 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; |
nothing calls this directly
no test coverage detected