BOOL SApplication::_LoadXmlDocment( LPCTSTR pszXmlName ,LPCTSTR pszType ,pugi::xml_document & xmlDoc,IResProvider *pResProvider/* = NULL*/) { if(!pResProvider) { if(IsFileType(pszType)) { pugi::xml_parse_result result= xmlDoc.load_file(pszXmlName,pugi::parse_default,pugi::encoding_utf8); SASSERT_FMTW(result,L"parse xml error! xmlName=%s,desc=%s,offset=%d",pszXmlName,result.description(),result.offset); return result; }else { pResProvider = GetMatchResProvider(pszType,pszXmlName); } } if(!pResProvider) return FALSE; DWORD dwSize=pResProvider->GetRawBufferSize(pszType,pszXmlName); if(dwSize==0) return FALSE; CMyBuffer<char> strXml; strXml.Allocate(dwSize); pResProvider->GetRawBuffer(pszType,pszXmlName,strXml,dwSize); pugi::xml_parse_result result= xmlDoc.load_buffer(strXml,strXml.size(),pugi::parse_default,pugi::encoding_utf8); SASSERT_FMTW(result,L"parse xml error! xmlName=%s,desc=%s,offset=%d",pszXmlName,result.description(),result.offset); return result; }
HRESULT RichEditBkImg::OnInternalAttrPos(POSITION_ITEM* pPosItem, int& nPosCount, const SStringW& strValue, BOOL bLoading) { SStringWList strLst; SplitString(strValue,L',',strLst); if(strLst.GetCount() != 2 && strLst.GetCount() != 4) { SASSERT_FMTW(L"Parse pos attribute failed, strPos=%s",strValue); return FALSE; } //增加pos属性中的空格兼容。 for(size_t i=0;i<strLst.GetCount();i++) { strLst.GetAt(i).TrimBlank(); } BOOL bRet = TRUE; BOOL bRet2 = TRUE; bRet = ParsePosition12(pPosItem, strLst[0],strLst[1]); if(strLst.GetCount() == 4) { bRet2 = ParsePosition34(pPosItem, strLst[2],strLst[3]); } if (bRet) { nPosCount = 2; } if (bRet2) { nPosCount = 4; } return bRet && bRet2; }
BOOL SwndLayoutBuilder::CalcChildrenPosition(SList<SWindowRepos*> *pListChildren,const CRect & rcContainer) { SPOSITION pos=pListChildren->GetHeadPosition(); int nChildrenCount=pListChildren->GetCount(); while(pos) { SPOSITION posOld=pos; SWindow *pChild=pListChildren->GetNext(pos)->GetWindow(); if(0 == SwndLayoutBuilder::CalcPosition(pChild,rcContainer,pChild->m_rcWindow)) { delete pListChildren->GetAt(posOld); pListChildren->RemoveAt(posOld); } } if(0==pListChildren->GetCount()) return TRUE; if(nChildrenCount == pListChildren->GetCount()) {//窗口布局依赖死锁 SASSERT_FMTW(FALSE,L"窗口布局依赖死锁"); return FALSE; }else { return CalcChildrenPosition(pListChildren,rcContainer); } }
BOOL SApplication::_LoadXmlDocment( LPCTSTR pszXmlName ,LPCTSTR pszType ,pugi::xml_document & xmlDoc) { DWORD dwSize=GetRawBufferSize(pszType,pszXmlName); if(dwSize==0) return FALSE; CMyBuffer<char> strXml; strXml.Allocate(dwSize); GetRawBuffer(pszType,pszXmlName,strXml,dwSize); pugi::xml_parse_result result= xmlDoc.load_buffer(strXml,strXml.size(),pugi::parse_default,pugi::encoding_utf8); SASSERT_FMTW(result,L"parse xml error! xmlName=%s,desc=%s,offset=%d",pszXmlName,result.description(),result.offset); return result; }
ISkinObj* SSkinPoolMgr::GetSkin( LPCWSTR strSkinName ) { POSITION pos=m_lstSkinPools.GetTailPosition(); while(pos) { SSkinPool *pStylePool=m_lstSkinPools.GetPrev(pos); if(ISkinObj* pSkin=pStylePool->GetSkin(strSkinName)) { return pSkin; } } SASSERT_FMTW(FALSE,L"GetSkin[%s] Failed!",strSkinName); return NULL; }
int SSkinPool::LoadSkins(pugi::xml_node xmlNode) { if(!xmlNode) return 0; int nLoaded=0; SStringW strSkinName, strTypeName; pugi::xml_node xmlSkin=xmlNode.first_child(); while(xmlSkin) { strTypeName = xmlSkin.name(); strSkinName = xmlSkin.attribute(L"name").value(); if (strSkinName.IsEmpty() || strTypeName.IsEmpty()) continue; xmlSkin.attribute(L"name").set_userdata(1); //标记该属性不需要再处理。 SASSERT(!HasKey(strSkinName)); ISkinObj *pSkin=SApplication::getSingleton().CreateSkinByName(strTypeName); if(pSkin) { pSkin->InitFromXml(xmlSkin); AddKeyObject(strSkinName,pSkin); nLoaded++; } else { SASSERT_FMTW(FALSE,L"load skin error,type=%s,name=%s",strTypeName,strSkinName); } xmlSkin.attribute(L"name").set_userdata(0); //清除标记 xmlSkin=xmlSkin.next_sibling(); } return nLoaded; }