String HTMLDocument::get_title() { ASSERT(0); return NULL; #if 0 if (pVal == NULL) return E_POINTER; if (m_documentElement) { ILDOMElement* head = GetElementByTagName(m_documentElement, L"head", FALSE); if (head) { ILDOMElement* title = GetElementByTagName(head, L"title", FALSE); if (title) { return title->get_textContent(pVal); } } } *pVal = NULL; return S_OK; #endif }
TiXmlElement* GetElementByTagName(TiXmlElement* root,const string& elementName) { TiXmlElement* ret = NULL; if (root == NULL) { return NULL; } if (root != NULL && elementName == root->Value()) { ret = root; } if (ret == NULL && root->FirstChildElement() != NULL) { ret = GetElementByTagName(root->FirstChildElement(),elementName); } if (ret == NULL && root->NextSiblingElement() != NULL) { ret = GetElementByTagName(root->NextSiblingElement(),elementName); } return ret; }
void HTMLDocument::set_title(StringIn newVal) { ASSERT(0); #if 0 if (m_documentElement) { CComPtr<ILDOMElement> head = GetElementByTagName(m_documentElement, L"head", FALSE); if (head == NULL) { createElement(L"head", &head); if (head) { CComPtr<ILDOMNode> beforeNode; m_documentElement->get_firstChild(&beforeNode); m_documentElement->insertBefore(head, _variant_t(beforeNode), NULL); } } if (head) { CComPtr<ILDOMElement> title = GetElementByTagName(head, L"title", FALSE); if (title == NULL) { createElement(L"title", &title); if (title) { CComPtr<ILDOMNode> beforeNode; head->get_firstChild(&beforeNode); head->insertBefore(title, _variant_t(beforeNode), NULL); } } if (title) { return title->set_textContent(newVal); } } } return S_OK; #endif }
string Base64GetElementValueByTagName(TiXmlElement* root,const string& name) { TiXmlElement* e = GetElementByTagName(root,name); if (e == NULL) return string(""); if (GetElementAttribute(e,"encode") == "base64") return base64_decode(string(e->GetText() ? e->GetText() : "")); else return string(e->GetText() ? e->GetText() : ""); }
string GetElementValueByTagName(TiXmlElement* root,const string& name) { if (root == NULL) return string(""); TiXmlElement* toFind = GetElementByTagName(root,name); if (toFind != NULL) return string(toFind->GetText() ? toFind->GetText() : ""); else return string(""); }
void GetPathNode(ILDOMElement* contextElement, BSTR path, ILDOMNode* *pVal) { *pVal = NULL; WCHAR* p = path; //while (*p) { BOOL bAttribute = FALSE; if (*p == L'@') { bAttribute = TRUE; p++; } CWCharString part = L""; // Get part while (*p && *p != '/') { part += *p++; } CComPtr<ILDOMNode> node; if (bAttribute) { CComPtr<ILDOMAttr> attrNode; contextElement->getAttributeNode(part, &attrNode); node = attrNode; *pVal = node; if (*pVal) (*pVal)->AddRef(); } else { ILDOMElement* childElement = GetElementByTagName(contextElement, part, FALSE); if (childElement) { if (*p == '/') // Recurse { p++; GetPathNode(childElement, p, &node); } else { *pVal = childElement; (*pVal)->AddRef(); } } } } }
string GetElementAttributeByTagName(TiXmlElement* root,const string& name, const string& attribute) { if (root == NULL) return string(""); string strValue(""); TiXmlElement* toFind = GetElementByTagName(root,name); if (toFind != NULL) { toFind->QueryValueAttribute(attribute,&strValue); } return strValue; }
// TODO, use common code for this void HTMLDocument::Seek(double seconds) { ASSERT(0); #if 0 if (m_documentElement) { CComPtr<ILDOMElement> body = GetElementByTagName(m_documentElement, L"body", FALSE); // m_tau = seconds; if (seconds != CComQIPtr<CLElementTimeImplImpl>(body)->m_tau) { CComQIPtr<CLElementTimeImplImpl>(body)->Seek(seconds); //ILSVGElement* svgElement = this;//reinterpret_cast<ISVGElement*>(this/*GetControllingUnknown()*/); bool bAny = DoAnimationsForAllElements(body, /*m_currentTimeSeconds,*/ seconds); //if (bAny) { // TODO, fix up here //CComQIPtr<CLDOMDocumentImplImpl> pDocument(m_ownerDocument); for (int n = 0; n < /*pDocument->*/m_pViews.GetSize(); n++) { ASSERT(0); #if 0 m_pViews[n]->m_htmTree->GetCSSPropertiesAndChildren(); m_pViews[n]->Flow(); if (m_pViews[n]->m_pUI) { m_pViews[n]->m_pUI->InvalidateRect( &m_pViews[n]->m_client, FALSE); } #endif } } } } #endif }
HTMLElement* HTMLDocument::get_body() { ASSERT(0); #if 0 if (m_documentElement) { LXML::Element* body = LXML::GetElementByTagName(m_documentElement, L"body", false); if (body) { return dynamic_cast<CLHTMLElementImpl*>(body); } else { Element* frameset = GetElementByTagName(m_documentElement, L"frameset", false); if (frameset) { return dynamic_cast<CLHTMLElementImpl*>(frameset); } } } #endif return NULL; }
void SetPathNodeValue(ILDOMElement* contextElement, BSTR path, BSTR value) { WCHAR* p = path; BOOL bAttribute = FALSE; if (*p == L'@') { bAttribute = TRUE; p++; } CWCharString part = L""; // Get part while (*p && *p != '/') { part += *p++; } CComPtr<ILDOMNode> node; if (bAttribute) { if (value != NULL) contextElement->setAttribute(part, value); else contextElement->removeAttribute(part); } else { if (value != NULL) { CComPtr<ILDOMElement> element = GetElementByTagName(contextElement, part, FALSE); if (element == NULL) { CComPtr<ILDOMDocument> ownerDocument; contextElement->get_ownerDocument(&ownerDocument); ownerDocument->createElement(part, &element); contextElement->appendChild(element, NULL); } if (*p == '/') // Recurse { p++; SetPathNodeValue(element, p, value); } else { element->put_TextContent(value); } } else { CComPtr<ILDOMElement> element = GetElementByTagName(contextElement, part, FALSE); if (element) { if (*p == '/') // Recurse { p++; SetPathNodeValue(element, p, value); } else { element->put_TextContent(NULL); } CComPtr<ILDOMNode> child; element->get_firstChild(&child); if (child == NULL) // No children, remove the element { contextElement->removeChild(element, NULL); } } } } }