def test_updates_docproperties_shared_header_footer(self): document = Document(docx_path('docproperties_shared_header_footer_2_sections.docx')) # the same header should be referenced by both sections # the sections should be considered as linked header_1 = document.sections[0].header header_2 = document.sections[1].header assert not header_1.is_linked_to_previous assert header_2.is_linked_to_previous assert_complex_field_value( u'blub', header_1.part.element, u'shared.header') assert_complex_field_value( u'blub', header_2.part.element, u'shared.header') # the same footer should be referenced by both sections # the sections should be considered as linked footer_1 = document.sections[0].footer footer_2 = document.sections[1].footer assert not footer_1.is_linked_to_previous assert footer_2.is_linked_to_previous assert_complex_field_value( u'N', footer_1.part.element, u'shared.footer') assert_complex_field_value( u'N', footer_2.part.element, u'shared.footer') CustomProperties(document).update_all() # the same header should be referenced by both sections assert_complex_field_value( u'ig bi obe', header_1.part.element, u'shared.header') assert_complex_field_value( u'ig bi obe', header_2.part.element, u'shared.header') # the same footer should be referenced by both sections footer_1 = document.sections[0].footer footer_2 = document.sections[1].footer assert_complex_field_value( u'Y', footer_1.part.element, u'shared.footer') assert_complex_field_value( u'Y', footer_2.part.element, u'shared.footer')
def test_updates_docproperties_shared_header(self): document = Document(docx_path('docproperties_shared_header_2_sections.docx')) # the same header should be referenced by both sections # the sections should be considered as linked header_1 = document.sections[0].header header_2 = document.sections[1].header assert not header_1.is_linked_to_previous assert header_2.is_linked_to_previous assert_complex_field_value( u'xxx', header_1.part.element, u'shared.header') assert_complex_field_value( u'xxx', header_2.part.element, u'shared.header') footer_1 = document.sections[0].footer footer_2 = document.sections[1].footer assert not footer_1.is_linked_to_previous assert not footer_2.is_linked_to_previous assert_complex_field_value( u'123', footer_1.part.element, u'section1.footer') assert_complex_field_value( u'yyy', footer_2.part.element, u'section2.footer') CustomProperties(document).update_all() # the same header should be referenced by both sections assert_complex_field_value( u'sh\xe4red', header_1.part.element, u'shared.header') assert_complex_field_value( u'sh\xe4red', header_2.part.element, u'shared.header') footer_1 = document.sections[0].footer footer_2 = document.sections[1].footer assert_complex_field_value( u'-1.0', footer_1.part.element, u'section1.footer') assert_complex_field_value( u'f\xfc\xfcter', footer_2.part.element, u'section2.footer')