Add impress examples; remove the auto-saving pyautogui commands change to libreoffice pre-setting
This commit is contained in:
@@ -18,7 +18,7 @@ from .libreoffice import check_libre_locale
|
||||
from .pdf import check_pdf_pages
|
||||
from .slides import check_presenter_console_disable, check_image_stretch_and_center, check_slide_numbers_color, \
|
||||
compare_pptx_files, check_strikethrough, \
|
||||
check_slide_orientation_Portrait, evaluate_presentation_fill_to_rgb_distance, check_left_panel
|
||||
check_slide_orientation_Portrait, evaluate_presentation_fill_to_rgb_distance, check_left_panel, check_transition
|
||||
# from .table import check_sheet_list, check_xlsx_freeze, check_xlsx_zoom, check_data_validations
|
||||
from .table import compare_table, compare_csv
|
||||
from .thunderbird import check_thunderbird_prefs, check_thunderbird_filter
|
||||
|
||||
@@ -253,15 +253,15 @@ def evaluate_colored_words_in_tables(file_path1, file_path2):
|
||||
|
||||
|
||||
def check_highlighted_words(file_path1, file_path2):
|
||||
if not compare_docx_files(file_path1, file_path2):
|
||||
return 0
|
||||
# if not compare_docx_files(file_path1, file_path2):
|
||||
# return 0
|
||||
|
||||
# Extract content.xml from the .odt file
|
||||
extract_dir = file_path1 + "_extracted"
|
||||
with zipfile.ZipFile(file_path1, 'r') as zip_ref:
|
||||
zip_ref.extractall(extract_dir)
|
||||
content_xml_path = os.path.join(extract_dir, 'content.xml')
|
||||
with open(content_xml_path, 'r') as file:
|
||||
with open(content_xml_path, 'r', encoding="utf-8") as file:
|
||||
content_xml = file.read()
|
||||
|
||||
# Check for yellow highlights in the content.xml
|
||||
|
||||
@@ -1,5 +1,6 @@
|
||||
import logging
|
||||
import xml.etree.ElementTree as ET
|
||||
import zipfile
|
||||
from math import sqrt
|
||||
|
||||
from pptx import Presentation
|
||||
@@ -189,7 +190,8 @@ def compare_pptx_files(file1_path, file2_path, **options):
|
||||
if run1.font.underline != run2.font.underline and examine_font_underline:
|
||||
return 0
|
||||
|
||||
if ('strike' in run1.font._element.attrib) != ('strike' in run2.font._element.attrib) and examine_strike_through:
|
||||
if ('strike' in run1.font._element.attrib) != (
|
||||
'strike' in run2.font._element.attrib) and examine_strike_through:
|
||||
return 0
|
||||
|
||||
# fixme: Actually there are more properties to be compared, but we cannot get them through pptx
|
||||
@@ -278,3 +280,41 @@ def check_left_panel(accessibility_tree):
|
||||
|
||||
# Left panel is not open
|
||||
return 0.0
|
||||
|
||||
|
||||
def check_transition(pptx_file, rules):
|
||||
slide_idx = rules['slide_idx']
|
||||
transition_type = rules['transition_type']
|
||||
|
||||
# Use the zipfile module to open the .pptx file
|
||||
with zipfile.ZipFile(pptx_file, 'r') as zip_ref:
|
||||
# Get the slide XML file
|
||||
slide_name = 'ppt/slides/slide{}.xml'.format(slide_idx + 1)
|
||||
try:
|
||||
zip_ref.getinfo(slide_name)
|
||||
except KeyError:
|
||||
# Slide does not exist
|
||||
return 0.
|
||||
|
||||
with zip_ref.open(slide_name) as slide_file:
|
||||
# 解析XML
|
||||
tree = ET.parse(slide_file)
|
||||
root = tree.getroot()
|
||||
|
||||
# XML namespace
|
||||
namespaces = {
|
||||
'a': 'http://schemas.openxmlformats.org/drawingml/2006/main',
|
||||
'p': 'http://schemas.openxmlformats.org/presentationml/2006/main',
|
||||
}
|
||||
|
||||
# Search for the transition element
|
||||
transition = root.find('.//p:transition', namespaces)
|
||||
if transition is not None:
|
||||
# Check if the transition is an expected transition
|
||||
dissolve = transition.find('.//p:{}'.format(transition_type), namespaces)
|
||||
if dissolve is not None:
|
||||
return 1.
|
||||
else:
|
||||
return 0.
|
||||
else:
|
||||
return 0.
|
||||
|
||||
Reference in New Issue
Block a user