update pptc as libreoffice impress

This commit is contained in:
tsuky_chen
2024-02-15 01:49:04 +08:00
parent 2f87aae0cb
commit f7bb33724c
8 changed files with 496 additions and 11 deletions

View File

@@ -146,6 +146,8 @@ def compare_pptx_files(file1_path, file2_path, **options):
examine_color_rgb = options.get("examine_color_rgb", True)
examine_font_underline = options.get("examine_font_underline", True)
examine_strike_through = options.get("examine_strike_through", True)
examine_alignment = options.get("examine_alignment", True)
examine_bottom_position = options.get("examine_bottom_position", False)
# compare the number of slides
if len(prs1.slides) != len(prs2.slides) and examine_number_of_slides:
@@ -153,19 +155,24 @@ def compare_pptx_files(file1_path, file2_path, **options):
# compare the content of each slide
for slide1, slide2 in zip(prs1.slides, prs2.slides):
# check if the shapes are the same
for shape1, shape2 in zip(slide1.shapes, slide2.shapes):
if (
shape1.left != shape2.left or shape1.top != shape2.top or shape1.width != shape2.width or shape1.height != shape2.height) and examine_shape:
if examine_bottom_position and shape1.top != shape2.top:
if hasattr(shape1, "text") and hasattr(shape2, "text") and shape1.text == shape2.text and shape1.text == "Product Comparison":
if shape1.top >= shape2.top:
return 0
if (shape1.left != shape2.left or shape1.top != shape2.top or shape1.width != shape2.width or shape1.height != shape2.height) and examine_shape:
return 0
if hasattr(shape1, "text") and hasattr(shape2, "text"):
if shape1.text != shape2.text and examine_text:
return 0
return 0
# check if the paragraphs are the same
for para1, para2 in zip(shape1.text_frame.paragraphs, shape2.text_frame.paragraphs):
if para1.alignment != para2.alignment and examine_alignment:
return 0
# check if the runs are the same
for run1, run2 in zip(para1.runs, para2.runs):
@@ -182,8 +189,9 @@ def compare_pptx_files(file1_path, file2_path, **options):
if run1.font.italic != run2.font.italic and examine_font_italic:
return 0
if run1.font.color.rgb != run2.font.color.rgb and examine_color_rgb:
return 0
if hasattr(run1.font.color, "rgb") and hasattr(run2.font.color, "rgb"):
if run1.font.color.rgb != run2.font.color.rgb and examine_color_rgb:
return 0
if run1.font.underline != run2.font.underline and examine_font_underline:
return 0