void ElementImpl::formatForDebugger(char *buffer, unsigned length) const { DOMString result; DOMString s; s = nodeName(); if (s.length() > 0) { result += s; } s = getAttribute(ATTR_ID); if (s.length() > 0) { if (result.length() > 0) result += "; "; result += "id="; result += s; } s = getAttribute(ATTR_CLASS); if (s.length() > 0) { if (result.length() > 0) result += "; "; result += "class="; result += s; } strncpy(buffer, result.string().latin1(), length - 1); }
void ElementNSImpl::setPrefix(const DOMString &prefix) { DOMString xml = NodeImpl::getXmlString(); DOMString xmlURI = NodeImpl::getXmlURIString(); if (ownerDocument->getErrorChecking()) { if (isReadOnly()) { throw DOM_DOMException( DOM_DOMException::NO_MODIFICATION_ALLOWED_ERR, null); } if (prefix != null && !((DocumentImpl *)this->getOwnerDocument())->isXMLName(prefix)) { throw DOM_DOMException(DOM_DOMException::INVALID_CHARACTER_ERR, null); } if (namespaceURI == null) { throw DOM_DOMException(DOM_DOMException::NAMESPACE_ERR, null); } } if (prefix == null || prefix.length() == 0) { name = localName; return; } if (ownerDocument->getErrorChecking() && (prefix.equals(xml) && !namespaceURI.equals(xmlURI))) { throw DOM_DOMException(DOM_DOMException::NAMESPACE_ERR, null); } const XMLCh *p = prefix.rawBuffer(); for (int i = prefix.length(); --i >= 0;) if (*p++ == chColon) //prefix is malformed throw DOM_DOMException(DOM_DOMException::NAMESPACE_ERR, null); name = prefix + chColon + localName; //nodeName is changed too }
EppCommandInfoLaunchRegistration* EppCommandInfoLaunchRegistration::fromXML( const DOMNode& root ) { EppCommandInfoLaunchRegistration* cmd = new EppCommandInfoLaunchRegistration(); if( cmd == null ) { return null; } DOMNodeList* list = root.getChildNodes(); DOMNamedNodeMap* attrs = root.getAttributes(); for( unsigned int i = 0; i < list->getLength(); i++ ) { DOMNode* node = list->item(i); DOMString name = node->getLocalName(); if( name.isNull() ) { name = node->getNodeName(); } if( name.isNull() ) { continue; } if( (name.length() > 7) && name.substringData(0, 7).equals("launch:") ) { name = name.substringData(7, name.length() - 7); } if( name.equals("phase") ) { EppLaunchPhase *_pptr = EppLaunchPhase::fromXML(*node); if( null != _pptr ) { cmd->_phase = *_pptr; delete _pptr; } _pptr = null; } else if ( name.equals("applicationID") ) { cmd->_appId = EppUtil::getText(*node); } } for( unsigned int i = 0;i<attrs->getLength();i++ ) { DOMNode* attr = attrs->item(i); if( XS(attr->getNodeName()).equals("includeMark") ) { DOMString _v = attr->getNodeValue(); if( _v.length() > 0 ) { if( _v.equals("true") ) { cmd->includeMark(true); } } break; } } return cmd; }
bool DOM::strncmp( const DOMString &a, const DOMString &b, unsigned int len) { if(a.length() < len || b.length() < len) return false; if(memcmp(a.unicode(), b.unicode(), len*sizeof(QChar))) return true; return false; }
bool DOM::operator==( const DOMString &a, const DOMString &b ) { unsigned int l = a.length(); if( l != b.length() ) return false; if(!memcmp(a.unicode(), b.unicode(), l*sizeof(QChar))) return true; return false; }
bool DOM::strcasecmp( const DOMString &as, const DOMString &bs ) { if ( as.length() != bs.length() ) return true; const QChar *a = as.unicode(); const QChar *b = bs.unicode(); if ( a == b ) return false; if ( !( a && b ) ) return true; int l = as.length(); while ( l-- ) { if ( *a != *b && a->lower() != b->lower() ) return true; a++,b++; } return false; }
void KeyboardEventImpl::initKeyboardEvent(const DOMString &typeArg, bool canBubbleArg, bool cancelableArg, const AbstractView &viewArg, const DOMString &keyIdentifierArg, unsigned long keyLocationArg, const DOMString &modifiersList) { unsigned keyVal = 0; unsigned virtKeyVal = 0; m_keyLocation = keyLocationArg; // Figure out the code information from the key identifier. if(keyIdentifierArg.length() == 1) { // Likely to be normal unicode id, unless it's one of the few // special values. unsigned short code = keyIdentifierArg.unicode()[0]; if(code > 0x20 && code != 0x7F) keyVal = code; } if(!keyVal) // One of special keys, likely. virtKeyVal = keyIdentifiersToVirtKeys()->toRight(keyIdentifierArg.string().latin1()); // Process modifier list. QStringList mods = QStringList::split(' ', modifiersList.string().stripWhiteSpace().simplifyWhiteSpace()); unsigned modifiers = 0; for(QStringList::Iterator i = mods.begin(); i != mods.end(); ++i) if(unsigned mask = keyModifiersToCode()->toRight((*i).latin1())) modifiers |= mask; initKeyBaseEvent(typeArg, canBubbleArg, cancelableArg, viewArg, keyVal, virtKeyVal, modifiers); }
bool EppUtil::getTextAsBool( const DOMNode &root ) { DOMString str = getText(root); unsigned int length = str.length(); if ( length == 1 && (str.charAt(0) == (XMLCh)'1') ) { return true; } else if ( length == 4 ) { XMLCh c; c = str.charAt(0); if ( c != (XMLCh)'t' && c != (XMLCh)'T' ) return false; c = str.charAt(1); if ( c != (XMLCh)'r' && c != (XMLCh)'R' ) return false; c = str.charAt(2); if ( c != (XMLCh)'u' && c != (XMLCh)'U' ) return false; c = str.charAt(3); if ( c != (XMLCh)'e' && c != (XMLCh)'E' ) return false; return true; } return false; }
CSSValue CSSStyleDeclaration::getPropertyCSSValue( const DOMString &propertyName ) const { if(!impl) return 0; int id = getPropertyID(propertyName.string().ascii(), propertyName.length()); if (!id) return 0; return static_cast<CSSStyleDeclarationImpl *>(impl)->getPropertyCSSValue(id); }
bool CSSStyleSheetImpl::parseString(const DOMString &string, bool strict) { strictParsing = strict; const QString preprocessed = preprocess(string.string()); #ifdef CSS_STYLESHEET_DEBUG kdDebug( 6080 ) << "parsing sheet, len=" << string.length() << ", sheet is " << string.string() << endl; #endif const QChar *curP = preprocessed.unicode(); const QChar *endP = preprocessed.unicode() + preprocessed.length(); #ifdef CSS_STYLESHEET_DEBUG kdDebug( 6080 ) << "preprocessed sheet, len=" << preprocessed.length() << ", sheet is " << preprocessed << endl; #endif while (curP && (curP < endP)) { CSSRuleImpl *rule = parseRule(curP, endP); if(rule) { m_lstChildren->append(rule); rule->setParent(this); // rule->init(); } } return true; }
void CSSStyleDeclarationImpl::setProperty ( const DOMString &propertyString) { QList<CSSProperty> *props = parseProperties(propertyString.unicode(), propertyString.unicode()+propertyString.length()); if(!props || !props->count()) { kdDebug( 6080 ) << "no properties returned!" << endl; return; } props->setAutoDelete(false); unsigned int i = 0; if(!m_lstValues) { m_lstValues = new QList<CSSProperty>; m_lstValues->setAutoDelete( true ); } while(i < props->count()) { //kdDebug( 6080 ) << "setting property" << endl; CSSProperty *prop = props->at(i); removeProperty(prop->m_id); m_lstValues->append(prop); i++; } delete props; if (m_node) m_node->setChanged(true); }
void TextEvent::initTextEvent(const DOMString &typeArg, bool canBubbleArg, bool cancelableArg, const AbstractView &viewArg, long /*detailArg*/, const DOMString &outputStringArg, unsigned long keyValArg, unsigned long virtKeyValArg, bool /*inputGeneratedArg*/, bool numPadArg) { if (!impl) throw DOMException(DOMException::INVALID_STATE_ERR); if (impl->isTextInputEvent()) { //Initialize based on the outputStringArg or virtKeyValArg. QString text = outputStringArg.string(); if (outputStringArg.length() == 0 && virtKeyValArg) { text += QChar((unsigned short)virtKeyValArg); } TextEventImpl* tImpl = static_cast<TextEventImpl*>(impl); tImpl->initTextEvent(typeArg, canBubbleArg, cancelableArg, viewArg, text); } else { KeyboardEventImpl* kbImpl = static_cast<KeyboardEventImpl*>(impl); kbImpl->initKeyboardEvent(typeArg, canBubbleArg, cancelableArg, viewArg, keyValArg, virtKeyValArg, 0, numPadArg ? KeyboardEventImpl::DOM_KEY_LOCATION_NUMPAD : KeyboardEventImpl::DOM_KEY_LOCATION_STANDARD); } }
int DOMString::compareString(const DOMString &other) const { // Note: this strcmp does not match the semantics // of the standard C strcmp. All it needs to do is // define some less than - equals - greater than ordering // of strings. How doesn't matter. // unsigned int thisLen = length(); unsigned int otherLen = other.length(); if (thisLen < otherLen) return -1; if (thisLen > otherLen) return 1; if (thisLen == 0) return 0; XMLCh *thisP = this->fHandle->fDSData->fData; XMLCh *otherP = other.fHandle->fDSData->fData; unsigned int i; for (i=0; i<thisLen; i++) { if (thisP[i] < otherP[i]) return -1; else if (thisP[i] > otherP[i]) return 1; } return 0; }
DOMString CSSStyleDeclaration::removeProperty(const DOMString &property) { int id = getPropertyID(property.string().ascii(), property.length()); if(!impl || !id) return DOMString(); return static_cast< CSSStyleDeclarationImpl * >(impl)->removeProperty(id); }
DOMString ElementImpl::toString() const { QString result = openTagStartToString().string(); // Accumulate in QString, since DOMString can't append well. if(hasChildNodes()) { result += ">"; for(NodeImpl *child = firstChild(); child != NULL; child = child->nextSibling()) { DOMString kid = child->toString(); result += QConstString(kid.unicode(), kid.length()).string(); } result += "</"; result += tagName().string(); result += ">"; } else if(result.length() == 1) { // ensure we dont get results like < /> can happen when serialize document result = ""; } else { result += " />"; } return result; }
const DOMString Document::getNsPrefixForNsUriImplicit(const DOMString nsUriStr) const { DOMString explicitNsPrefix = getNsPrefixForNsUriExplicit(nsUriStr); if(explicitNsPrefix.length()>0) { return explicitNsPrefix; } list<DOMString>::const_iterator it = _unprefixedNamepspaces.begin(); unsigned int i = _prefixedNamespaces.size() + 1; for( ; it != _unprefixedNamepspaces.end(); it++, i++) { if(*it != nsUriStr) { continue; } ostringstream oss; oss << "ns" << i; DOMString nsPrefix = oss.str(); while(1) { ostringstream oss; oss << "ns" << i; nsPrefix = oss.str(); if(!isPrefixTaken(nsPrefix)) { return nsPrefix; } i++; } return DOMString(oss.str()); } return ""; }
DOMString CSSStyleDeclarationImpl::getPropertyPriority( const DOMString &propertyName ) { int id = getPropertyID(propertyName.string().ascii(), propertyName.length()); if(getPropertyPriority(id)) return DOMString("important"); return DOMString(); }
void CSSStyleDeclarationImpl::setProperty ( const DOMString &propertyString) { DOMString ppPropertyString = preprocess(propertyString.string(),true); QPtrList<CSSProperty> *props = parseProperties(ppPropertyString.unicode(), ppPropertyString.unicode()+ppPropertyString.length()); if(!props || !props->count()) return; props->setAutoDelete(false); if(!m_lstValues) { m_lstValues = new QPtrList<CSSProperty>; m_lstValues->setAutoDelete( true ); } CSSProperty *prop = props->first(); while( prop ) { removeProperty(prop->m_id, false); m_lstValues->append(prop); prop = props->next(); } delete props; setChanged(); }
EppCommandCreateSecDns* EppCommandCreateSecDns::fromXML( const DOMNode &root ) { EppCommandCreateSecDns * cmd = new EppCommandCreateSecDns(); if( cmd == null ) { return null; } DOMNodeList* list = root.getChildNodes(); for( unsigned int i = 0; i < list->getLength(); i++ ) { DOMNode* node = list->item(i); DOMString name = node->getLocalName(); if( name.isNull() ) { name = node->getNodeName(); } if( name.isNull() ) { continue; } if( name.substringData(0, 7).equals("secDNS:") ) { name = name.substringData(7, name.length() - 7); } if( name.equals("dsData") ) { EppSecDnsDsData * ds = EppSecDnsDsData::fromXML(*node); if( ds != null ) { cmd->add(*ds); delete ds; } } else if( name.equals("maxSigLife") ) { DOMString value = EppUtil::getText(*node); char *p = value.transcode(); if( p != null ) { cmd->maxSigLife = ::atoi(p); XercesString::Delete(p); } } else if( name.equals("keyData") ) { // FIXME(zhang) not supported cmd->keyDataPresent = true; EppSecDnsKeyData *kd = EppSecDnsKeyData::fromXML(*node); if( kd != null ) { cmd->add(*kd); delete kd; } } } return cmd; }
EppMarkMark* EppMarkMark::fromXML( const DOMNode& root, const char* ns) { EppMarkMark *_ret = new EppMarkMark(ns); DOMNodeList* list = root.getChildNodes(); int nsLen = strlen(ns); if( list == 0 ) { delete _ret; return NULL; } for( unsigned int i = 0; i < list->getLength(); i++ ) { DOMNode* node = list->item(i); DOMString name = node->getLocalName(); if( name.isNull() ) { name = node->getNodeName(); } if( name.isNull() ) { continue; } if( name.substringData(0, nsLen + 1).equals((_ret->getNameSpace() + ":").c_str()) ) { name = name.substringData(nsLen + 1, name.length() - ( nsLen + 1 )); } if( name.equals("trademark") ) { EppTrademarkData *_tmd = EppTrademarkData::fromXML(*node, ns); if( NULL != _tmd ) { _ret->_marks.addElement(_tmd); } } else if ( name.equals("court") ) { EppCourtData *_cd = EppCourtData::fromXML(*node, ns); if( NULL != _cd ) { _ret->_marks.addElement(_cd); } } else if ( name.equals("treatyOrStatute") ) { EppTreatyOrStatuteData *_tsd = EppTreatyOrStatuteData::fromXML(*node, ns); if( NULL != _tsd ) { _ret->_marks.addElement(_tsd ); } } } return _ret; }
void TextEventImpl::initTextEvent(const DOMString &typeArg, bool canBubbleArg, bool cancelableArg, const AbstractView &viewArg, const DOMString &text) { m_outputString = text; // See whether we can get a key out of this. unsigned keyCode = 0; if(text.length() == 1) keyCode = text.unicode()[0].unicode(); initKeyBaseEvent(typeArg, canBubbleArg, cancelableArg, viewArg, keyCode, 0, 0); }
EppResponseDataCreateLaunchRegistration* EppResponseDataCreateLaunchRegistration::fromXML( const DOMNode& root ) { EppResponseDataCreateLaunchRegistration *cmd = new EppResponseDataCreateLaunchRegistration(); if( cmd == null ) { return null; } DOMNodeList* list = root.getChildNodes(); for( unsigned int i = 0; i < list->getLength(); i++ ) { DOMNode* node = list->item(i); DOMString name = node->getLocalName(); if( name.isNull() ) { name = node->getNodeName(); } if( name.isNull() ) { continue; } if( (name.length() > 7) && name.substringData(0, 7).equals("launch:") ) { name = name.substringData(7, name.length() - 7); } if( name.equals("phase") ) { EppLaunchPhase *_pptr = EppLaunchPhase::fromXML(*node); if( null != _pptr ) { cmd->_phase = *_pptr; delete _pptr; } _pptr = null; } else if( name.equals("applicationID") ) { cmd->_appId = EppUtil::getText(*node); } } return cmd; }
bool CSSStyleSheetImpl::parseString(const DOMString &string, bool strict) { #ifdef CSS_STYLESHEET_DEBUG qDebug() << "parsing sheet, len=" << string.length() << ", sheet is " << string.string(); #endif strictParsing = strict; CSSParser p(strict); p.parseSheet(this, string); return true; }
void CSSStyleDeclarationImpl::setProperty( const DOMString &propName, const DOMString &value, const DOMString &priority ) { int id = getPropertyID(propName.string().lower().ascii(), propName.length()); if (!id) return; bool important = false; QString str = priority.string().lower(); if(str.contains("important")) important = true; setProperty(id, value, important); }
void CSSStyleDeclaration::setProperty( const DOMString &propName, const DOMString &value, const DOMString &priority ) { if(!impl) return; int id = getPropertyID(propName.string().lower().ascii(), propName.length()); if (!id) return; bool important = false; QString str = priority.string(); if (str.find("important", 0, false) != -1) important = true; static_cast<CSSStyleDeclarationImpl *>(impl)->setProperty( id, value, important ); }
UString::UString(const DOMString &d) { if (d.isNull()) { attach(&Rep::null); return; } unsigned int len = d.length(); UChar *dat = new UChar[len]; memcpy(dat, d.unicode(), len * sizeof(UChar)); rep = UString::Rep::create(dat, len); }
EppContact * EppContact::fromXML( const DOM_Node& root ) { EppContact * contact = new EppContact(); DOM_NodeList list = root.getChildNodes(); for( unsigned int i = 0; i < list.getLength(); i++ ) { DOM_Node node = list.item(i); DOMString name = node.getLocalName(); if( name == null ) { name = node.getNodeName(); } if( name == null ) { continue; } if( name.substringData(0, 8).equals("contact:") ) { name = name.substringData(8, name.length() - 8); } if( name.equals("id") ) { contact->id = EppUtil::getText(node); } else if( name.equals("ascii") ) { contact->ascii = EppContactData::fromXML(node); } else if( name.equals("i15d") ) { contact->i15d = EppContactData::fromXML(node); } else if( name.equals("voice") ) { contact->voice = EppE164::fromXML(node); } else if( name.equals("fax") ) { contact->fax = EppE164::fromXML(node); } else if( name.equals("email") ) { contact->email = EppUtil::getText(node); } else { contact->fromXMLCommon(node, name); } } return contact; }
void CSSStyleDeclarationImpl::setLengthProperty(int id, const DOMString &value, bool important, bool nonCSSHint) { strictParsing = false; setProperty( id, value, important, nonCSSHint); strictParsing = true; #if 0 // ### FIXME after 2.0 if(!value.unicode() || value.length() == 0) return; if(!m_lstValues) { m_lstValues = new QList<CSSProperty>; m_lstValues->setAutoDelete(true); } CSSValueImpl *v = parseUnit(value.unicode(), value.unicode()+value.length(), INTEGER | PERCENT | LENGTH, ); if(!v) { kdDebug( 6080 ) << "invalid length" << endl; return; } CSSPrimitiveValueImpl *p = static_cast<CSSPrimitiveValueImpl *>(v); if(p->primitiveType() == CSSPrimitiveValue::CSS_NUMBER) { // set the parsed number in pixels p->setPrimitiveType(CSSPrimitiveValue::CSS_PX); } CSSProperty *prop = new CSSProperty(); prop->m_id = id; prop->setValue(v); prop->m_bImportant = important; prop->nonCSSHint = nonCSSHint; m_lstValues->append(prop); #endif }
bool DOM::operator==( const DOMString &a, const char *b ) { unsigned int blen = strlen(b); if(a.length() != blen) return false; const QChar* aptr = a.stringPtr(); while( blen-- ) { if((*aptr++).latin1() != *b++) return false; } return true; }
bool DOM::strcasecmp( const DOMString &as, const char* bs ) { const QChar *a = as.unicode(); int l = as.length(); if ( !bs ) return ( l != 0 ); while ( l-- ) { if ( a->toLatin1() != *bs ) { char cc = ( ( *bs >= 'A' ) && ( *bs <= 'Z' ) ) ? ( ( *bs ) + 'a' - 'A' ) : ( *bs ); if ( a->toLower().toLatin1() != cc ) return true; } a++, bs++; } return ( *bs != '\0' ); }