summaryrefslogtreecommitdiff
path: root/unoxml
diff options
context:
space:
mode:
authorOliver Bolte <obo@openoffice.org>2008-02-26 13:48:46 +0000
committerOliver Bolte <obo@openoffice.org>2008-02-26 13:48:46 +0000
commit9f892eb3a4434b80a752b5162a932b6dff1ddcc2 (patch)
treeed5b0f6977309119acb9a9ed7f64dce3526a7257 /unoxml
parentc1187e64f0c0d49444ad2516a929811249e58fcd (diff)
INTEGRATION: CWS custommeta (1.10.30); FILE MERGED
2008/02/26 10:40:45 mst 1.10.30.5: RESYNC: (1.11-1.12); FILE MERGED 2008/02/07 15:11:33 mst 1.10.30.4: - unoxml/source/dom/{document.cxx,element.cxx,saxbuilder.cxx}: + remove debugging printf calls (and worse...) 2008/02/01 10:36:23 mst 1.10.30.3: RESYNC: (1.10-1.11); FILE MERGED 2008/01/03 14:21:15 mst 1.10.30.2: - unoxml/source/dom/element.cxx: + found another implementation of xml::sax::XAttributeList in comphelper good thing there's so many of them to choose from... - unoxml/source/dom/REMOVEME.cxx: + remove... 2007/12/07 14:05:56 mst 1.10.30.1: - unoxml/source/dom/document.{hxx,cxx}: implement interface css::xml::sax::XSAXSerializable - unoxml/source/dom/*.{hxx,cxx}: add virtual method saxify() on all subclasses of CNode add missing implementations of getLocalName()
Diffstat (limited to 'unoxml')
-rw-r--r--unoxml/source/dom/element.cxx60
1 files changed, 58 insertions, 2 deletions
diff --git a/unoxml/source/dom/element.cxx b/unoxml/source/dom/element.cxx
index ca87b75fdc6f..3d9e307276a7 100644
--- a/unoxml/source/dom/element.cxx
+++ b/unoxml/source/dom/element.cxx
@@ -4,9 +4,9 @@
*
* $RCSfile: element.cxx,v $
*
- * $Revision: 1.12 $
+ * $Revision: 1.13 $
*
- * last change: $Author: ihi $ $Date: 2008-02-04 13:56:41 $
+ * last change: $Author: obo $ $Date: 2008-02-26 14:48:46 $
*
* The Contents of this file are made available subject to
* the terms of GNU Lesser General Public License Version 2.1.
@@ -40,8 +40,11 @@
#include "attributesmap.hxx"
#include "../events/mutationevent.hxx"
+#include "comphelper/attributelist.hxx"
+
#include <string.h>
+
namespace DOM
{
@@ -51,6 +54,55 @@ namespace DOM
init_node(aNodePtr);
}
+ void SAL_CALL CElement::saxify(
+ const Reference< XDocumentHandler >& i_xHandler) {
+ if (!i_xHandler.is()) throw RuntimeException();
+ comphelper::AttributeList *pAttrs =
+ new comphelper::AttributeList();
+ OUString type = OUString::createFromAscii("");
+ // add namespace definitions to attributes
+ for (xmlNsPtr pNs = m_aNodePtr->nsDef; pNs != 0; pNs = pNs->next) {
+ const xmlChar *pPrefix = pNs->prefix;
+ OUString prefix(reinterpret_cast<const sal_Char*>(pPrefix),
+ strlen(reinterpret_cast<const char*>(pPrefix)),
+ RTL_TEXTENCODING_UTF8);
+ OUString name = (prefix.equalsAscii(""))
+ ? OUString::createFromAscii("xmlns")
+ : OUString::createFromAscii("xmlns:") + prefix;
+ const xmlChar *pHref = pNs->href;
+ OUString val(reinterpret_cast<const sal_Char*>(pHref),
+ strlen(reinterpret_cast<const char*>(pHref)),
+ RTL_TEXTENCODING_UTF8);
+ pAttrs->AddAttribute(name, type, val);
+ }
+ // add attributes
+ for (xmlAttrPtr pAttr = m_aNodePtr->properties;
+ pAttr != 0; pAttr = pAttr->next) {
+ CNode * pNode = CNode::get(reinterpret_cast<xmlNodePtr>(pAttr));
+ OSL_ENSURE(pNode != 0, "CNode::get returned 0");
+ OUString prefix = pNode->getPrefix();
+ OUString name = (prefix.getLength() == 0)
+ ? pNode->getLocalName()
+ : prefix + OUString(static_cast<sal_Unicode>(':')) + pNode->getLocalName();
+ OUString val = pNode->getNodeValue();
+ pAttrs->AddAttribute(name, type, val);
+ }
+ OUString prefix = getPrefix();
+ OUString name = (prefix.getLength() == 0)
+ ? getLocalName()
+ : prefix + OUString(static_cast<sal_Unicode>(':')) + getLocalName();
+ Reference< XAttributeList > xAttrList(pAttrs);
+ i_xHandler->startElement(name, xAttrList);
+ // recurse
+ for (xmlNodePtr pChild = m_aNodePtr->children;
+ pChild != 0; pChild = pChild->next) {
+ CNode * pNode = CNode::get(pChild);
+ OSL_ENSURE(pNode != 0, "CNode::get returned 0");
+ pNode->saxify(i_xHandler);
+ }
+ i_xHandler->endElement(name);
+ }
+
/**
Retrieves an attribute value by name.
return empty string if attribute is not set
@@ -467,6 +519,10 @@ namespace DOM
}
OUString SAL_CALL CElement::getNodeName()throw (RuntimeException)
{
+ return getLocalName();
+ }
+ OUString SAL_CALL CElement::getLocalName()throw (RuntimeException)
+ {
OUString aName;
if (m_aNodePtr != NULL)
{