xmlfix3: #i113683#: finish CProcessingInstruction

This commit is contained in:
Michael Stahl 2011-02-10 16:45:03 +01:00
parent c5db3b93ee
commit 9f235cfecf
3 changed files with 68 additions and 27 deletions

View file

@ -603,7 +603,7 @@ namespace DOM
xmlChar *xTarget = (xmlChar*)o1.getStr(); xmlChar *xTarget = (xmlChar*)o1.getStr();
OString o2 = OUStringToOString(data, RTL_TEXTENCODING_UTF8); OString o2 = OUStringToOString(data, RTL_TEXTENCODING_UTF8);
xmlChar *xData = (xmlChar*)o2.getStr(); xmlChar *xData = (xmlChar*)o2.getStr();
xmlNodePtr const pNode = xmlNewPI(xTarget, xData); xmlNodePtr const pNode = xmlNewDocPI(m_aDocPtr, xTarget, xData);
pNode->doc = m_aDocPtr; pNode->doc = m_aDocPtr;
Reference< XProcessingInstruction > const xRet( Reference< XProcessingInstruction > const xRet(
static_cast< XNode* >(GetCNode(pNode).get()), static_cast< XNode* >(GetCNode(pNode).get()),

View file

@ -54,46 +54,89 @@ namespace DOM
/** /**
The content of this processing instruction. The content of this processing instruction.
*/ */
OUString SAL_CALL CProcessingInstruction::getData() throw (RuntimeException) OUString SAL_CALL
CProcessingInstruction::getData() throw (RuntimeException)
{ {
// XXX ::osl::MutexGuard const g(m_rMutex);
return OUString();
if (0 == m_aNodePtr) {
return ::rtl::OUString();
}
char const*const pContent(
reinterpret_cast<char const*>(m_aNodePtr->content));
if (0 == pContent) {
return ::rtl::OUString();
}
OUString const ret(pContent, strlen(pContent), RTL_TEXTENCODING_UTF8);
return ret;
} }
/** /**
The target of this processing instruction. The target of this processing instruction.
*/ */
OUString SAL_CALL CProcessingInstruction::getTarget() throw (RuntimeException) OUString SAL_CALL
CProcessingInstruction::getTarget() throw (RuntimeException)
{ {
// XXX ::osl::MutexGuard const g(m_rMutex);
return OUString();
}
if (0 == m_aNodePtr) {
return ::rtl::OUString();
}
char const*const pName(
reinterpret_cast<char const*>(m_aNodePtr->name));
if (0 == pName) {
return ::rtl::OUString();
}
OUString const ret(pName, strlen(pName), RTL_TEXTENCODING_UTF8);
return ret;
}
/** /**
The content of this processing instruction. The content of this processing instruction.
*/ */
void SAL_CALL CProcessingInstruction::setData(const OUString& /*data*/) throw (RuntimeException, DOMException) void SAL_CALL CProcessingInstruction::setData(OUString const& rData)
{ throw (RuntimeException, DOMException)
// XXX
}
OUString SAL_CALL CProcessingInstruction::getNodeName()throw (RuntimeException)
{ {
::osl::MutexGuard const g(m_rMutex); ::osl::MutexGuard const g(m_rMutex);
OUString aName; if (0 == m_aNodePtr) {
if (m_aNodePtr != NULL) throw RuntimeException();
{
const xmlChar* xName = m_aNodePtr->name;
aName = OUString((sal_Char*)xName, strlen((char*)xName), RTL_TEXTENCODING_UTF8);
} }
return aName;
OString const data(OUStringToOString(rData, RTL_TEXTENCODING_UTF8));
xmlChar const*const pData(
reinterpret_cast<xmlChar const*>(data.getStr()) );
xmlFree(m_aNodePtr->content);
m_aNodePtr->content = xmlStrdup(pData);
} }
OUString SAL_CALL CProcessingInstruction::getNodeValue() throw (RuntimeException) OUString SAL_CALL
CProcessingInstruction::getNodeName() throw (RuntimeException)
{
::osl::MutexGuard const g(m_rMutex);
if (0 == m_aNodePtr) {
return ::rtl::OUString();
}
sal_Char const*const pName =
reinterpret_cast<sal_Char const*>(m_aNodePtr->name);
OUString const ret(pName, strlen(pName), RTL_TEXTENCODING_UTF8);
return ret;
}
OUString SAL_CALL CProcessingInstruction::getNodeValue()
throw (RuntimeException)
{ {
return getData(); return getData();
} }
void SAL_CALL
CProcessingInstruction::setNodeValue(OUString const& rNodeValue)
throw (RuntimeException, DOMException)
{
return setData(rNodeValue);
}
} }

View file

@ -81,6 +81,9 @@ namespace DOM
throw (RuntimeException); throw (RuntimeException);
virtual OUString SAL_CALL getNodeValue() virtual OUString SAL_CALL getNodeValue()
throw (RuntimeException); throw (RuntimeException);
virtual void SAL_CALL setNodeValue(OUString const& rNodeValue)
throw (RuntimeException, DOMException);
// --- delegation for XNde base. // --- delegation for XNde base.
virtual Reference< XNode > SAL_CALL appendChild(const Reference< XNode >& newChild) virtual Reference< XNode > SAL_CALL appendChild(const Reference< XNode >& newChild)
throw (RuntimeException, DOMException) throw (RuntimeException, DOMException)
@ -189,11 +192,6 @@ namespace DOM
{ {
return CNode::replaceChild(newChild, oldChild); return CNode::replaceChild(newChild, oldChild);
} }
virtual void SAL_CALL setNodeValue(const OUString& nodeValue)
throw (RuntimeException, DOMException)
{
return CNode::setNodeValue(nodeValue);
}
virtual void SAL_CALL setPrefix(const OUString& prefix) virtual void SAL_CALL setPrefix(const OUString& prefix)
throw (RuntimeException, DOMException) throw (RuntimeException, DOMException)
{ {