use of com.gargoylesoftware.css.parser.CSSOMParser in project LoboEvolution by LoboEvolution.
the class CSSImportRuleImpl method setCssText.
/**
* {@inheritDoc}
*/
@Override
public void setCssText(final String cssText) throws DOMException {
try {
final CSSOMParser parser = new CSSOMParser();
final AbstractCSSRuleImpl r = parser.parseRule(cssText);
// The rule must be an import rule
if (r instanceof CSSImportRuleImpl) {
href_ = ((CSSImportRuleImpl) r).href_;
media_ = ((CSSImportRuleImpl) r).media_;
} else {
throw new DOMException(DOMException.INVALID_MODIFICATION_ERR, DOMException.EXPECTING_IMPORT_RULE);
}
} catch (final CSSException e) {
throw new DOMException(DOMException.SYNTAX_ERR, DOMException.SYNTAX_ERROR, e.getMessage());
} catch (final IOException e) {
throw new DOMException(DOMException.SYNTAX_ERR, DOMException.SYNTAX_ERROR, e.getMessage());
}
}
use of com.gargoylesoftware.css.parser.CSSOMParser in project LoboEvolution by LoboEvolution.
the class CSSPageRuleImpl method setCssText.
/**
* {@inheritDoc}
*/
@Override
public void setCssText(final String cssText) throws DOMException {
try {
final CSSOMParser parser = new CSSOMParser();
final AbstractCSSRuleImpl r = parser.parseRule(cssText);
// The rule must be a page rule
if (r instanceof CSSPageRuleImpl) {
pseudoPage_ = ((CSSPageRuleImpl) r).pseudoPage_;
style_ = ((CSSPageRuleImpl) r).style_;
} else {
throw new DOMException(DOMException.INVALID_MODIFICATION_ERR, DOMException.EXPECTING_PAGE_RULE);
}
} catch (final CSSException e) {
throw new DOMException(DOMException.SYNTAX_ERR, DOMException.SYNTAX_ERROR, e.getMessage());
} catch (final IOException e) {
throw new DOMException(DOMException.SYNTAX_ERR, DOMException.SYNTAX_ERROR, e.getMessage());
}
}
use of com.gargoylesoftware.css.parser.CSSOMParser in project LoboEvolution by LoboEvolution.
the class CSSStyleDeclarationImpl method setCssText.
/**
* Sets the css text.
* @param cssText the new css text
* @param cssErrorHandler the CSSErrorHandler to be used
* @throws DOMException in case of error
*/
public void setCssText(final String cssText, final CSSErrorHandler cssErrorHandler) throws DOMException {
try {
final CSSOMParser parser = new CSSOMParser();
parser.setErrorHandler(cssErrorHandler);
properties_.clear();
parser.parseStyleDeclaration(this, cssText);
} catch (final Exception e) {
throw new DOMException(DOMException.SYNTAX_ERR, DOMException.SYNTAX_ERROR, e.getMessage());
}
}
use of com.gargoylesoftware.css.parser.CSSOMParser in project LoboEvolution by LoboEvolution.
the class CSSValueImpl method setCssText.
/**
* Sets the css text.
*
* @param cssText the new css text
* @throws org.w3c.dom.DOMException in case of error
*/
public void setCssText(final String cssText) throws DOMException {
try {
final CSSOMParser parser = new CSSOMParser();
final CSSValueImpl v2 = parser.parsePropertyValue(cssText);
value_ = v2.value_;
} catch (final Exception e) {
throw new DOMException(DOMException.SYNTAX_ERR, DOMException.SYNTAX_ERROR, e.getMessage());
}
}
use of com.gargoylesoftware.css.parser.CSSOMParser in project LoboEvolution by LoboEvolution.
the class MediaListImpl method setMediaText.
/**
* Parses the given media text.
*
* @param mediaText text to be parsed
* @throws org.w3c.dom.DOMException in case of error
*/
public void setMediaText(final String mediaText) throws DOMException {
try {
final CSSOMParser parser = new CSSOMParser();
parser.setErrorHandler(ThrowCssExceptionErrorHandler.INSTANCE);
final MediaQueryList sml = parser.parseMedia(mediaText);
setMediaList(sml);
} catch (final CSSParseException e) {
throw new DOMException(DOMException.SYNTAX_ERR, e.getLocalizedMessage());
} catch (final IOException e) {
throw new DOMException(DOMException.NOT_FOUND_ERR, e.getLocalizedMessage());
}
}
Aggregations