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>
public final class StyleDefinitionsPart extends JaxbXmlPartXPathAware<Styles>
-
Field Summary
Fields Modifier and Type Field Description static java.lang.StringdocDefaultsStringstatic java.lang.StringpPrDefaultsStringstatic java.lang.StringrPrDefaultsStringFields inherited from class org.docx4j.openpackaging.parts.JaxbXmlPart
jaxbElement, jc, MAX_BYTES_Unmarshal_Error -
Constructor Summary
Constructors Constructor Description StyleDefinitionsPart()StyleDefinitionsPart(PartName partName) -
Method Summary
Modifier and Type Method Description java.lang.StringgetCss()StylegetDefaultCharacterStyle()StylegetDefaultParagraphStyle()if this returns null; invoke createVirtualStylesForDocDefaults() @since 3.2.0 then try againStylegetDefaultTableStyle()java.lang.StringgetIDForStyleName(java.lang.String name)Given the name of a style known in this part, return the corresponding style ID.static java.util.Map<java.lang.String,Style>getKnownStyles()Returns a map of styles defined in docx4j's KnownStyles.xml (not styles defined in your pkg)StylegetLinkedStyle(java.lang.String rStyleVal)For a run/character style return its linked paragraph style (if any), or vice versa.java.lang.StringgetMceIgnorable()java.lang.StringgetNameForStyleID(java.lang.String id)Given the ID of a style known in this part, return the corresponding style name.StylegetStyleById(java.lang.String id)voidinit()voidprotectRestrictFormatting(java.util.List<java.lang.String> allowedStyleNames, boolean removedNotAllowedFormatting, java.util.Set<java.lang.String> stylesInUse)Restrict allowed formatting to specified styles.voidrefreshNameIdBiMaps()Refresh the style name - ID bimaps, based on styles currently defined in this part.voidsetCss(java.lang.String css)voidsetJaxbElement(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.java.lang.ObjectunmarshalDefaultStyles()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, getContents, getJAXBContext, getJaxbElement, getMcChoiceNamespaces, getXML, isContentEqual, isUnmarshalled, marshal, marshal, marshal, marshal, pipe, pipe, pipe, setContents, setJAXBContext, setJaxbElement, transform, 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
-
rPrDefaultsString
public static final java.lang.String rPrDefaultsString- See Also:
- Constant Field Values
-
pPrDefaultsString
public static final java.lang.String pPrDefaultsString- See Also:
- Constant Field Values
-
docDefaultsString
public static final java.lang.String docDefaultsString- See Also:
- Constant Field Values
-
-
Constructor Details
-
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
public java.lang.String 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
public java.lang.Object unmarshalDefaultStyles() throws javax.xml.bind.JAXBExceptionUnmarshal a default set of styles, useful when creating this part from scratch.- Returns:
- the newly created root object of the java content tree
- Throws:
javax.xml.bind.JAXBException- If any unexpected errors occur while unmarshalling
-
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
-
getDefaultCharacterStyle
-
getDefaultParagraphStyle
if this returns null; invoke createVirtualStylesForDocDefaults() @since 3.2.0 then try again- Returns:
-
getDefaultTableStyle
- Since:
- 3.0
-
getCss
public java.lang.String getCss() -
setCss
public void setCss(java.lang.String css) -
getLinkedStyle
For a run/character style return its linked paragraph style (if any), or vice versa.- Parameters:
rStyleVal-- Returns:
-
protectRestrictFormatting
public void protectRestrictFormatting(java.util.List<java.lang.String> allowedStyleNames, boolean removedNotAllowedFormatting, java.util.Set<java.lang.String> stylesInUse) throws Docx4JExceptionRestrict 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
public java.lang.String getNameForStyleID(java.lang.String id)Given the ID of a style known in this part, return the corresponding style name.- Parameters:
id-- Returns:
- Since:
- 3.3.0
-
getIDForStyleName
public java.lang.String getIDForStyleName(java.lang.String name)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
-