예제 #1
0
def _get_strong_style(context):
    styles = context['styles']
    strong_style = styles.get('strong')
    if strong_style is not None:
        return strong_style
    strong_style = odf_create_style("text", bold=True)
    context['doc'].insert_style(strong_style, automatic=True)
    styles['strong'] = strong_style
    return strong_style
예제 #2
0
def _get_strong_style(context):
    styles = context['styles']
    strong_style = styles.get('strong')
    if strong_style is not None:
        return strong_style
    strong_style = odf_create_style("text", bold=True)
    context['doc'].insert_style(strong_style, automatic=True)
    styles['strong'] = strong_style
    return strong_style
예제 #3
0
def _get_emphasis_style(context):
    styles = context['styles']
    emphasis_style = styles.get('emphasis')
    if emphasis_style is not None:
        return emphasis_style
    emphasis_style = odf_create_style("text", italic=True)
    context['doc'].insert_style(emphasis_style, automatic=True)
    styles['emphasis'] = emphasis_style
    return emphasis_style
예제 #4
0
def _get_emphasis_style(context):
    styles = context['styles']
    emphasis_style = styles.get('emphasis')
    if emphasis_style is not None:
        return emphasis_style
    emphasis_style = odf_create_style("text", italic=True)
    context['doc'].insert_style(emphasis_style, automatic=True)
    styles['emphasis'] = emphasis_style
    return emphasis_style
예제 #5
0
def _get_cell_style(context):
    styles = context['styles']
    cell_style = styles.get('cell')
    if cell_style is not None:
        return cell_style
    # Give borders to cells
    cell_style = odf_create_style('table-cell', u"odf_table.A1",
            padding=u"0.049cm", border=u"0.002cm solid #000000")
    context['doc'].insert_style(cell_style, automatic=True)
    styles['cell'] = cell_style
    return cell_style
예제 #6
0
def _get_image_style(context):
    styles = context['styles']
    image_style = styles.get('image')
    if image_style is not None:
        return image_style
    image_style = odf_create_style('graphic', parent="Graphics",
            **{'style:horizontal-pos': u"center",
                'style:horizontal-rel': u"paragraph"})
    context['doc'].insert_style(image_style, automatic=True)
    styles['image'] = image_style
    return image_style
예제 #7
0
파일: rst2odt.py 프로젝트: xrmx/lpod-python
def _get_cell_style(context):
    styles = context['styles']
    cell_style = styles.get('cell')
    if cell_style is not None:
        return cell_style
    # Give borders to cells
    cell_style = odf_create_style('table-cell', u"odf_table.A1",
            padding=u"0.049cm", border=u"0.002cm solid #000000")
    context['doc'].insert_style(cell_style, automatic=True)
    styles['cell'] = cell_style
    return cell_style
예제 #8
0
파일: rst2odt.py 프로젝트: xrmx/lpod-python
def _get_image_style(context):
    styles = context['styles']
    image_style = styles.get('image')
    if image_style is not None:
        return image_style
    image_style = odf_create_style('graphic', parent="Graphics",
            **{'style:horizontal-pos': u"center",
                'style:horizontal-rel': u"paragraph"})
    context['doc'].insert_style(image_style, automatic=True)
    styles['image'] = image_style
    return image_style
예제 #9
0
def odf_create_toc_level_style(level):
    """Generate an automatic default style for the given TOC level.
    """
    tab_stop = base_tab_stop.clone()
    position = 17.5 - (0.5 * level)
    tab_stop.set_attribute("style:position", u"%dcm" % position)
    tab_stops = odf_create_element("style:tab-stops")
    tab_stops.append(tab_stop)
    properties = odf_create_element("style:paragraph-properties")
    properties.append(tab_stops)
    element = odf_create_style("paragraph", name=TOC_ENTRY_STYLE_PATTERN % level, parent="Contents_20_%d" % level)
    element.append(properties)
    return element
예제 #10
0
def _get_caption_style(context):
    styles = context['styles']
    caption_style = styles.get('caption')
    if caption_style is not None:
        return caption_style
    caption_style = odf_create_style('graphic', parent=u"Frame",
            **{'style:wrap': u"none", 'style:vertical-pos': u"top",
                'style:vertical-rel': u"paragraph-content",
                'style:horizontal-pos': u"center",
                'style:horizontal-rel': u"paragraph-content",
                'fo:padding': u"0.25cm", 'fo:border': u"0cm solid #000000"})
    context['doc'].insert_style(caption_style, automatic=True)
    styles['caption'] = caption_style
    return caption_style
예제 #11
0
파일: rst2odt.py 프로젝트: xrmx/lpod-python
def _get_caption_style(context):
    styles = context['styles']
    caption_style = styles.get('caption')
    if caption_style is not None:
        return caption_style
    caption_style = odf_create_style('graphic', parent=u"Frame",
            **{'style:wrap': u"none", 'style:vertical-pos': u"top",
                'style:vertical-rel': u"paragraph-content",
                'style:horizontal-pos': u"center",
                'style:horizontal-rel': u"paragraph-content",
                'fo:padding': u"0.25cm", 'fo:border': u"0cm solid #000000"})
    context['doc'].insert_style(caption_style, automatic=True)
    styles['caption'] = caption_style
    return caption_style
