lpod.style

class lpod.style.odf_background_image(native_element, cache=None)

Bases: lpod.image.odf_image

get_filter()
get_opacity()
get_position()
get_repeat()
set_filter(filter)
set_opacity(opacity)
set_position(position)
set_repeat(repeat)
class lpod.style.odf_currency_style(native_element, cache=None)

Bases: lpod.style.odf_style

get_family()
class lpod.style.odf_date_style(native_element, cache=None)

Bases: lpod.style.odf_style

get_family()
class lpod.style.odf_fill_image(native_element, cache=None)

Bases: lpod.style.odf_style, lpod.image.odf_image

get_family()
class lpod.style.odf_font_style(native_element, cache=None)

Bases: lpod.style.odf_style

get_family()
set_font(name, family=None, family_generic=None, pitch=u'variable')
class lpod.style.odf_list_level_style_number(native_element, cache=None)

Bases: lpod.style.odf_style

get_text_style()
set_text_style(style)
class lpod.style.odf_list_style(native_element, cache=None)

Bases: lpod.style.odf_style

A list style is a container for list level styles.

get_family()
get_level_style(level)
set_level_style(level, num_format=None, bullet_char=None, url=None, display_levels=None, prefix=None, suffix=None, start_value=None, style=None, clone=None)

Arguments:

level – int

num_format (for number) – int

bullet_char (for bullet) – unicode

url (for image) – str

display_levels – int

prefix – unicode

suffix – unicode

start_value – int

style – unicode

clone – odf_list_style

Return:
level_style created
any_style = '(text:list-level-style-number|text:list-level-style-bullet|text:list-level-style-image)'
class lpod.style.odf_marker(native_element, cache=None)

Bases: lpod.style.odf_style

get_family()
class lpod.style.odf_master_page(native_element, cache=None)

Bases: lpod.style.odf_style

A master page is the style of a page.

Physical presentation is in the associated page layout.

XXX to verify

get_family()

Get the element that contains the footer contents.

If None, no footer was set.

get_header()

Get the element that contains the header contents.

If None, no header was set.

get_next_style()
get_page_layout()
set_family()

Create or replace the footer by the given content. It can already be a complete footer.

If you only want to update the existing footer, get it and use the API.

Arguments:

text_or_element – unicode or odf_element or a list of them
set_header(text_or_element)

Create or replace the header by the given content. It can already be a complete header.

If you only want to update the existing header, get it and use the API.

Arguments:

text_or_element – unicode or odf_element or a list of them
set_next_style(name)
set_page_layout(name)
class lpod.style.odf_number_style(native_element, cache=None)

Bases: lpod.style.odf_style

get_family()
class lpod.style.odf_outline_style(native_element, cache=None)

Bases: lpod.style.odf_list_style

get_family()
class lpod.style.odf_page_layout(native_element, cache=None)

Bases: lpod.style.odf_style

Physical presentation of a page.

XXX to verify

get_family()
get_header_style()
set_family()
set_header_style(new_style)
class lpod.style.odf_percentage_style(native_element, cache=None)

Bases: lpod.style.odf_style

get_family()
class lpod.style.odf_presentation_page_layout(native_element, cache=None)

Bases: lpod.style.odf_style

get_family()
class lpod.style.odf_style(native_element, cache=None)

Bases: lpod.element.odf_element

Specialised element for styles, yet generic to all style types.

del_properties(properties=[], area=None, *args)

Delete the given properties, either by list argument or positional argument (or both). Remove only from the given area, identical to the style family by default.

Arguments:

properties – list

area – str

get_display_name()
get_family()
get_master_page()
get_name()
get_parent_style()

Will only return a name, not an object, because we don’t have access to the XML part from here.

See odf_styles.get_parent_style

get_properties(area=None)

Get the mapping of all properties of this style. By default the properties of the same family, e.g. a paragraph style and its paragraph properties. Specify the area to get the text properties of a paragraph style for example.

Arguments:

area – str

Return: dict

set_background(color=None, url=None, position='center', repeat=None, opacity=None, filter=None)

Set the background color of a text style, or the background color or image of a paragraph style or page layout.

With no argument, remove any existing background.

The position is one or two of ‘center’, ‘left’, ‘right’, ‘top’ or ‘bottom’.

