예제 #1
0
def invoke(cell_object, section):
    if section.type != 'image':
        err_msg = f'Called image but not image -  [{section}]'
        return utils.insert_error(cell_object, err_msg)

    has_run(cell_object)

    ImageElement(cell_object, section).insert()
예제 #2
0
def invoke(cell_object, section):
    if section.type != 'image':
        section.contents = f'Called image but not image -  [{section}]'
        return error.invoke(cell_object, section)

    has_run(cell_object)

    ImageElement(cell_object, section).insert()
예제 #3
0
def invoke(cell_object, section, apply_styling=True) -> None:
    if section.type not in ['header', 'paragraph', 'span', 'text', 'p']:
        err_msg = f'Called text but not text -  [{section}]'
        return utils.insert_error(cell_object, err_msg)

    # Used when called directly from a text element (in the json)
    # So we have to apply the style manually.
    if apply_styling:
        has_run(cell_object)
        apply_style(cell_object, section)

    TextElement(cell_object, section).insert()
예제 #4
0
def insert_elem(cell_object: Union[CellObject, _Cell], section: Section,
                add_run=False):
    """ Insert text into a specified cell, can add a style and a run element
        too.
     """

    # Get the relevant cell object
    if isinstance(cell_object, _Cell):
        cell_object = CellObject(cell_object, add_run=add_run)
    elif add_run:
        cell_object = cell_object
        cell_object.add_run()

    if not add_run:
        has_run(cell_object)

    # Apply the relevant style
    apply_style(cell_object, section)

    text.invoke(cell_object, section, apply_styling=False)
예제 #5
0
    def insert(self):
        if DEBUG:
            print('Adding text...')

        has_run(self.cell_object)
        self.cell_object.run.text = self.section.contents