Esempio n. 1
0
def when_I_call_shapes_add_movie(context):
    shapes = context.shapes
    x, y, cx, cy = Emu(2590800), Emu(571500), Emu(3962400), Emu(5715000)
    context.movie = shapes.add_movie(
        test_file('just-two-mice.mp4'), x, y, cx, cy,
        test_file('just-two-mice.png')
    )
Esempio n. 2
0
def given_a_PROG_ID_member_file_as_ole_object_file(context, PROG_ID_member):
    filename = {
        "DOCX": "shp-embedded-docx.docx",
        "PPTX": "shp-embedded-pptx.pptx",
        "XLSX": "shp-embedded-xlsx.xlsx",
    }[PROG_ID_member]
    with open(test_file(filename), "rb") as f:
        context.ole_object_file = io.BytesIO(f.read())
    context.PROG_ID_member = PROG_ID_member
Esempio n. 3
0
def given_a_shape_having_click_action_action(context, action):
    shape_idx = (
        "none",
        "first slide",
        "last slide",
        "previous slide",
        "next slide",
        "last slide viewed",
        "named slide",
        "end show",
        "hyperlink",
        "other presentation",
        "open file",
        "custom slide show",
        "OLE action",
        "run macro",
        "run program",
        "play media",
    ).index(action)
    slides = Presentation(test_file("act-props.pptm")).slides
    context.slides = slides
    context.click_action = slides[2].shapes[shape_idx].click_action
Esempio n. 4
0
def given_image_filename(context, filename):
    context.image_path = test_file(filename)
Esempio n. 5
0
def when_I_open_a_presentation_extracted_into_a_directory(context):
    context.prs = Presentation(test_file("extracted-pptx"))
Esempio n. 6
0
def when_I_call_TextFrame_fit_text(context):
    from helpers import test_file

    font_file = test_file("calibriz.ttf")
    context.text_frame.fit_text(bold=True, italic=True, font_file=font_file)
Esempio n. 7
0
def when_add_inline_picture_to_document(context):
    document = context.document
    run = document.add_paragraph().add_run()
    context.inline_shape = (document.inline_shapes.add_picture(
        test_file('monty-truth.png'), run))
Esempio n. 8
0
def when_I_call_TextFrame_fit_text(context):
    from helpers import test_file
    font_file = test_file('calibriz.ttf')
    context.text_frame.fit_text(bold=True, italic=True, font_file=font_file)
Esempio n. 9
0
def when_add_picture_specifying_width(context):
    document = context.document
    context.picture = document.add_picture(test_file('monty-truth.png'),
                                           width=Inches(1.5))
Esempio n. 10
0
def then_movie_poster_frame_is_the_same_image_as_poster_frame(context):
    actual_sha1 = context.movie.poster_frame.sha1
    with open(test_file('just-two-mice.png'), 'rb') as f:
        expected_sha1 = hashlib.sha1(f.read()).hexdigest()
    assert actual_sha1 == expected_sha1, 'not the same image'
Esempio n. 11
0
def then_movie_poster_frame_is_the_same_image_as_poster_frame(context):
    actual_sha1 = context.movie.poster_frame.sha1
    with open(test_file("just-two-mice.png"), "rb") as f:
        expected_sha1 = hashlib.sha1(f.read()).hexdigest()
    assert actual_sha1 == expected_sha1, "not the same image"
Esempio n. 12
0
def when_I_add_a_picture_to_the_run(context):
    run = context.run
    run.add_picture(test_file('monty-truth.png'))
Esempio n. 13
0
def when_I_call_run_add_picture(context):
    context.run.add_picture(test_file("test.png"))
Esempio n. 14
0
def given_an_ActionSetting_object_as_click_action(context, action):
    shape_idx = {"NONE": 0, "NAMED_SLIDE": 6}[action]
    slides = Presentation(test_file("act-props.pptm")).slides
    context.slides = slides
    context.click_action = slides[2].shapes[shape_idx].click_action
Esempio n. 15
0
def when_add_inline_picture_from_file_like_object(context):
    document = context.document
    run = document.add_paragraph().add_run()
    with open(test_file('monty-truth.png'), 'rb') as f:
        context.inline_shape = document.inline_shapes.add_picture(f, run)
Esempio n. 16
0
def when_I_call_shapes_add_movie(context):
    shapes = context.shapes
    x, y, cx, cy = Emu(2590800), Emu(571500), Emu(3962400), Emu(5715000)
    context.movie = shapes.add_movie(
        test_file("just-two-mice.mp4"), x, y, cx, cy, test_file("just-two-mice.png")
    )
Esempio n. 17
0
def when_add_inline_picture_to_document(context):
    document = context.document
    run = document.add_paragraph().add_run()
    context.inline_shape = (document.inline_shapes.add_picture(
        test_file('monty-truth.png'), run
    ))
Esempio n. 18
0
def when_add_picture_specifying_only_image_file(context):
    document = context.document
    context.picture = document.add_picture(test_file('monty-truth.png'))
Esempio n. 19
0
def when_add_picture_specifying_width(context):
    document = context.document
    context.picture = document.add_picture(
        test_file('monty-truth.png'), width=Inches(1.5)
    )
Esempio n. 20
0
def when_add_inline_picture_from_file_like_object(context):
    document = context.document
    run = document.add_paragraph().add_run()
    with open(test_file('monty-truth.png'), 'rb') as f:
        context.inline_shape = document.inline_shapes.add_picture(f, run)
Esempio n. 21
0
def when_add_picture_specifying_only_image_file(context):
    document = context.document
    context.picture = document.add_picture(test_file('monty-truth.png'))
Esempio n. 22
0
def when_I_call_run_add_picture(context):
    context.run.add_picture(test_file("test.png"))
Esempio n. 23
0
def when_add_picture_specifying_height(context):
    document = context.document
    context.picture = document.add_picture(test_file("monty-truth.png"),
                                           height=Inches(1.5))
Esempio n. 24
0
def when_I_call_placeholder_insert_picture(context, filename):
    placeholder = context.shape
    path = test_file(filename)
    with open(path, 'rb') as f:
        context.image_sha1 = hashlib.sha1(f.read()).hexdigest()
    context.placeholder = placeholder.insert_picture(path)
Esempio n. 25
0
def when_I_add_a_picture_to_the_run(context):
    run = context.run
    run.add_picture(test_file('monty-truth.png'))
Esempio n. 26
0
def when_I_call_placeholder_insert_picture(context, filename):
    placeholder = context.shape
    path = test_file(filename)
    with open(path, "rb") as f:
        context.image_sha1 = hashlib.sha1(f.read()).hexdigest()
    context.placeholder = placeholder.insert_picture(path)
Esempio n. 27
0
def given_image_filename(context, filename):
    context.image_path = test_file(filename)