- Add\Rework UI - Add Split Table and Listing - Add Support Customazeble schems
This commit is contained in:
+40
-8
@@ -173,13 +173,11 @@ def apply_document_styles(document: Document, style_preset: str = "mirea") -> No
|
||||
|
||||
|
||||
def _apply_common_page_and_body(document: Document) -> None:
|
||||
from .page_geometry import apply_section_geometry, is_landscape_section
|
||||
|
||||
for section in document.sections:
|
||||
section.page_width = Mm(210)
|
||||
section.page_height = Mm(297)
|
||||
section.left_margin = Mm(30)
|
||||
section.right_margin = Mm(10)
|
||||
section.top_margin = Mm(20)
|
||||
section.bottom_margin = Mm(20)
|
||||
# Do not wipe landscape sections created for +landscape figures/tables.
|
||||
apply_section_geometry(section, landscape=is_landscape_section(section))
|
||||
|
||||
_fix_toc_tab_stops(document)
|
||||
|
||||
@@ -209,7 +207,7 @@ def _apply_common_captions_and_misc(document: Document) -> None:
|
||||
cpf.line_spacing_rule = WD_LINE_SPACING.SINGLE
|
||||
cpf.widow_control = True
|
||||
|
||||
# --- Caption Table: 12pt italic, left, above table ---
|
||||
# --- Caption Table (legacy EN name) + «Название таблицы» (основной) ---
|
||||
caption_tbl = _ensure_style(document, "Caption Table", "Caption")
|
||||
_set_run_font(caption_tbl, "Times New Roman", 12, italic=True)
|
||||
tpf = caption_tbl.paragraph_format
|
||||
@@ -219,8 +217,22 @@ def _apply_common_captions_and_misc(document: Document) -> None:
|
||||
tpf.space_before = Mm(6)
|
||||
tpf.space_after = Mm(0)
|
||||
tpf.line_spacing_rule = WD_LINE_SPACING.SINGLE
|
||||
tpf.keep_with_next = True
|
||||
tpf.widow_control = True
|
||||
|
||||
# ГОСТ-имя стиля подписи таблицы (те же параметры, что Caption Table)
|
||||
caption_tbl_ru = _ensure_style(document, "Название таблицы", "Caption Table")
|
||||
_set_run_font(caption_tbl_ru, "Times New Roman", 12, italic=True)
|
||||
tpf_ru = caption_tbl_ru.paragraph_format
|
||||
tpf_ru.alignment = WD_ALIGN_PARAGRAPH.LEFT
|
||||
tpf_ru.first_line_indent = Cm(0)
|
||||
tpf_ru.left_indent = Cm(0)
|
||||
tpf_ru.space_before = Mm(6)
|
||||
tpf_ru.space_after = Mm(0)
|
||||
tpf_ru.line_spacing_rule = WD_LINE_SPACING.SINGLE
|
||||
tpf_ru.keep_with_next = True
|
||||
tpf_ru.widow_control = True
|
||||
|
||||
# --- Caption Listing (как таблицы) ---
|
||||
caption_lst = _ensure_style(document, "Caption Listing", "Caption")
|
||||
_set_run_font(caption_lst, "Times New Roman", 12, italic=True)
|
||||
@@ -256,7 +268,9 @@ def _apply_common_captions_and_misc(document: Document) -> None:
|
||||
table_text = _ensure_style(document, "Table Text", "Normal")
|
||||
_set_run_font(table_text, "Times New Roman", 12)
|
||||
ttf = table_text.paragraph_format
|
||||
ttf.alignment = WD_ALIGN_PARAGRAPH.LEFT
|
||||
ttf.first_line_indent = Cm(0)
|
||||
ttf.left_indent = Cm(0)
|
||||
ttf.space_before = Mm(0)
|
||||
ttf.space_after = Mm(0)
|
||||
ttf.line_spacing_rule = WD_LINE_SPACING.SINGLE
|
||||
@@ -276,12 +290,28 @@ def _apply_common_captions_and_misc(document: Document) -> None:
|
||||
bhpf = biblio_h.paragraph_format
|
||||
bhpf.alignment = WD_ALIGN_PARAGRAPH.CENTER
|
||||
bhpf.first_line_indent = Cm(0)
|
||||
bhpf.left_indent = Cm(0)
|
||||
bhpf.left_indent = Cm(1.25) # табл. 5.1
|
||||
bhpf.space_before = Mm(6)
|
||||
bhpf.space_after = Mm(6)
|
||||
bhpf.line_spacing_rule = WD_LINE_SPACING.ONE_POINT_FIVE
|
||||
bhpf.keep_with_next = True
|
||||
|
||||
# TOC styles: TNR 14, 1.5, no bold, no first-line indent; toc 1 = ALL CAPS
|
||||
for toc_name, all_caps in (("toc 1", True), ("toc 2", False), ("toc 3", False)):
|
||||
try:
|
||||
toc_style = document.styles[toc_name]
|
||||
except KeyError:
|
||||
toc_style = _ensure_style(document, toc_name, "Normal")
|
||||
_set_run_font(toc_style, "Times New Roman", 14, bold=False)
|
||||
toc_style.font.all_caps = all_caps
|
||||
toc_style.font.bold = False
|
||||
tpf_toc = toc_style.paragraph_format
|
||||
tpf_toc.alignment = WD_ALIGN_PARAGRAPH.LEFT
|
||||
tpf_toc.first_line_indent = Cm(0)
|
||||
tpf_toc.space_before = Pt(0)
|
||||
tpf_toc.space_after = Pt(0)
|
||||
tpf_toc.line_spacing_rule = WD_LINE_SPACING.ONE_POINT_FIVE
|
||||
|
||||
try:
|
||||
footer_style = document.styles["Footer"]
|
||||
_set_run_font(footer_style, "Times New Roman", 12)
|
||||
@@ -301,4 +331,6 @@ def _apply_common_captions_and_misc(document: Document) -> None:
|
||||
after = _ensure_style(document, "Space After Table", "Normal")
|
||||
apf = after.paragraph_format
|
||||
apf.space_before = Mm(6)
|
||||
apf.space_after = Pt(0)
|
||||
apf.first_line_indent = Cm(1.25)
|
||||
apf.line_spacing_rule = WD_LINE_SPACING.ONE_POINT_FIVE
|
||||
|
||||
Reference in New Issue
Block a user