Package com.itextpdf.tool.xml.css
Class StyleAttrCSSResolver
java.lang.Object
com.itextpdf.tool.xml.css.StyleAttrCSSResolver
- All Implemented Interfaces:
CSSResolver
Resolves CSS properties.
-
Field Summary
FieldsModifier and TypeFieldDescriptionprivate final CssFiles
private CssInheritanceRules
private FileRetrieve
static final String
private final CssUtils
-
Constructor Summary
ConstructorsConstructorDescriptionConstruct a newStyleAttrCSSResolver
with default settings.StyleAttrCSSResolver
(CssFiles cssFiles) Construct a new StyleAttrCSSResolver with the givenCssFiles
and theDefaultCssInheritanceRules
.StyleAttrCSSResolver
(CssFiles cssFiles, CssUtils utils) Construct a new StyleAttrCSSResolver with the givenCssFiles
andCssUtils
and theDefaultCssInheritanceRules
.StyleAttrCSSResolver
(CssFiles cssFiles, FileRetrieve r) StyleAttrCSSResolver
(CssInheritanceRules rules, CssFiles cssFiles, CssUtils utils) StyleAttrCSSResolver
(CssInheritanceRules rules, CssFiles cssFiles, CssUtils utils, FileRetrieve fileRetrieve) -
Method Summary
Modifier and TypeMethodDescriptionvoid
Add a file to the CssFiles Collection.void
Add a piece of CSS code.void
Add a piece of CSS code.void
addCssFile
(String href, boolean isPersistent) Add a file to the CssFiles Collection.private boolean
canInherite
(Tag t, String property) Defaults to true if noCssInheritanceRules
implementation set.clear()
private String
mergeTextDecorationRules
(String oldRule, String newRule) private boolean
mustInherit
(String tag) Defaults to true if noCssInheritanceRules
implementation set.void
resolveStyles
(Tag t) Also taking into account the CSS properties of any parent tag in the given tag.void
setCssInheritance
(CssInheritanceRules cssInheritanceRules) By setting an implementation ofCssInheritanceRules
a developer can set rules on what css selectors are inherited from parent tags.void
void
setFileRetrieve
(FileRetrieve retrieve) TheFileRetrieve
implementation to use inaddCss(String, boolean)
.private void
-
Field Details
-
STYLE
- See Also:
-
utils
-
inherit
-
cssFiles
-
retrieve
-
-
Constructor Details
-
StyleAttrCSSResolver
public StyleAttrCSSResolver()Construct a newStyleAttrCSSResolver
with default settings. -
StyleAttrCSSResolver
Construct a new StyleAttrCSSResolver with the givenCssFiles
and theDefaultCssInheritanceRules
.- Parameters:
cssFiles
- aCssFiles
implementation.
-
StyleAttrCSSResolver
Construct a new StyleAttrCSSResolver with the givenCssFiles
andCssUtils
and theDefaultCssInheritanceRules
.- Parameters:
cssFiles
- aCssFiles
implementation.utils
- the CssUtils to use.
-
StyleAttrCSSResolver
- Parameters:
rules
- theCssInheritanceRules
to use.cssFiles
- aCssFiles
implementation.utils
- the CssUtils to use.
-
StyleAttrCSSResolver
public StyleAttrCSSResolver(CssInheritanceRules rules, CssFiles cssFiles, CssUtils utils, FileRetrieve fileRetrieve) - Parameters:
rules
- theCssInheritanceRules
to use.cssFiles
- aCssFiles
implementation.utils
- the CssUtils to use.fileRetrieve
- theFileRetrieve
implementation
-
StyleAttrCSSResolver
- Parameters:
cssFiles
- theCssFile
implementationr
- theFileRetrieve
implementation
-
-
Method Details
-
resolveStyles
Also taking into account the CSS properties of any parent tag in the given tag.- Specified by:
resolveStyles
in interfaceCSSResolver
- Parameters:
t
- the tag.- See Also:
-
mergeTextDecorationRules
-
splitRules
- Parameters:
css
- the css map to populatekey
- the propertyvalue
- the value
-
setCssInheritance
By setting an implementation ofCssInheritanceRules
a developer can set rules on what css selectors are inherited from parent tags.- Parameters:
cssInheritanceRules
- the inherit to set
-
canInherite
Defaults to true if noCssInheritanceRules
implementation set.- Parameters:
t
-property
-- Returns:
- true if may be inherited false otherwise
-
mustInherit
Defaults to true if noCssInheritanceRules
implementation set.- Parameters:
tag
-- Returns:
- true if must be inherited false otherwise
-
addCss
public void addCss(String content, String charSet, boolean isPersistent) throws CssResolverException Description copied from interface:CSSResolver
Add a piece of CSS code.- Specified by:
addCss
in interfaceCSSResolver
- Parameters:
content
- the CSScharSet
- a charsetisPersistent
- true if the added css should not be deleted on a call to clear- Throws:
CssResolverException
- thrown if something goes wrong
-
addCssFile
Add a file to the CssFiles Collection.- Specified by:
addCssFile
in interfaceCSSResolver
- Parameters:
href
- the path, if it starts with http we try to retrieve the file from the net, if not we try a normal file operation.isPersistent
- true if the added css should not be deleted on a call to clear- Throws:
CssResolverException
- thrown if something goes wrong
-
addCss
Add a file to the CssFiles Collection.- Specified by:
addCss
in interfaceCSSResolver
- Parameters:
file
- the CssFile to add.
-
addCss
Description copied from interface:CSSResolver
Add a piece of CSS code.- Specified by:
addCss
in interfaceCSSResolver
- Parameters:
content
- the content to parse to cssisPersistent
- true if the added css should not be deleted on a call to clear- Throws:
CssResolverException
- thrown if something goes wrong
-
setCssInheritanceRules
- Parameters:
inherit
- the inherit to set
-
setFileRetrieve
TheFileRetrieve
implementation to use inaddCss(String, boolean)
.- Specified by:
setFileRetrieve
in interfaceCSSResolver
- Parameters:
retrieve
- the retrieve to set
-
clear
- Specified by:
clear
in interfaceCSSResolver
- Returns:
- an instance of this resolver
- Throws:
CssResolverException
- thrown if something goes wrong
-