Class StyleDefinitionsPart
java.lang.Object
org.docx4j.openpackaging.Base
org.docx4j.openpackaging.parts.Part
org.docx4j.openpackaging.parts.JaxbXmlPart<E>
org.docx4j.openpackaging.parts.JaxbXmlPartXPathAware<Styles>
org.docx4j.openpackaging.parts.WordprocessingML.StyleDefinitionsPart
- All Implemented Interfaces:
XPathEnabled<Styles>
-
Field Summary
FieldsModifier and TypeFieldDescriptionprivate StringIt is convenient to have a CSS representation of styles, and this part is a natural place to store it.private static final Stringprivate Styleprivate Styleprivate Stylestatic final Stringprivate static org.slf4j.Loggerstatic final Stringstatic final String(package private) static final StringFields inherited from class org.docx4j.openpackaging.parts.JaxbXmlPartXPathAware
binderFields inherited from class org.docx4j.openpackaging.parts.JaxbXmlPart
jaxbElement, jc, MAX_BYTES_Unmarshal_ErrorFields inherited from class org.docx4j.openpackaging.Base
contentType, partName, relationships -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptiongetCss()if this returns null; invoke createVirtualStylesForDocDefaults() @since 3.2.0 then try againprivate StylegetDefaultStyle(String type) getIDForStyleName(String name) Given the name of a style known in this part, return the corresponding style ID.Returns a map of styles defined in docx4j's KnownStyles.xml (not styles defined in your pkg)getLinkedStyle(String rStyleVal) For a run/character style return its linked paragraph style (if any), or vice versa.Given the ID of a style known in this part, return the corresponding style name.getStyleById(String id) private static StylegetStyleById(List<Style> styles, String id) voidinit()private static voidvoidprotectRestrictFormatting(List<String> allowedStyleNames, boolean removedNotAllowedFormatting, Set<String> stylesInUse) Restrict allowed formatting to specified styles.voidRefresh the style name - ID bimaps, based on styles currently defined in this part.voidvoidsetJaxbElement(Styles jaxbElement) You can't use this override to create/update a binder, since this would set the jaxbElement field to something different to the object being passed in (as a consequence of the process to create a binder).protected voidsetMceIgnorable(McIgnorableNamespaceDeclarator namespacePrefixMapper) Where the mc:Ignorable attribute is present, ensure its contents matches the ignorable namespaces actually present.Unmarshal a default set of styles, useful when creating this part from scratch.Methods inherited from class org.docx4j.openpackaging.parts.JaxbXmlPartXPathAware
createBinderAndJaxbElement, getBinder, getJAXBAssociationsForXPath, getJAXBAssociationsForXPath, getJAXBNodesViaXPath, getJAXBNodesViaXPath, unmarshal, unmarshalMethods inherited from class org.docx4j.openpackaging.parts.JaxbXmlPart
addMcChoiceNamespace, getConfiguredUnmarshaller, getContents, getJAXBContext, getJaxbElement, getMcChoiceNamespaces, getXML, getXMLStreamReader, inputStreamToXSR, isContentEqual, isUnmarshalled, marshal, marshal, marshal, marshal, pipe, pipe, pipe, preprocess, replacePartContent, setContents, setJAXBContext, setJaxbElement, transform, transformToDom, variableReplaceMethods inherited from class org.docx4j.openpackaging.parts.Part
getContentLengthAsLoaded, getOwningRelationshipPart, getPackage, getRelationshipType, getSourceRelationship, getSourceRelationships, getVersion, remove, rename, setContentLengthAsLoaded, setOwningRelationshipPart, setPackage, setPartShortcut, setRelationshipType, setSourceRelationship, setVersionMethods inherited from class org.docx4j.openpackaging.Base
addTargetPart, addTargetPart, addTargetPart, addTargetPart, getContentType, getPartName, getRelationshipsPart, getRelationshipsPart, getUserData, reset, setContentType, setPartName, setRelationships, setUserData
-
Field Details
-
log
private static org.slf4j.Logger log -
knownStyles
-
defaultCharacterStyle
-
DEFAULT_CHARACTER_STYLE_DEFAULT
- See Also:
-
defaultParagraphStyle
-
defaultTableStyle
-
wNamespaceDec
- See Also:
-
rPrDefaultsString
- See Also:
-
pPrDefaultsString
- See Also:
-
docDefaultsString
- See Also:
-
css
It is convenient to have a CSS representation of styles, and this part is a natural place to store it. HtmlCssHelper contains a method createCssForStyles which relies on StyleTree to generate CSS. -
styleIdToName
-
styleNameToId
-
-
Constructor Details
-
StyleDefinitionsPart
- Throws:
InvalidFormatException
-
StyleDefinitionsPart
- Throws:
InvalidFormatException
-
-
Method Details
-
init
public void init() -
setMceIgnorable
Description copied from class:JaxbXmlPartWhere the mc:Ignorable attribute is present, ensure its contents matches the ignorable namespaces actually present.- Overrides:
setMceIgnorablein classJaxbXmlPart<Styles>
-
getMceIgnorable
- Overrides:
getMceIgnorablein classJaxbXmlPart<Styles>
-
setJaxbElement
Description copied from class:JaxbXmlPartXPathAwareYou can't use this override to create/update a binder, since this would set the jaxbElement field to something different to the object being passed in (as a consequence of the process to create a binder). We don't want that, because calling code may then continue to manipulate the field, without effect.. See instead createBinderAndJaxbElement- Overrides:
setJaxbElementin classJaxbXmlPartXPathAware<Styles>
-
unmarshalDefaultStyles
Unmarshal a default set of styles, useful when creating this part from scratch.- Returns:
- the newly created root object of the java content tree
- Throws:
jakarta.xml.bind.JAXBException- If any unexpected errors occur while unmarshalling
-
initKnownStyles
private static void initKnownStyles() -
getKnownStyles
Returns a map of styles defined in docx4j's KnownStyles.xml (not styles defined in your pkg)- Returns:
-
getStyleById
- Parameters:
id-- Returns:
- Since:
- 3.0.0
-
getStyleById
- Parameters:
id-- Returns:
- Since:
- 3.0.1
-
getDefaultCharacterStyle
-
getDefaultParagraphStyle
if this returns null; invoke createVirtualStylesForDocDefaults() @since 3.2.0 then try again- Returns:
-
getDefaultTableStyle
- Since:
- 3.0
-
getDefaultStyle
-
getCss
-
setCss
-
getLinkedStyle
For a run/character style return its linked paragraph style (if any), or vice versa.- Parameters:
rStyleVal-- Returns:
-
protectRestrictFormatting
public void protectRestrictFormatting(List<String> allowedStyleNames, boolean removedNotAllowedFormatting, Set<String> stylesInUse) throws Docx4JException Restrict allowed formatting to specified styles. You don't want to use this directly; use the method with the same name in WordprocessingMLPackage Formatting or styles that aren't allowed are not removed.- Parameters:
allowedStyleNames-- Throws:
Docx4JException- Since:
- 3.3.0
-
getNameForStyleID
Given the ID of a style known in this part, return the corresponding style name.- Parameters:
id-- Returns:
- Since:
- 3.3.0
-
getIDForStyleName
Given the name of a style known in this part, return the corresponding style ID.- Parameters:
name-- Returns:
- Since:
- 3.3.0
-
refreshNameIdBiMaps
public void refreshNameIdBiMaps()Refresh the style name - ID bimaps, based on styles currently defined in this part.- Since:
- 3.3.0
-