fix(translators): ameliorer le respect des formats de fichiers pour Excel, PowerPoint et PDF
All checks were successful
Deploy to Production / Build and Deploy (push) Successful in 2m33s

- Excel: elargissement intelligent des colonnes pour le texte etendu et alignement RTL des cellules

- PowerPoint: retour a la ligne et auto-fit anti-debordement, colonnes de tableaux en RTL

- PDF: protection multi-colonnes pour eviter les chevauchements et formatage hebreu

- Tests: validation de non-regression pour tous les formats
This commit is contained in:
2026-09-02 21:35:31 +02:00
parent cae09fc512
commit 6f5b6acbdc
6 changed files with 257 additions and 16 deletions

View File

@@ -151,6 +151,14 @@ def _apply_ltr_to_shape(shape) -> None:
_unset_pptx_paragraph_rtl(paragraph)
if shape.shape_type == MSO_SHAPE_TYPE.TABLE:
try:
tbl_el = shape._element.find(f".//{{{_NS_A}}}tbl")
if tbl_el is not None:
tblPr = tbl_el.find(f"{{{_NS_A}}}tblPr")
if tblPr is not None and "rtl" in tblPr.attrib:
del tblPr.attrib["rtl"]
except Exception:
pass
for row in shape.table.rows:
for cell in row.cells:
for paragraph in cell.text_frame.paragraphs:
@@ -168,6 +176,14 @@ def _apply_rtl_to_shape(shape) -> None:
_set_pptx_paragraph_rtl(paragraph)
if shape.shape_type == MSO_SHAPE_TYPE.TABLE:
try:
tbl_el = shape._element.find(f".//{{{_NS_A}}}tbl")
if tbl_el is not None:
tblPr = tbl_el.find(f"{{{_NS_A}}}tblPr")
if tblPr is not None:
tblPr.set("rtl", "1")
except Exception:
pass
for row in shape.table.rows:
for cell in row.cells:
for paragraph in cell.text_frame.paragraphs:
@@ -978,6 +994,19 @@ class PowerPointTranslator:
if not text_frame.text.strip():
return
# Ensure word wrap is enabled so expanding translated text wraps naturally
# inside the shape rather than stretching past the slide edge.
# If no autofit is explicitly configured, enable text-to-fit-shape
# so PowerPoint can scale font size down if the translated text is too long.
try:
if not getattr(text_frame, "word_wrap", None):
text_frame.word_wrap = True
from pptx.enum.text import MSO_AUTO_SIZE
if getattr(text_frame, "auto_size", None) is None:
text_frame.auto_size = MSO_AUTO_SIZE.TEXT_TO_FIT_SHAPE
except Exception:
pass
tag_r = f"{{{_NS_A}}}r"
tag_t = f"{{{_NS_A}}}t"