diff options
Diffstat (limited to 'unoxml/source/dom/processinginstruction.cxx')
-rw-r--r-- | unoxml/source/dom/processinginstruction.cxx | 99 |
1 files changed, 75 insertions, 24 deletions
diff --git a/unoxml/source/dom/processinginstruction.cxx b/unoxml/source/dom/processinginstruction.cxx index f999e36f695e..aa119c7ade0f 100644 --- a/unoxml/source/dom/processinginstruction.cxx +++ b/unoxml/source/dom/processinginstruction.cxx @@ -26,19 +26,24 @@ * ************************************************************************/ -#include "processinginstruction.hxx" -#include <com/sun/star/xml/sax/XExtendedDocumentHandler.hpp> +#include <processinginstruction.hxx> + #include <string.h> +#include <com/sun/star/xml/sax/XExtendedDocumentHandler.hpp> + + namespace DOM { - CProcessingInstruction::CProcessingInstruction(const xmlNodePtr aNodePtr) + CProcessingInstruction::CProcessingInstruction( + CDocument const& rDocument, ::osl::Mutex const& rMutex, + xmlNodePtr const pNode) + : CProcessingInstruction_Base(rDocument, rMutex, + NodeType_PROCESSING_INSTRUCTION_NODE, pNode) { - m_aNodeType = NodeType_PROCESSING_INSTRUCTION_NODE; - init_node(aNodePtr); } - void SAL_CALL CProcessingInstruction::saxify( + void CProcessingInstruction::saxify( const Reference< XDocumentHandler >& i_xHandler) { if (!i_xHandler.is()) throw RuntimeException(); Reference< XExtendedDocumentHandler > xExtended(i_xHandler, UNO_QUERY); @@ -50,46 +55,92 @@ 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( + ::rtl::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) { - OUString aName; - if (m_aNodePtr != NULL) - { - const xmlChar* xName = m_aNodePtr->name; - aName = OUString((sal_Char*)xName, strlen((char*)xName), RTL_TEXTENCODING_UTF8); + ::osl::MutexGuard const g(m_rMutex); + + 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); + } } /* vim:set shiftwidth=4 softtabstop=4 expandtab: */ |