XmlData::Element* GetElementByTagNameNS(XmlData::Element* parent, StringIn ns, StringIn tagName, bool bDeep/* = TRUE*/) { XmlData::Node* child = parent->get_firstChild(); while (child != NULL) { XmlData::Element* element = dynamic_cast<XmlData::Element*>(child); if (element) { String ens = element->get_namespaceURI(); if (ens == ns) { String etagName = element->get_localName(); if (etagName == NULL) { etagName = element->get_tagName(); } if (etagName == tagName) { return element; } } // Recurse if (bDeep) { XmlData::Element* element2 = GetElementByTagNameNS(element, ns, tagName, true); if (element2 != NULL) return element2; } } child = child->get_nextSibling(); } return NULL; }
void CNITFTopicsDlg::AddSubjects(ILDOMElement* documentElement, IUITreeItem* parentItem, int topicType, int matchSubject, int matchSubjectMatter) { CComPtr<ILDOMNode> node; documentElement->get_firstChild(&node); while (node) { CComQIPtr<ILDOMElement> element = node; if (element) { BSTR btagName; element->get_tagName(&btagName); _bstr_t tagName = _bstr_t(btagName, false); if (!wcscmp(tagName, L"Topic")) { BSTR bduid; element->getAttribute(L"Duid", &bduid); _bstr_t duid = _bstr_t(bduid, false); WCHAR* p = (BSTR)duid; p += 2; char buf[4]; buf[0] = *p++; buf[1] = *p++; buf[2] = 0; int subject = atol(buf); buf[0] = *p++; buf[1] = *p++; buf[2] = *p++; buf[3] = 0; int subjectMatter = atol(buf); buf[0] = *p++; buf[1] = *p++; buf[2] = *p++; buf[3] = 0; int subjectDetail = atol(buf); if ((topicType == 0 && subject != 0 && subjectMatter == 0 && subjectDetail == 0) || (topicType == 1 && subject == matchSubject && subjectMatter != 0 && subjectDetail == 0) || (topicType == 2 && subject == matchSubject && subjectMatter == matchSubjectMatter && subjectDetail != 0)) { ILDOMElement* description = GetElementByTagNameNS(element, NULL, L"Description", FALSE); BSTR bvariant; description->getAttribute(L"Variant", &bvariant); _bstr_t variant = _bstr_t(bvariant, false); if (!wcscmp(variant, L"Name")) { BSTR bname; description->get_textContent(&bname); _bstr_t name = _bstr_t(bname, false); CSubject* pSubject = new CSubject; pSubject->m_name = name; CComPtr<IUITreeItem> newItem; m_subjectsTreeCtl->InsertItem((DWORD)pSubject, parentItem, NULL, NULL, -1/*pNewItem->m_iIcon*/, -1/*pNewItem->m_cChildren*/, &newItem); if (topicType == 0) AddSubjects(documentElement, newItem, 1, subject, 0); else if (topicType == 1) AddSubjects(documentElement, newItem, 2, subject, subjectMatter); } } } } CComPtr<ILDOMNode> nextSibling; node->get_nextSibling(&nextSibling); node = nextSibling; } }
STDMETHODIMP CESceneDocument::ShowViews(IEFrame* pFrame) { #if 0 CComPtr<ILXFrameworkFrame> frame; static_cast<CLXMLEditorApp*>(m_app.p)->m_spAddinSite->GetFrame(&frame); CComPtr<ILXFrameworkApp> app; frame->GetApp(&app); CComPtr<ILXUIMDIFrameElement> frameelement; frame->get_Element(&frameelement); CComPtr<ILXUIDocument> appdocument; app->get_Document(&appdocument); // CComPtr<ILXUIElement> mdiclient; // frameelement->getMDIClientElement(&mdiclient); #if 0 CComPtr<ILDOMElement> mdiclient = GetElementByTagNameNS(frameelement, L"http://www.lerstad.com/2004/lxui", L"mdiclient", FALSE); if (mdiclient) { CComPtr<ILXUIElement> mdichild; appdocument->createElementNS(L"http://www.lerstad.com/2004/lxui", L"mdichild", (ILDOMElement**)&mdichild); mdiclient->appendChild(mdichild, NULL); } #endif CDocumentWorkspace* pWorkspace = &static_cast<CLXMLEditorApp*>(m_app.p)->m_sceneDocumentWorkspace; CComQIPtr<ILXAddin> addin = m_app; CComPtr<ILXAddinSite> addinSite; addin->GetSite(&addinSite); CComPtr<IUIManager> uiManager; addinSite->GetUIManager((IUnknown**)&uiManager); CComQIPtr<IUIMDIFrame> mdiframe = pFrame; /* CComObject<CEXMLViewGroup>* viewGroup; CComObject<CEXMLViewGroup>::CreateInstance(&viewGroup); if (viewGroup) { viewGroup->AddRef(); viewGroup->SetDocument(this); */ // Create all views // 3DView(s) { CComPtr<ILDOMElement> e; appdocument->createElementNS(NULL, L"content", &e); CComPtr<IUnknown> old; e->setUserData(L"n", /*viewGroup->*/GetUnknown(), NULL, &old); VARIANT vFactory; V_VT(&vFactory) = VT_UNKNOWN; V_UNKNOWN(&vFactory) = static_cast<CLXMLEditorApp*>(m_app.p)->m_pElementBehaviorFactory; V_UNKNOWN(&vFactory)->AddRef(); long cookie; e->addBehavior(L"#factory#scene_3dview", &vFactory, &cookie); m_views.Add(e.Detach()); } // SceneGraphDlg { CComPtr<ILDOMElement> e; appdocument->createElementNS(NULL, L"content", &e); CComPtr<IUnknown> old; e->setUserData(L"n", /*viewGroup->*/GetUnknown(), NULL, &old); VARIANT vFactory; V_VT(&vFactory) = VT_UNKNOWN; V_UNKNOWN(&vFactory) = static_cast<CLXMLEditorApp*>(m_app.p)->m_pElementBehaviorFactory; V_UNKNOWN(&vFactory)->AddRef(); long cookie; e->addBehavior(L"#factory#scene_graph", &vFactory, &cookie); m_views.Add(e.Detach()); } pWorkspace->Create(pFrame, static_cast<CLXMLEditorApp*>(m_app.p), this/*viewGroup*/); //} // UpdateTitles(); #endif return S_OK; }
ErrorCode CDispLRegFilter::BuildRegFilter(XmlData::Element* element) { m_Name = element->getAttribute(WSTR("name")); m_Src = element->getAttribute(WSTR("src")); XmlData::Node* node = element->get_firstChild(); while (node) { XmlData::Element* element = dynamic_cast<XmlData::Element*>(node); if (element) { String tagName = element->get_tagName(); if (tagName == L"inputpin" || tagName == L"outputpin") { CLRegPin* pRegPin = new CLRegPin; if (tagName == L"inputpin") { pRegPin->m_dir = PINDIR_INPUT; } else// if (!wcscmp(tagName, L"outputpin")) { pRegPin->m_dir = PINDIR_OUTPUT; } String minOccurs = element->getAttribute(WSTR("minOccurs")); String maxOccurs = element->getAttribute(WSTR("maxOccurs")); pRegPin->m_name = element->getAttribute(WSTR("name")); XmlData::Element* mediaTypes = GetElementByTagNameNS(element, NULL, WSTR("mediatypes"), false); if (mediaTypes) { XmlData::Node* node = mediaTypes->get_firstChild(); while (node) { XmlData::Element* element = dynamic_cast<XmlData::Element*>(node); if (element) { String tagName = element->get_tagName(); if (tagName == "mediatype") { CLRegMediaType* pRegMediaType = new CLRegMediaType; String majortype = element->getAttribute(WSTR("majortype")); if (majortype.Compare(WSTR("stream")) == 0) { pRegMediaType->m_majortype = LMEDIATYPE_Stream; XmlData::Element* streamcontent = GetElementByTagNameNS(element, NULL, WSTR("streamcontent"), false); if (streamcontent) { XmlData::Node* node = streamcontent->get_firstChild(); while (node) { XmlData::Element* element = dynamic_cast<XmlData::Element*>(node); if (element) { String tagName = element->get_tagName(); if (tagName == "match") { CMatch match; XmlData::Node* node = element->get_firstChild(); while (node) { XmlData::Element* element = dynamic_cast<XmlData::Element*>(node); if (element) { String tagName = element->get_tagName(); if (tagName == "pattern") { String value = element->getAttribute(WSTR("value")); if (value != NULL) { BytePattern pattern; String offset = element->getAttribute(WSTR("offset")); if (offset != NULL) //pattern.m_offset = _wtoi64(offset.c_str()); pattern.m_offset = str2int(CString(offset)); else pattern.m_offset = 0; String v = stripspaces(value); pattern.m_length = v.GetLength()/2; pattern.m_value = new uint8[pattern.m_length]; HexStringToBytes(CStringw(v), pattern.m_value, pattern.m_length); pattern.m_mask = new uint8[pattern.m_length]; String mask = element->getAttribute(WSTR("mask")); int masklen; if (mask != NULL) { v = stripspaces(mask); masklen = MIN(v.GetLength()/2, pattern.m_length); HexStringToBytes(CStringw(v), pattern.m_mask, masklen); } else masklen = 0; while (masklen < pattern.m_length) // Fill rest with 0xFF { pattern.m_mask[masklen++] = 0xFF; } match.m_patterns.Add(pattern); } } } node = node->get_nextSibling(); } pRegMediaType->m_streamcontent.m_matches.Add(match); } } node = node->get_nextSibling(); } } } else if (majortype.Compare(WSTR("video")) == 0) { pRegMediaType->m_majortype = LMEDIATYPE_Video; } else if (majortype.Compare(WSTR("audio")) == 0) { pRegMediaType->m_majortype = LMEDIATYPE_Audio; } else if (majortype.Compare(WSTR("scene")) == 0) { pRegMediaType->m_majortype = LMEDIATYPE_Scene; } else { // TODO ASSERT(0); } pRegPin->m_mediaTypes.Add(pRegMediaType); } } node = node->get_nextSibling(); } } m_RegPins.Add(pRegPin); } } node = node->get_nextSibling(); } return 0; }