The repeat is ‘no-repeat’, ‘repeat’ or ‘stretch’.

The opacity is a percentage integer (not a string with the ‘%s’ sign)

The filter is an application-specific filter name defined elsewhere.

Though this method is defined on the base style class, it will raise an error if the style type is not compatible.

Arguments:

color – ‘#rrggbb’

url – str

position – str

repeat – str

opacity – int

filter – str

set_display_name(name)
set_family(family)
set_master_page(name)
set_name(name)
set_parent_style(name)
set_properties(properties={}, style=None, area=None, **kw)

Set the properties of the “area” type of this style. Properties are given either as a dict or as named arguments (or both). The area is identical to the style family by default. If the properties element is missing, it is created.

Instead of properties, you can pass a style with properties of the same area. These will be copied.

Arguments:

properties – dict

style – odf_style

area – ‘paragraph’, ‘text’...

class lpod.style.odf_time_style(native_element, cache=None)

Bases: lpod.style.odf_style

get_family()
lpod.style.hex2rgb(color)

Turns a “#RRGGBB” hexadecimal color representation into a (R, G, B) tuple. Arguments:

color: str

Return: tuple

lpod.style.make_table_cell_border_string(thick=None, line=None, color=None)

Returns a string for style:table-cell-properties fo:border, with default : “0.06pt solid #000000”

thick – str or float line – str color – str or rgb 3-tuple, str is ‘black’, ‘grey’, ... or ‘#012345’

Returns : str

lpod.style.odf_create_default_boolean_style()
lpod.style.odf_create_default_currency_style()
lpod.style.odf_create_default_date_style()
lpod.style.odf_create_default_number_style()
lpod.style.odf_create_default_percentage_style()
lpod.style.odf_create_default_time_style()
lpod.style.odf_create_style(family, name=None, display_name=None, parent=None, area=None, color=None, background_color=None, italic=False, bold=False, master_page=None, page_layout=None, next_style=None, data_style=None, border=None, border_top=None, border_right=None, border_bottom=None, border_left=None, shadow=None, height=None, use_optimal_height=None, width=None, break_before=None, break_after=None, min_height=None, font_name=None, font_family=None, font_family_generic=None, font_pitch=u'variable', **kw)

Create a style of the given family. The name is not mandatory at this point but will become required when inserting in a document as a common style.

The display name is the name the user sees in an office application.

The parent is the name of the style this style will inherit from.

To set properties, pass them as keyword arguments. The area properties apply to is optional and defaults to the family.

Arguments:

family – ‘paragraph’, ‘text’, ‘section’, ‘table’, ‘table-column’,
‘table-row’, ‘table-cell’, ‘table-page’, ‘chart’, ‘drawing-page’, ‘graphic’, ‘presentation’, ‘control’, ‘ruby’, ‘list’, ‘number’, ‘page-layout’ ‘font-face’, or ‘master-page’

name – unicode

display_name – unicode

parent – unicode

area – str

‘text’ Properties:

italic – bool

bold – bool

‘paragraph’ Properties:

master_page – unicode

‘master-page’ Properties:

page_layout – unicode

next_style – unicode

‘table-cell’ Properties:

border, border_top, border_right, border_bottom, border_left – str, e.g. “0.002cm solid #000000” or ‘none’

shadow – str, e.g. “#808080 0.176cm 0.176cm”

‘table-row’ Properties:

height – str, e.g. ‘5cm’

use_optimal_height – bool

‘table-column’ Properties:

width – str, e.g. ‘5cm’

break_before – ‘page’, ‘column’ or ‘auto’

break_after – ‘page’, ‘column’ or ‘auto’

Return: odf_style

lpod.style.odf_create_table_cell_style(border=None, border_top=None, border_bottom=None, border_left=None, border_right=None, background_color=None, shadow=None, color=None)
lpod.style.register_style(tagname, cls)
lpod.style.rgb2hex(color)

Turns a color name or a (R, G, B) color tuple into a “#RRGGBB” hexadecimal representation. Arguments:

color – str or tuple

Return: str

Examples:

>>> rgb2hex('yellow')
'#FFFF00'
>>> rgb2hex((238, 130, 238))
'#EE82EE'

Previous topic

lpod.span

Next topic

lpod.styles

This Page