Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
def numberings_with_zero_reference():
composer = Composer(Document(
docx_path("numbering_reference_to_numbering_zero.docx")))
composer.append(Document(
docx_path("numbering_reference_to_numbering_zero.docx")))
return composer
def header_footer():
composer = Composer(Document(docx_path("master.docx")))
composer.append(Document(docx_path("header_footer_sections.docx")))
return composer
def multiple_numberings():
composer = Composer(Document(docx_path("numberings_styles.docx")))
composer.append(Document(docx_path("numberings_styles.docx")))
return composer
def mixed_numberings():
composer = Composer(Document(docx_path("numberings_restart.docx")))
composer.append(Document(docx_path("numberings_restart.docx")))
return composer
def numberings_in_styles():
composer = Composer(Document(docx_path("master.docx")))
composer.append(Document(docx_path("numberings_styles.docx")))
return composer
def numbering_with_paragraphs():
composer = Composer(Document(docx_path("master.docx")))
composer.append(Document(docx_path("numbering_with_paragraphs_in_between.docx")))
return composer
def __init__(self, master_filename, filename, *filenames):
composer = Composer(Document(docx_path(master_filename)))
for filename in (filename,) + filenames:
composer.append(Document(docx_path(filename)))
super(ComposedDocument, self).__init__(composer.doc)
def merged_styles():
composer = Composer(Document(docx_path("styles_en.docx")))
composer.append(Document(docx_path("styles_de.docx")))
return composer
def fix_subdoc(masterdoc, subdoc):
"""Fix the images, styles, references, shapes, etc of a subdoc"""
composer = Composer(masterdoc) # Using docxcompose
composer.reset_reference_mapping()
# This is the same as the docxcompose function, except it doesn't copy the elements over.
# Copying the elements over is done by returning the subdoc XML in this function.
# Both sd.subdocx and the master template file are changed with these functions.
composer._create_style_id_mapping(subdoc)
for element in subdoc.element.body:
if isinstance(element, CT_SectPr):
continue
composer.add_referenced_parts(subdoc.part, masterdoc.part, element)
composer.add_styles(subdoc, element)
composer.add_numberings(subdoc, element)
composer.restart_first_numbering(subdoc, element)
composer.add_images(subdoc, element)
composer.add_shapes(subdoc, element)
composer.add_footnotes(subdoc, element)