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, TheDictionaryPartial

Cell 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_APPLYING event is raised before a style is applied. The WriteNamedEvent.TABLE_STYLE_APPLIED event is raised after a style has been applied. The event data is a dictionary that contains the following:

  • cancel_apply: If set to True the style will not be applied. This is only used in the TABLE_STYLE_APPLYING event.

  • 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 is None when TABLE_STYLE_APPLYING is raised. Is the style that was applied when TABLE_STYLE_APPLIED is raised.

Other style specific data is also in the dictionary such as the parameter values used to apply the style.

The event_args.event_source is the instance of the CellStyler class.

Parameters:
__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 trigger method called when this class trigger method 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=True return value will never be None.

remove_event_observer(observer)

Removes an observer

Parameters:

observer (EventObserver) – One or more observers to add.

Returns:

True if 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 align and align_last are 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_alignment is cancelled and not handled.

Returns:

Alignment Style instance or None if cancelled.

Return type:

Alignment | None

Hint

  • ParagraphAdjust can be imported from ooo.dyn.style.paragraph_adjust

  • ParagraphVertAlignEnum can be imported from ooo.dyn.text.paragraph_vert_align

  • LastLineKind can be imported from ooodev.format.writer.direct.para.alignment

  • WritingMode can be imported from ooodev.format.inner.direct.write.para.align

  • WritingMode2Enum can be imported from oo.dyn.text.writing_mode2.

style_alignment_get()

Gets the Alignment Style.

Returns:

Alignment Style instance or None if not available.

Return type:

Alignment | None

style_area_color(color=-1)

Style Area Color.

Parameters:

color (Color, optional) – FillColor Color. Defaults to StandardColor.AUTO_COLOR.

Raises:

CancelEventError – If the event before_style_area_color is cancelled and not handled.

Returns:

FillColor instance or None if cancelled.

Return type:

FillColorT | None

style_area_color_get()

Gets the Area Color Style.

Raises:

CancelEventError – If the event before_style_area_color_get is cancelled and not handled.

Returns:

Area color style or None if 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 name is 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 in mm units.

  • 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 name is ensured to be unique. Defaults to False.

Raises:

CancelEventError – If the event before_style_area_img is cancelled and not handled.

Returns:

Fill Image instance or None if cancelled.

Return type:

FillImgT | None

Hint

  • RectanglePoint can be imported from ooo.dyn.drawing.rectangle_point

  • ImgStyleKind can be imported from ooodev.format.inner.direct.write.fill.area.img

  • SizePercent can be imported from ooodev.format.inner.common.format_types.size_percent

  • SizeMM can be imported from ooodev.utils.data_type.size_mm

  • OffsetColumn can be imported from ooodev.format.inner.common.format_types.offset_column

  • OffsetRow can be imported from ooodev.format.inner.common.format_types.offset_row

  • Offset can be imported from ooodev.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:

FillImgT

Hint

  • PresetImageKind can be imported from ooodev.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, right are ignored

Raises:

CancelEventError – If the event before_style_cell_borders is cancelled and not handled.

Returns:

Borders Style instance or None if cancelled.

Return type:

Borders | None

Hint

  • BorderLine can be imported from ooodev.format.writer.direct.char.borders

  • BorderLine2 can be imported from ooodev.format.writer.direct.char.borders

  • BorderLineKind can be imported from ooodev.format.writer.direct.char.borders

  • LineSize can be imported from ooodev.format.writer.direct.char.borders

  • Side can be imported from ooodev.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. Default StandardColor.BLACK

  • width (LineSize, float, UnitT, optional) – Contains the width in of a single line or the width of outer part of a double line (in pt units) or Class UnitT. If this value is zero, no line is drawn. Default LineSize.THIN

Raises:

CancelEventError – If the event before_style_cell_borders is cancelled and not handled.

Returns:

Borders Style instance or None if cancelled.

Return type:

Borders | None

Hint

  • BorderLine2 can be imported from ooo.dyn.table.border_line2

  • BorderLine can be imported from ooo.dyn.table.border_line

  • BorderLineKind can be imported from ooodev.format.inner.direct.structs.side

  • LineSize can be imported from ooodev.format.inner.direct.structs.side

style_font(name=None, size=None, font_style=None, lang=None)

Style Font.

Parameters:
  • name (str | None, optional) – Font Name.

  • size (float | UnitT | None, optional) – Font Size in PT units or UnitT.

  • font_style (str | None, optional) – Font Style such as Bold Italics

  • lang (FontLangT | None, optional) – Font Language.

Raises:

CancelEventError – If the event before_style_font_only is cancelled and not handled.

Returns:

Font Only instance or None if cancelled.

Return type:

FontOnlyT | None

See also

FontLang

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 -1 the automatic color is applied.

  • transparency (Intensity, int, optional) – The transparency value from 0 to 100 for 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_effect is cancelled and not handled.

