from docx import Document
from docx.enum.text import WD_ALIGN_PARAGRAPH
from docx.shared import Pt
from docx.shared import Length
from docx.shared import RGBColor
from docx.enum.style import WD_STYLE
#from docx.shared import Inches

document = Document()

#document = Document("verif_plan_template.docx")
#header = section.header

#header = document.sections[0].header
#header.text = 'foobar'

#docbody = document.xpath('/w:document/w:body',namespaces=wordnamespaces)[0]
#docbody.append(heading('Your header text',1)  )

#document.sections[0].headers[0].add_paragraph(text='moar header')


document.add_paragraph('This is a new paragraph.')
document.paragraphs[0].add_run(' This is the next sentence.')

document.paragraphs[0].add_run(' This is a bold sentence.')
document.paragraphs[0].runs[2].bold = True
document.paragraphs[0].add_run('This is in italics.')
document.paragraphs[0].runs[3].italic = True
document.paragraphs[0].add_run('This is underlined.')
document.paragraphs[0].runs[4].underline = True

#filepath = 'C:\\Users\\Desktop\\'
# 
#for x in range(1,13):
#    document.add_picture(filepath + str(x) + '.tif', width=Inches(8.0))


document.add_heading("NCVxxxxx Digital Verification Test Plan", 0)

# define style
#styles = document.styles
#style = styles[WD_STYLE.BODY_TEXT]

p = document.add_paragraph("flmgglglgfggkgklgklmgkldklbklkssksdfmldfkdfdkgdldlfgdlfdlffgfdlmlgdfg")
# insére un espace entre le heading et le paragraphe
p.paragraph_format.space_before = Pt(20)
p.add_run('bold').bold = True
p.add_run(' and some ')
p.add_run('italic.').italic = True
p.add_run(" and some fdf lkjdfksqjfk lsgjsdkgskg fgqgkjqglkqsj  fglkjglkqjgjfg lkjgkqlgjqgj  ")
p.alignment = WD_ALIGN_PARAGRAPH.JUSTIFY


p = document.add_paragraph('Suite du programme A plain paragraph having some ')
p.add_run('bold').bold = True
p.add_run(' and some ')
p.add_run('italic.').italic = True
p.add_run(" and some fdf lkjdfksqjfk lsgjsdkgskg fgqgkjqglkqsj  fglkjglkqjgjfg lkjgkqlgjqgj  ")
p.alignment = WD_ALIGN_PARAGRAPH.JUSTIFY

p.paragraph_format.space_before = Pt(38)




p = document.add_heading("2: I2C Regs", level=1)

p = document.add_heading("2.1 I2C defaults", level=2)


#p = document.add_paragraph(style = 'List', text = "2.1 I2C defaults")


p = document.add_paragraph()
obj = p.add_run("DESCRIPTION:")
obj.bold = True
p = document.add_paragraph("Verify defaults of I2C registers are in line with specified ones.")


p = document.add_paragraph()
obj = p.add_run("Test sequence:")
obj.underline = True

p = document.add_paragraph(style = 'List Continue', text = "1. Perform reset")
p = document.add_paragraph(style = 'List Continue', text = "2. Force OTP config not fused")
p = document.add_paragraph(style = 'List Continue', text = "3. Start chip (POR release) and make EN pin high")
p = document.add_paragraph(style = 'List Continue', text = "4. Enter in test mode")
p = document.add_paragraph(style = 'List Continue', text = "5. Read all I2C registers and check the read value is equal to PTS expected value")

p = document.add_paragraph("")
p.add_run("TESTCASE: ").bold = True
p.add_run("default.v")

#
#p0 = d.add_paragraph('Item 1', style='List Bullet')
#list_number(d, p0, level=0, num=False)
#p1 = d.add_paragraph('Item A' , style='List Bullet 2')
#list_number(d, p1, p0, level=1)
#p2 = d.add_paragraph('Item 2', style='List Bullet')
#list_number(d, p2, p1, level=0)
#p3 = d.add_paragraph('Item B', style='List Bullet 2')
#list_number(d, p3, p2, level=1)

#document.add_heading('Heading, level 1', level=1)
#document.add_paragraph('Intense quote', style='IntenseQuote')

#document.add_paragraph('first item in unordered list', style='ListBullet')
#document.add_paragraph('first item in ordered list', style='ListNumber')


#OK
#p = document.add_paragraph('')
#p.add_run('salit').underline = True
#p.add_run('pipotron').bold = True


#style = document.styles['Normal']
#font = style.font
#font.name = 'Arial'
#font.size = Pt(24)
#paragraph.style = document.styles['Normal']

# OK  avec la couleur cyan
#run = document.add_paragraph().add_run()
#style = document.styles['Normal']
#font = style.font
# fixe la couleur de la fonte
#font.color.rgb = RGBColor(0x42, 0xCC, 0xE9)
#font.name = 'Arial'
#font.size = Pt(10)
#document.add_paragraph('Some text').add_run()


# OK
#p = document.add_paragraph()
#runner = p.add_run("word")
#runner.bold = True
#runner.italic = True
#runner.underline = True

#document.add_paragraph("blabla", style="ListNumber")
#document.add_paragraph("blabla", style="ListNumber2")
#document.add_paragraph("blabla", style="ListNumber3")
#document.add_paragraph("blabla", style="ListNumber")




# OK
#p = document.add_paragraph(style = 'ListParagraph', text = "1.")
#p = document.add_paragraph(style = 'ListParagraph', text = "2.")
#p = document.add_paragraph(style = 'ListParagraph', text = "3.")
#p = document.add_paragraph(style = 'ListParagraph', text = "4.")
#p = document.add_paragraph(style = 'ListParagraph', text = "5.")
#p = document.add_paragraph(style = 'ListParagraph', text = "6.")

#p = document.add_paragraph(style = 'List Continue', text = "1a.")
#p = document.add_paragraph(style = 'List Continue', text = "2a.")
#p = document.add_paragraph(style = 'List Continue', text = "3a.")
#p = document.add_paragraph(style = 'List Continue', text = "4a.")

#p = document.add_paragraph(style = 'List', text = "1.1")
#p = document.add_paragraph(style = 'List', text = "1.2")
#p = document.add_paragraph(style = 'List', text = "1.3")
#p = document.add_paragraph(style = 'List', text = "1.4")
#p = document.add_paragraph(style = 'List', text = "1.5")
#p = document.add_paragraph(style = 'List', text = "1.6")



# add page
document.add_page_break()

document.save('toto.docx')
