Class JsonCustomPropsPartial
- class ooodev.utils.partial.json_custom_props_partial.JsonCustomPropsPartial(doc)[source]
Class to add custom properties to a document. The properties are stored in a json file embedded in the document.
Allows custom properties to be added to a document.
Note
Any value that can be serialized to JSON can be stored as a custom property. Classes can implement the
ooodev.io.json.json_encoder.JsonEncoder
class to provide custom serialization by overriding theon_json_encode()
method.- Parameters:
doc (OfficeDocumentT) –
- __init__(doc)[source]
Constructor.
- Parameters:
forms (Any) – The component that implements
XForm
.form_name (str, optional) – The name to assign to the form. Defaults to “CustomProperties”.
ctl_name (str, optional) – The name to assign to the hidden control. Defaults to “CustomProperties”.
doc (OfficeDocumentT) –
- get_custom_properties()[source]
Gets custom properties.
- Returns:
custom properties.
- Return type:
DotDict
Hint
DotDict is a class that allows you to access dictionary keys as attributes or keys. DotDict can be imported from
ooodev.utils.helper.dot_dict.DotDict
.
- get_custom_property(name, default=<object object>)[source]
Gets a custom property.
- Parameters:
name (str) – The name of the property.
default (Any, optional) – The default value to return if the property does not exist.
- Raises:
AttributeError – If the property is not found.
- Returns:
The value of the property.
- Return type:
Any
- has_custom_property(name)[source]
Gets if a custom property exists.
- Parameters:
name (str) – The name of the property to check.
- Returns:
True
if the property exists, otherwiseFalse
.- Return type:
bool
- remove_custom_property(name)[source]
Removes a custom property.
- Parameters:
name (str) – The name of the property to remove.
- Raises:
AttributeError – If the property is a forbidden key.
- Return type:
None
- set_custom_properties(properties)[source]
Sets custom properties.
- Parameters:
properties (DotDict) – custom properties to set.
- Return type:
None
Hint
DotDict is a class that allows you to access dictionary keys as attributes or keys. DotDict can be imported from
ooodev.utils.helper.dot_dict.DotDict
.- Return type:
None
- Parameters:
properties (DotDict) –