예제 #12
0
def odf_create_toc_level_style(level):
    """Generate an automatic default style for the given TOC level.
    """
    tab_stop = base_tab_stop.clone()
    position = 17.5 - (0.5 * level)
    tab_stop.set_attribute('style:position', u'%dcm' % position)
    tab_stops = odf_create_element('<style:tab-stops/>')
    tab_stops.append_element(tab_stop)
    properties = odf_create_element('<style:paragraph-properties/>')
    properties.append_element(tab_stops)
    element = odf_create_style('paragraph',
            name=TOC_ENTRY_STYLE_PATTERN % level,
            parent='Contents_20_%d' % level)
    element.append_element(properties)
    return element
예제 #13
0
파일: toc.py 프로젝트: xrmx/lpod-python
def odf_create_toc_level_style(level):
    """Generate an automatic default style for the given TOC level.
    """
    tab_stop = base_tab_stop.clone()
    position = 17.5 - (0.5 * level)
    tab_stop.set_attribute('style:position', u'%dcm' % position)
    tab_stops = odf_create_element('style:tab-stops')
    tab_stops.append(tab_stop)
    properties = odf_create_element('style:paragraph-properties')
    properties.append(tab_stops)
    element = odf_create_style('paragraph',
                               name=TOC_ENTRY_STYLE_PATTERN % level,
                               parent='Contents_20_%d' % level)
    element.append(properties)
    return element
예제 #14
0
파일: frame.py 프로젝트: Agicia/lpod-python
def odf_create_frame_position_style(name=u"FramePosition",
        horizontal_pos="from-left", vertical_pos="from-top",
        horizontal_rel="paragraph", vertical_rel="paragraph"):
    """Helper style for positioning frames in desktop applications that need
    it.

    Default arguments should be enough.

    Use the return value as the frame style or build a new graphic style with
    this style as the parent.
    """
    return odf_create_style('graphic', u"FramePositioning",
            **{'style:horizontal-pos': "from-left",
                'style:vertical-pos': "from-top",
                'style:horizontal-rel': "paragraph",
                'style:vertical-rel': "paragraph"})
예제 #15
0
def _get_term_style(context):
    styles = context['styles']
    term_style = styles.get('term')
    if term_style is not None:
        return term_style
    # Reuse template style if any
    doc = context['doc']
    term_style = doc.get_style('paragraph',
            u"Definition_20_List_20_Term")
    if term_style is None:
        # Create default one
        term_style = odf_create_style('paragraph',
                name=u"Definition_20_List_20_Term",
                display_name=u"Definition List Term", parent="Standard",
                font_weight=u"bold", area='text')
        doc.insert_style(term_style, automatic=False)
    styles['term'] = term_style
    return term_style
예제 #16
0
파일: rst2odt.py 프로젝트: xrmx/lpod-python
def _get_term_style(context):
    styles = context['styles']
    term_style = styles.get('term')
    if term_style is not None:
        return term_style
    # Reuse template style if any
    doc = context['doc']
    term_style = doc.get_style('paragraph',
            u"Definition_20_List_20_Term")
    if term_style is None:
        # Create default one
        term_style = odf_create_style('paragraph',
                name=u"Definition_20_List_20_Term",
                display_name=u"Definition List Term", parent="Standard",
                font_weight=u"bold", area='text')
        doc.insert_style(term_style, automatic=False)
    styles['term'] = term_style
    return term_style
예제 #17
0
def _get_definition_style(context):
    styles = context['styles']
    definition_style = styles.get('definition')
    if definition_style is not None:
        return definition_style
    # Reuse template style if any
    doc = context['doc']
    definition_style = doc.get_style('paragraph',
            u"Definition_20_List_20_Definition")
    if definition_style is None:
        # Create default one
        definition_style = odf_create_style('paragraph',
                name=u"Definition_20_List_20_Definition",
                display_name=u"Definition List Definition",
                parent="Standard", margin_left=u"0.5cm",
                margin_right=u"0cm", text_indent=u"0cm",
                **{'style:auto-text-indent': u"false"})
        doc.insert_style(definition_style, automatic=False)
    styles['definition'] = definition_style
    return definition_style
예제 #18
0
파일: rst2odt.py 프로젝트: xrmx/lpod-python
def _get_definition_style(context):
    styles = context['styles']
    definition_style = styles.get('definition')
    if definition_style is not None:
        return definition_style
    # Reuse template style if any
    doc = context['doc']
    definition_style = doc.get_style('paragraph',
            u"Definition_20_List_20_Definition")
    if definition_style is None:
        # Create default one
        definition_style = odf_create_style('paragraph',
                name=u"Definition_20_List_20_Definition",
                display_name=u"Definition List Definition",
                parent="Standard", margin_left=u"0.5cm",
                margin_right=u"0cm", text_indent=u"0cm",
                **{'style:auto-text-indent': u"false"})
        doc.insert_style(definition_style, automatic=False)
    styles['definition'] = definition_style
    return definition_style
예제 #19
0
파일: frame.py 프로젝트: Agicia/lpod-python
def odf_create_frame_position_style(name=u"FramePosition",
                                    horizontal_pos="from-left",
                                    vertical_pos="from-top",
                                    horizontal_rel="paragraph",
                                    vertical_rel="paragraph"):
    """Helper style for positioning frames in desktop applications that need
    it.

    Default arguments should be enough.

    Use the return value as the frame style or build a new graphic style with
    this style as the parent.
    """
    return odf_create_style(
        'graphic', u"FramePositioning", **{
            'style:horizontal-pos': "from-left",
            'style:vertical-pos': "from-top",
            'style:horizontal-rel': "paragraph",
            'style:vertical-rel': "paragraph"
        })