/** * */ public void initialize(ICSSStyleDeclaration decl) { fProperties.clear(); if (fModified != null) fModified.clear(); if (decl == null) return; int nProperties = decl.getLength(); for (int i = 0; i < nProperties; i++) { String propName = decl.item(i); if (propName != null) { String propN = propName.trim().toLowerCase(); if (propN.length() != 0) { CSSValue val = decl.getPropertyCSSValue(propName); if (val != null) fProperties.put(propN, val); } } } }
/** * This function exports all property/value pairs to 'decl' declaration */ public void applyFull(ICSSStyleDeclaration decl) { if (decl == null) return; Enumeration keys = fProperties.keys(); while (keys.hasMoreElements()) { Object key = keys.nextElement(); Object val = fProperties.get(key); String value = (val instanceof ICSSValue) ? ((ICSSValue) val).getCSSValueText() : val.toString(); if (value == null || value.length() <= 0) decl.removeProperty(key.toString()); else decl.setProperty(key.toString(), value.trim(), (val instanceof ValueData && ((ValueData) val).important) ? "!important" : "");//$NON-NLS-2$//$NON-NLS-1$ } }
return; CSSLinkConverter conv = new CSSLinkConverter(decl.getOwnerDocument().getModel()); int nProperties = decl.getLength(); for (int i = 0; i < nProperties; i++) { String propName = decl.item(i); if (propName != null) { String propN = propName.trim().toLowerCase(); if (propN.length() != 0) { PropCMProperty prop = PropCMProperty.getInstanceOf(propN); String priority = decl.getPropertyPriority(propName); boolean important = priority != null && priority.length() > 0; if (prop != null && prop.isShorthand()) { expandToLeaf(prop, decl.getPropertyValue(propName), context); ICSSStyleDeclItem declItem = (ICSSStyleDeclItem) decl.getDeclItemNode(propName).cloneNode(true); int nValues = declItem.getLength(); for (int j = 0; j < nValues; j++) {
ICSSStyleDeclItem declItem = ((CSSQueryDeclarationData) val).getDeclItem(); if (declItem.getLength() <= 0) { ICSSStyleDeclItem itemToRemove = decl.getDeclItemNode(key.toString()); if (itemToRemove != null) { decl.removeDeclItemNode(itemToRemove); decl.setDeclItemNode(declItem); ICSSStyleDeclItem itemToRemove = decl.getDeclItemNode(key.toString()); if (itemToRemove != null) { decl.removeDeclItemNode(itemToRemove); decl.setProperty(key.toString(), value, null);
/** * This function exports modified property/value pairs to 'decl' * declaration */ public void applyModified(ICSSStyleDeclaration decl) { if (decl == null || fModified == null) return; Iterator it = fModified.iterator(); while (it.hasNext()) { Object key = it.next(); Object val = fProperties.get(key); String value = (val instanceof ICSSValue) ? ((ICSSValue) val).getCSSValueText() : ((val != null) ? val.toString() : null); if (value == null || value.length() <= 0) decl.removeProperty(key.toString()); else decl.setProperty(key.toString(), value.trim(), (val instanceof ValueData && ((ValueData) val).important) ? "!important" : "");//$NON-NLS-2$//$NON-NLS-1$ } }