Returns:

Font Effects instance or None if cancelled.

Return type:

FontEffectsT | None

Hint

  • CaseMapEnum can be imported from ooo.dyn.style.case_map

  • FontReliefEnum can be imported from ooo.dyn.awt.font_relief

  • FontStrikeoutEnum can be imported from ooo.dyn.awt.font_strikeout

  • FontLine can be imported from ooodev.format.inner.direct.write.char.font.font_effects

  • Intensity can be imported from ooodev.utils.data_type.intensity

  • FontUnderlineEnum can be imported from ooo.dyn.awt.font_underline

style_font_effect_get()

Gets the font effect Style.

Raises:

CancelEventError – If the event before_style_font_effect_get is cancelled and not handled.

Returns:

Font Effect style or None if 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 -1 the automatic color is applied.

  • line (FontUnderlineEnum, optional) – Font Line kind.

  • overline (bool, optional) – If True the line is overline, otherwise it is underline.

Raises:

CancelEventError – If the event before_style_font_effect is cancelled and not handled.

Returns:

Font Effects instance or None if cancelled.

Return type:

FontEffectsT | None

Hint

  • FontUnderlineEnum can be imported from ooo.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 weight to bold.

  • i (bool, optional) – Shortcut to set slant to italic.

  • u (bool, optional) – Shortcut ot set underline to 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 -1 will 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_font is cancelled and not handled.

Returns:

Font instance or None if cancelled.

Return type:

FontT | None

Hint

  • FontFamilyEnum can be imported from ooo.dyn.awt.font_family

  • CharSetEnum can be imported from ooo.dyn.awt.char_set

  • ShadowFormat can be imported from ooo.dyn.table.shadow_format

  • FontSlant can be imported from ooo.dyn.awt.font_slant

  • FontStrikeoutEnum can be imported from ooo.dyn.awt.font_strikeout

  • FontWeightEnum can be imported from ooo.dyn.awt.font_weight

  • FontLine can be imported from ooodev.format.inner.direct.write.char.font.font_effects

  • CharSpacingKind can be imported from ooodev.format.inner.direct.write.char.font.font_position

style_font_get()

Gets the font Style.

Raises:

CancelEventError – If the event before_style_font_only_get is cancelled and not handled.

Returns:

Font style or None if cancelled.

Return type:

FontOnlyT | None

style_numbers_boolean()

Style numbers boolean.

Return type:

NumbersT | None

style_numbers_currency()

Style numbers currency.

Return type:

NumbersT | None

style_numbers_date()

Style numbers date.

Return type:

NumbersT | None

style_numbers_datetime()

Style numbers datetime.

Return type:

NumbersT | None

style_numbers_fraction()

Style numbers fraction.

Return type:

NumbersT | None

style_numbers_general()

Style numbers general.

Return type:

NumbersT | None

style_numbers_number()

Style numbers number.

Return type:

NumbersT | 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_index is -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 None which used current Locale.

Raises:

CancelEventError – If the event before_style_number_number is cancelled and not handled.

Returns:

Style Numbers instance or None if cancelled.

Return type:

NumbersT | None

Hint

  • NumberFormatEnum can be imported from ooo.dyn.util.number_format

  • NumberFormatIndexEnum can be imported from ooo.dyn.i18n.number_format_index

  • Locale can be imported from ooo.dyn.lang.locale

style_numbers_numbers_get()

Gets the Numbers Style.

Raises:

CancelEventError – If the event before_style_number_number_get is cancelled and not handled.

Returns:

Numbers style or None if 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_index is cancelled and not handled.

Returns:

Numbers style or None if cancelled.

Return type:

NumbersT | None

Parameters:
  • idx (int) –

  • locale (Locale | None) –

Hint

  • Locale can be imported from ooo.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 to False.

  • locale (Locale | None) –

Raises:

CancelEventError – If the event before_style_number_number_from_index is cancelled and not handled.

Returns:

Numbers style or None if cancelled.

Return type:

NumbersT | None

Hint

  • Locale can be imported from ooo.dyn.lang.locale

style_numbers_percent()

Style numbers percent.

Return type:

NumbersT | None

style_numbers_scientific()

Style numbers scientific.

Return type:

NumbersT | None

style_numbers_time()

Style numbers time.

Return type:

NumbersT | None

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:

EventObserver

property extra_data: TheDict

Extra Data Key Value Pair Dictionary

Return type:

TheDict

property lo_inst: LoInst

Lo Instance

Return type:

LoInst

property office_doc: OfficeDocumentT

Office Document.

Return type:

OfficeDocumentT

property write_doc: WriteDoc

Write Document.

Return type:

WriteDoc

property write_table: WriteTable[Any]

Write Document.

Return type:

WriteTable[Any]