Class CellStyler
- class ooodev.write.style.direct.table.cell_styler.CellStyler(owner, component)[source]
Bases:
WriteDocPropPartial,WriteTablePropPartial,EventsPartial,LoInstPropsPartial,QiPartial,FillColorPartial,WriteTableFillImgPartial,WriteTableCellBordersPartial,FontOnlyPartial,FontEffectsPartial,FontPartial,NumbersNumbersPartial,WriteParaAlignmentPartial,TheDictionaryPartialCell Styler class.
Class set various cell properties.
Events are raises when a style is being applied and when a style has been applied. The
WriteNamedEvent.TABLE_STYLE_APPLYINGevent is raised before a style is applied. TheWriteNamedEvent.TABLE_STYLE_APPLIEDevent is raised after a style has been applied. The event data is a dictionary that contains the following:cancel_apply: If set toTruethe style will not be applied. This is only used in theTABLE_STYLE_APPLYINGevent.this_component: The component that the style is being applied to. This is the normally same component passed to the constructor.styler_object: The style that is being applied. This isNonewhenTABLE_STYLE_APPLYINGis raised. Is the style that was applied whenTABLE_STYLE_APPLIEDis raised.
Other style specific data is also in the dictionary such as the parameter values used to apply the style.
The
event_args.event_sourceis the instance of theCellStylerclass.- Parameters:
owner (WriteTable) –
component (Any) –
- __init__(owner, component)[source]
Constructor.
- Parameters:
owner (WriteTable) – Write Table instance.
component (Any) – component instance.
- Return type:
None
- add_event_observers(*args)
Adds observers that gets their
triggermethod called when this classtriggermethod is called.- Parameters:
args (EventObserver) – One or more observers to add.
- Return type:
None
Note
Observers are removed automatically when they are out of scope.
- qi(atype, raise_err=False)
Generic method that get an interface instance from an object.
- Parameters:
atype (T) – Interface type to query obj for. Any Uno class that starts with ‘X’ such as XInterface
raise_err (bool, optional) – If True then raises MissingInterfaceError if result is None. Default False
- Raises:
MissingInterfaceError – If ‘raise_err’ is ‘True’ and result is None
- Returns:
instance of interface if supported; Otherwise, None
- Return type:
T | None
Note
When
raise_err=Truereturn value will never beNone.
- remove_event_observer(observer)
Removes an observer
- Parameters:
observer (EventObserver) – One or more observers to add.
- Returns:
Trueif observer has been removed; Otherwise,False.- Return type:
bool
- style_alignment(*, align=None, align_vert=None, txt_direction=None, align_last=None, expand_single_word=None, snap_to_grid=None)
Style Write Paragraph Alignment.
- Parameters:
align (ParagraphAdjust, optional) – Determines horizontal alignment of a paragraph.
align_vert (ParagraphVertAlignEnum, optional) – Determines vertical alignment of a paragraph.
text_direction (WritingMode, optional) – Determines the text direction.
align_last (LastLineKind, optional) – Determines the adjustment of the last line.
expand_single_word (bool, optional) – Determines if single words are stretched. It is only valid if
alignandalign_lastare also valid.snap_to_grid (bool, optional) – Determines snap to text grid (if active).
txt_direction (WritingMode | None) –
- Raises:
CancelEventError – If the event
before_paragraph_alignmentis cancelled and not handled.- Returns:
Alignment Style instance or
Noneif cancelled.- Return type:
Alignment | None
Hint
ParagraphAdjustcan be imported fromooo.dyn.style.paragraph_adjustParagraphVertAlignEnumcan be imported fromooo.dyn.text.paragraph_vert_alignLastLineKindcan be imported fromooodev.format.writer.direct.para.alignmentWritingModecan be imported fromooodev.format.inner.direct.write.para.alignWritingMode2Enumcan be imported fromoo.dyn.text.writing_mode2.
- style_alignment_get()
Gets the Alignment Style.
- Returns:
Alignment Style instance or
Noneif not available.- Return type:
Alignment | None
- style_area_color(color=-1)
Style Area Color.
- Parameters:
color (
Color, optional) – FillColor Color. Defaults toStandardColor.AUTO_COLOR.- Raises:
CancelEventError – If the event
before_style_area_coloris cancelled and not handled.- Returns:
FillColor instance or
Noneif cancelled.- Return type:
FillColorT | None
- style_area_color_get()
Gets the Area Color Style.
- Raises:
CancelEventError – If the event
before_style_area_color_getis cancelled and not handled.- Returns:
Area color style or
Noneif cancelled.- Return type:
FillColorT | None
- style_area_image(*, bitmap=None, name='', mode=ImgStyleKind.TILED, size=None, position=None, pos_offset=None, tile_offset=None, auto_name=False)
Style Area Color.
- Parameters:
bitmap (XBitmap, optional) – Bitmap instance. If
nameis not already in the Bitmap Table then this property is required.name (str, optional) – Specifies the name of the image. This is also the name that is used to store bitmap in LibreOffice Bitmap Table.
mode (ImgStyleKind, optional) – Specifies the image style, tiled, stretched etc. Default
ImgStyleKind.TILED.size (SizePercent, SizeMM, optional) – Size in percent (
0 - 100) or size inmmunits.position (RectanglePoint) – Tiling position of Image.
pos_offset (Offset, optional) – Tiling position offset.
tile_offset (OffsetColumn, OffsetRow, optional) – The tiling offset.
auto_name (bool, optional) – Specifies if
nameis ensured to be unique. Defaults toFalse.
- Raises:
CancelEventError – If the event
before_style_area_imgis cancelled and not handled.- Returns:
Fill Image instance or
Noneif cancelled.- Return type:
FillImgT | None
Hint
RectanglePointcan be imported fromooo.dyn.drawing.rectangle_pointImgStyleKindcan be imported fromooodev.format.inner.direct.write.fill.area.imgSizePercentcan be imported fromooodev.format.inner.common.format_types.size_percentSizeMMcan be imported fromooodev.utils.data_type.size_mmOffsetColumncan be imported fromooodev.format.inner.common.format_types.offset_columnOffsetRowcan be imported fromooodev.format.inner.common.format_types.offset_rowOffsetcan be imported fromooodev.utils.data_type.offset
- style_area_image_from_preset(preset)
Style Area Gradient from Preset.
- Parameters:
preset (PresetImageKind) – Preset Image Kind.
- Returns:
Chart Fill Image instance.
- Return type:
Hint
PresetImageKindcan be imported fromooodev.format.inner.preset.preset_image
- style_borders(*, right=None, left=None, top=None, bottom=None, border_side=None)
Style Write Character Borders.
- Parameters:
left (Side,, optional) – Specifies the line style at the left edge.
right (Side, optional) – Specifies the line style at the right edge.
top (Side, optional) – Specifies the line style at the top edge.
bottom (Side, optional) – Specifies the line style at the bottom edge.
border_side (Side, optional) – Specifies the line style at the top, bottom, left, right edges. If this argument has a value then arguments
top,bottom,left,rightare ignored
- Raises:
CancelEventError – If the event
before_style_cell_bordersis cancelled and not handled.- Returns:
Borders Style instance or
Noneif cancelled.- Return type:
Borders | None
Hint
BorderLinecan be imported fromooodev.format.writer.direct.char.bordersBorderLine2can be imported fromooodev.format.writer.direct.char.bordersBorderLineKindcan be imported fromooodev.format.writer.direct.char.bordersLineSizecan be imported fromooodev.format.writer.direct.char.bordersSidecan be imported fromooodev.format.inner.direct.structs.side
- style_borders_side(*, line=BorderLineKind.SOLID, color=0, width=LineSize.THIN)
Style All Write Character Borders.
- Parameters:
line (BorderLineStyleEnum, optional) – Line Style of the border. Default
BorderLineKind.SOLID.color (
Color, optional) – Color of the border. DefaultStandardColor.BLACKwidth (LineSize, float, UnitT, optional) – Contains the width in of a single line or the width of outer part of a double line (in
ptunits) or Class UnitT. If this value is zero, no line is drawn. DefaultLineSize.THIN
- Raises:
CancelEventError – If the event
before_style_cell_bordersis cancelled and not handled.- Returns:
Borders Style instance or
Noneif cancelled.- Return type:
Borders | None
Hint
BorderLine2can be imported fromooo.dyn.table.border_line2BorderLinecan be imported fromooo.dyn.table.border_lineBorderLineKindcan be imported fromooodev.format.inner.direct.structs.sideLineSizecan be imported fromooodev.format.inner.direct.structs.side
- style_font(name=None, size=None, font_style=None, lang=None)
Style Font.
- Parameters:
- Raises:
CancelEventError – If the event
before_style_font_onlyis cancelled and not handled.- Returns:
Font Only instance or
Noneif cancelled.- Return type:
FontOnlyT | None
See also
- style_font_effect(*, color=None, transparency=None, overline=None, underline=None, strike=None, word_mode=None, case=None, relief=None, outline=None, shadowed=None)
Style Font options.
- Parameters:
color (
Color, optional) – The value of the text color. If value is-1the automatic color is applied.transparency (Intensity, int, optional) – The transparency value from
0to100for the font color.overline (FontLine, optional) – Character overline values.
underline (FontLine, optional) – Character underline values.
strike (FontStrikeoutEnum, optional) – Determines the type of the strike out of the character.
word_mode (bool, optional) – If
True, the underline and strike-through properties are not applied to white spaces.case (CaseMapEnum, optional) – Specifies the case of the font.
relief (FontReliefEnum, optional) – Specifies the relief of the font.
outline (bool, optional) – Specifies if the font is outlined.
shadowed (bool, optional) – Specifies if the characters are formatted and displayed with a shadow effect.
- Raises:
CancelEventError – If the event
before_style_font_effectis cancelled and not handled.- Returns:
Font Effects instance or
Noneif cancelled.- Return type:
FontEffectsT | None
Hint
CaseMapEnumcan be imported fromooo.dyn.style.case_mapFontReliefEnumcan be imported fromooo.dyn.awt.font_reliefFontStrikeoutEnumcan be imported fromooo.dyn.awt.font_strikeoutFontLinecan be imported fromooodev.format.inner.direct.write.char.font.font_effectsIntensitycan be imported fromooodev.utils.data_type.intensityFontUnderlineEnumcan be imported fromooo.dyn.awt.font_underline
- style_font_effect_get()
Gets the font effect Style.
- Raises:
CancelEventError – If the event
before_style_font_effect_getis cancelled and not handled.- Returns:
Font Effect style or
Noneif cancelled.- Return type:
FontEffectsT | None
- style_font_effect_line(line=None, color=None, overline=False)
Style Font Underline or Overline.
This method is a subset of
style_font_effect()method for convenience.- Parameters:
color (
Color, optional) – The value of the text color. If value is-1the automatic color is applied.line (FontUnderlineEnum, optional) – Font Line kind.
overline (bool, optional) – If
Truethe line is overline, otherwise it is underline.
- Raises:
CancelEventError – If the event
before_style_font_effectis cancelled and not handled.- Returns:
Font Effects instance or
Noneif cancelled.- Return type:
FontEffectsT | None
Hint
FontUnderlineEnumcan be imported fromooo.dyn.awt.font_underline
- style_font_general(b=None, i=None, u=None, bg_color=None, bg_transparent=None, charset=None, color=None, family=None, name=None, overline=None, rotation=None, shadow_fmt=None, shadowed=None, size=None, slant=None, spacing=None, strike=None, subscript=None, superscript=None, underline=None, weight=None, word_mode=None)
Style Font.
- Parameters:
b (bool, optional) – Shortcut to set
weightto bold.i (bool, optional) – Shortcut to set
slantto italic.u (bool, optional) – Shortcut ot set
underlineto underline.bg_color (
Color, optional) – The value of the text background color.bg_transparent (bool, optional) – Determines if the text background color is set to transparent.
charset (CharSetEnum, optional) – The text encoding of the font.
color (
Color, optional) – The value of the text color. Setting to-1will cause automatic color.family (FontFamilyEnum, optional) – Font Family.
name (str, optional) – This property specifies the name of the font style. It may contain more than one name separated by comma.
overline (FontLine, optional) – Character overline values.
rotation (int, Angle, optional) – Specifies the rotation of a character in degrees. Depending on the implementation only certain values may be allowed.
shadow_fmt (ShadowFormat | None) – (ShadowFormat, optional): Determines the type, color, and width of the shadow.
shadowed (bool, optional) – Specifies if the characters are formatted and displayed with a shadow effect.
size (float, UnitT, optional) – This value contains the size of the characters in
pt(point) units or Class UnitT.slant (FontSlant, optional) – The value of the posture of the document such as
FontSlant.ITALIC.spacing (CharSpacingKind, float, UnitT, optional) – Specifies character spacing in
pt(point) units or Class UnitT.strike (FontStrikeoutEnum, optional) – Determines the type of the strike out of the character.
subscript (bool, optional) – Subscript option.
superscript (bool, optional) – Superscript option.
underline (FontLine, optional) – Character underline values.
weight (FontWeightEnum, optional) – The value of the font weight.
word_mode (bool, optional) – If
True, the underline and strike-through properties are not applied to white spaces.
- Raises:
CancelEventError – If the event
before_style_general_fontis cancelled and not handled.- Returns:
Font instance or
Noneif cancelled.- Return type:
FontT | None
Hint
FontFamilyEnumcan be imported fromooo.dyn.awt.font_familyCharSetEnumcan be imported fromooo.dyn.awt.char_setShadowFormatcan be imported fromooo.dyn.table.shadow_formatFontSlantcan be imported fromooo.dyn.awt.font_slantFontStrikeoutEnumcan be imported fromooo.dyn.awt.font_strikeoutFontWeightEnumcan be imported fromooo.dyn.awt.font_weightFontLinecan be imported fromooodev.format.inner.direct.write.char.font.font_effectsCharSpacingKindcan be imported fromooodev.format.inner.direct.write.char.font.font_position
- style_font_get()
Gets the font Style.
- Raises:
CancelEventError – If the event
before_style_font_only_getis cancelled and not handled.- Returns:
Font style or
Noneif cancelled.- Return type:
FontOnlyT | None
- style_numbers_numbers(num_format=0, num_format_index=-1, lang_locale=None)
Style numbers numbers.
- Parameters:
num_format (NumberFormatEnum, int, optional) – Type of a number format. Use this to select a default format. Defaults to 0 (General Format). Only used if
num_format_indexis-1(omitted).num_format_index (NumberFormatIndexEnum, int, optional) – Index of a number format. The enumeration values represent the built-in number formats. Defaults to
-1.lang_locale (Locale, optional) – Locale of the number format. Defaults to
Nonewhich used current Locale.
- Raises:
CancelEventError – If the event
before_style_number_numberis cancelled and not handled.- Returns:
Style Numbers instance or
Noneif cancelled.- Return type:
NumbersT | None
Hint
NumberFormatEnumcan be imported fromooo.dyn.util.number_formatNumberFormatIndexEnumcan be imported fromooo.dyn.i18n.number_format_indexLocalecan be imported fromooo.dyn.lang.locale
- style_numbers_numbers_get()
Gets the Numbers Style.
- Raises:
CancelEventError – If the event
before_style_number_number_getis cancelled and not handled.- Returns:
Numbers style or
Noneif cancelled.- Return type:
NumbersT | None
- style_numbers_numbers_get_from_index(idx, locale=None)
Gets the Numbers Style.
- Raises:
CancelEventError – If the event
before_style_number_number_from_indexis cancelled and not handled.- Returns:
Numbers style or
Noneif cancelled.- Return type:
NumbersT | None
- Parameters:
idx (int) –
locale (Locale | None) –
Hint
Localecan be imported fromooo.dyn.lang.locale
- style_numbers_numbers_get_from_str(nf_str, locale=None, auto_add=False)
Gets the Numbers Style.
- Parameters:
nf_str (str) – Format string.
lang_locale (Locale, optional) – Locale. Defaults to
None.auto_add (bool, optional) – If True, format string will be added to document if not found. Defaults to
False.source_format (bool, optional) – If
True, the number format will be linked to the source format. Defaults toFalse.locale (Locale | None) –
- Raises:
CancelEventError – If the event
before_style_number_number_from_indexis cancelled and not handled.- Returns:
Numbers style or
Noneif cancelled.- Return type:
NumbersT | None
Hint
Localecan be imported fromooo.dyn.lang.locale
- subscribe_event(event_name, callback)
Add an event listener to current instance.
- Parameters:
event_name (str) – Event Name.
callback (EventCallback) – Callback of the event listener.
- Return type:
None
- trigger_event(event_name, event_args)
Trigger an event on current instance.
- Parameters:
event_name (str) – Event Name.
event_args (EventArgsT) – Event Args.
- Return type:
None
- unsubscribe_event(event_name, callback)
Remove an event listener from current instance.
- Parameters:
event_name (str) – Event Name.
callback (EventCallback) – Callback of the event listener.
- Return type:
None
- property event_observer: EventObserver
Gets/Sets The Event Observer for this instance.
- Return type:
- property extra_data: TheDict
Extra Data Key Value Pair Dictionary.
Properties can be assigned properties and access like a dictionary and with dot notation.
Note
This is a dictionary object that can be used to store key value pairs. Generally speaking this data is not part of the object’s main data structure and is not saved with the object (document).
This property is used to store data that is not part of the object’s main data structure and can be used however the developer sees fit.
- Return type:
- property office_doc: OfficeDocumentT
Office Document.
- Return type:
- property write_table: WriteTable[Any]
Write Document.
- Return type:
WriteTable[Any]