summaryrefslogtreecommitdiff
path: root/unoxml
diff options
context:
space:
mode:
authorMichael Stahl <mst@openoffice.org>2011-02-10 16:45:03 +0100
committerMichael Stahl <mst@openoffice.org>2011-02-10 16:45:03 +0100
commit9f235cfecf6e910323a63326101c0aa5bf1d2796 (patch)
treebebc553428fd350936be6f19fc8ee2974df5be41 /unoxml
parentc5db3b93ee1058bd20ebcde2e757b52b9a67b74a (diff)
xmlfix3: #i113683#: finish CProcessingInstruction
Diffstat (limited to 'unoxml')
-rw-r--r--unoxml/source/dom/document.cxx2
-rw-r--r--unoxml/source/dom/processinginstruction.cxx79
-rw-r--r--unoxml/source/dom/processinginstruction.hxx8
3 files changed, 65 insertions, 24 deletions
diff --git a/unoxml/source/dom/document.cxx b/unoxml/source/dom/document.cxx
index 1a7f47b9e621..305d0819c67e 100644
--- a/unoxml/source/dom/document.cxx
+++ b/unoxml/source/dom/document.cxx
@@ -603,7 +603,7 @@ namespace DOM
xmlChar *xTarget = (xmlChar*)o1.getStr();
OString o2 = OUStringToOString(data, RTL_TEXTENCODING_UTF8);
xmlChar *xData = (xmlChar*)o2.getStr();
- xmlNodePtr const pNode = xmlNewPI(xTarget, xData);
+ xmlNodePtr const pNode = xmlNewDocPI(m_aDocPtr, xTarget, xData);
pNode->doc = m_aDocPtr;
Reference< XProcessingInstruction > const xRet(
static_cast< XNode* >(GetCNode(pNode).get()),
diff --git a/unoxml/source/dom/processinginstruction.cxx b/unoxml/source/dom/processinginstruction.cxx
index c5cbaa96866b..44565738ddf6 100644
--- a/unoxml/source/dom/processinginstruction.cxx
+++ b/unoxml/source/dom/processinginstruction.cxx
@@ -54,46 +54,89 @@ namespace DOM
/**
The content of this processing instruction.
*/
- OUString SAL_CALL CProcessingInstruction::getData() throw (RuntimeException)
+ OUString SAL_CALL
+ CProcessingInstruction::getData() throw (RuntimeException)
{
- // XXX
- return OUString();
+ ::osl::MutexGuard const g(m_rMutex);
+
+ 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.
*/
- OUString SAL_CALL CProcessingInstruction::getTarget() throw (RuntimeException)
+ OUString SAL_CALL
+ CProcessingInstruction::getTarget() throw (RuntimeException)
{
- // XXX
- return OUString();
- }
+ ::osl::MutexGuard const g(m_rMutex);
+ 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.
*/
- void SAL_CALL CProcessingInstruction::setData(const OUString& /*data*/) throw (RuntimeException, DOMException)
+ void SAL_CALL CProcessingInstruction::setData(OUString const& rData)
+ throw (RuntimeException, DOMException)
{
- // XXX
- }
+ ::osl::MutexGuard const g(m_rMutex);
+
+ if (0 == m_aNodePtr) {
+ throw RuntimeException();
+ }
+ 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::getNodeName()throw (RuntimeException)
+ OUString SAL_CALL
+ CProcessingInstruction::getNodeName() throw (RuntimeException)
{
::osl::MutexGuard const g(m_rMutex);
- OUString aName;
- if (m_aNodePtr != NULL)
- {
- const xmlChar* xName = m_aNodePtr->name;
- aName = OUString((sal_Char*)xName, strlen((char*)xName), RTL_TEXTENCODING_UTF8);
+ if (0 == m_aNodePtr) {
+ return ::rtl::OUString();
}
- return aName;
+
+ 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)
+ OUString SAL_CALL CProcessingInstruction::getNodeValue()
+ throw (RuntimeException)
{
return getData();
}
+
+ void SAL_CALL
+ CProcessingInstruction::setNodeValue(OUString const& rNodeValue)
+ throw (RuntimeException, DOMException)
+ {
+ return setData(rNodeValue);
+ }
}
diff --git a/unoxml/source/dom/processinginstruction.hxx b/unoxml/source/dom/processinginstruction.hxx
index 44cf07a0e7df..4bf8d52f3c41 100644
--- a/unoxml/source/dom/processinginstruction.hxx
+++ b/unoxml/source/dom/processinginstruction.hxx
@@ -81,6 +81,9 @@ namespace DOM
throw (RuntimeException);
virtual OUString SAL_CALL getNodeValue()
throw (RuntimeException);
+ virtual void SAL_CALL setNodeValue(OUString const& rNodeValue)
+ throw (RuntimeException, DOMException);
+
// --- delegation for XNde base.
virtual Reference< XNode > SAL_CALL appendChild(const Reference< XNode >& newChild)
throw (RuntimeException, DOMException)
@@ -189,11 +192,6 @@ namespace DOM
{
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)
throw (RuntimeException, DOMException)
{