diff options
author | Michael Stahl <mst@openoffice.org> | 2011-01-19 20:27:28 +0100 |
---|---|---|
committer | Michael Stahl <mst@openoffice.org> | 2011-01-19 20:27:28 +0100 |
commit | d76639d5d833a05a3181f7293e38a250dc6c1299 (patch) | |
tree | f868f4025d12b17c45c2b202c3879326d0d645c6 /unoxml/source/dom/element.cxx | |
parent | 76eac88260284d6c85c693f7186186a05e053c54 (diff) |
xmlfix3: unoxml: eradicate the bizarre concept of "carrier nodes":
add namespace data member to CAttr.
CAttr overrides getPrefix(), setPrefix(), getNamespaceURI().
CDocument::createAttributeNS() uses this new CAttr member instead of creating
a dummy carrier element.
CElement::setAttributeNode_Impl_Lock() and CNode::appendChild() do not free
the no longer existing dummy carrier element.
CNode::insertBefore() calls appendChild() for attributes
instead of ignoring namespace.
CNode::appendChild() does not invalidate attributes, because they are copied.
Diffstat (limited to 'unoxml/source/dom/element.cxx')
-rw-r--r-- | unoxml/source/dom/element.cxx | 40 |
1 files changed, 11 insertions, 29 deletions
diff --git a/unoxml/source/dom/element.cxx b/unoxml/source/dom/element.cxx index 4339fb569e7e..1403fc4060a5 100644 --- a/unoxml/source/dom/element.cxx +++ b/unoxml/source/dom/element.cxx @@ -503,9 +503,9 @@ namespace DOM */ Reference< XAttr > CElement::setAttributeNode_Impl_Lock( - Reference< XAttr > const& newAttr, bool const bNS) + Reference< XAttr > const& xNewAttr, bool const bNS) { - if (newAttr->getOwnerDocument() != getOwnerDocument()) { + if (xNewAttr->getOwnerDocument() != getOwnerDocument()) { DOMException e; e.Code = DOMExceptionType_WRONG_DOCUMENT_ERR; throw e; @@ -518,48 +518,30 @@ namespace DOM } // get the implementation - CNode *const pCNode = CNode::GetImplementation(newAttr); - if (!pCNode) { throw RuntimeException(); } + CAttr *const pCAttr = dynamic_cast<CAttr*>( + CNode::GetImplementation(xNewAttr)); + if (!pCAttr) { throw RuntimeException(); } xmlAttrPtr const pAttr = - reinterpret_cast<xmlAttrPtr>(pCNode->GetNodePtr()); + reinterpret_cast<xmlAttrPtr>(pCAttr->GetNodePtr()); if (!pAttr) { throw RuntimeException(); } // check whether the attribute is not in use by another element - xmlNsPtr pNs = NULL; - if (pAttr->parent != NULL) - { - if (strcmp((char*)pAttr->parent->name, "__private") == 0 - && pNs && pAttr->ns != NULL) - { - pNs = xmlSearchNs(m_aNodePtr->doc, m_aNodePtr, - pAttr->ns->prefix); - if (pNs == NULL || - strcmp((char*)pNs->href, (char*)pAttr->ns->href) != 0) - { - pNs = xmlNewNs(m_aNodePtr, pAttr->ns->href, - pAttr->ns->href); - } else { - throw RuntimeException(); - } - } + if (pAttr->parent) { + DOMException e; + e.Code = DOMExceptionType_INUSE_ATTRIBUTE_ERR; + throw e; } xmlAttrPtr res = NULL; if (bNS) { + xmlNsPtr const pNs( pCAttr->GetNamespace(m_aNodePtr) ); res = xmlNewNsProp(m_aNodePtr, pNs, pAttr->name, pAttr->children->content); } else { res = xmlNewProp(m_aNodePtr, pAttr->name, pAttr->children->content); } - // free carrier node ... - if (pAttr->parent != NULL && - strcmp((char*)pAttr->parent->name, "__private") == 0) - { - xmlFreeNode(pAttr->parent); - } - // get the new attr node Reference< XAttr > const xAttr( static_cast< XNode* >(GetOwnerDocument().GetCNode( |