1 # -*- coding: utf-8 -*-
2 # drawing hearts in the snow!
3 from odf
.opendocument
import OpenDocumentText
4 from odf
.text
import P
, Span
5 from odf
.style
import Style
, TextProperties
, ParagraphProperties
, BackgroundImage
, GraphicProperties
6 from odf
.draw
import Frame
, TextBox
11 words
= [u
"aai", u
"aan", u
"alleen", u
"beloofde", u
"bemind", u
"benen", u
"bewust", u
"borst", u
"eenzaam", u
"elkaar", u
"geloofde", u
"gesmoord", u
"gevoel", u
"gezicht", u
"giechelend", u
"glimlachte", u
"haar", u
"hand", u
"haren", u
"hem", u
"hen", u
"herinner", u
"herinneren", u
"herinneringen", u
"hier", u
"hij", u
"hoofd", u
"hoop", u
"huilen", u
"ik", u
"ja", u
"je", u
"Jij", u
"jij", u
"jou", u
"jouw", u
"kiezen", u
"kleurde", u
"leven", u
"liefde", u
"liefdes", u
"liefs", u
"liefste", u
"lieve", u
"lippen", u
"man", u
"me", u
"mijn", u
"moed", u
"moeilijk", u
"ogen", u
"ons", u
"ontmoeting", u
"onze", u
"opnieuw", u
"rituelen", u
"roos", u
"routine", u
"ruggen", u
"samen", u
"smoorverliefd", u
"spijt", u
"stotterde", u
"streelde", u
"tenen", u
"troost", u
"vergat", u
"vergeet", u
"vergeten", u
"voorzichtig", u
"vriend", u
"vrienden", u
"vrijheid", u
"vrouw", u
"we", u
"wij", u
"wil", u
"wilde", u
"wilden", u
"willen", u
"ze", u
"zelf", u
"zij", u
"zijn", u
"zinnen"]
13 def special_kinda_p(paragraphic_style
, boldstyle
, text
, textbox
):
14 sectioned
= text
.split()
15 p
= P(text
=u
"", stylename
=paragraphic_style
)
18 for i
in range(len(sectioned
)-1):
19 if sectioned
[i
] in words
:
20 boldpart
= Span(stylename
=boldstyle
, text
=sectioned
[i
] + u
" ")
21 p
.addElement(boldpart
)
23 normalpart
= Span(text
=sectioned
[i
] + u
" ")
24 p
.addElement(normalpart
)
25 p
.addText(sectioned
[-1])
30 def character_text_frame(odt
, genre
, spice
):
33 boldstyle
= Style(name
=spice
+ "Bold", family
="text")
34 boldprop
= TextProperties(fontfamily
="diluvienne", fontsize
="28pt")
35 boldstyle
.addElement(boldprop
)
36 odt
.automaticstyles
.addElement(boldstyle
)
37 elif spice
== "champagne":
38 boldstyle
= Style(name
=spice
+ "Bold", family
="text")
39 boldprop
= TextProperties(fontfamily
="Cimatics_Trash")
40 boldstyle
.addElement(boldprop
)
41 odt
.automaticstyles
.addElement(boldstyle
)
43 boldstyle
= Style(name
=spice
+ "Bold", family
="text")
44 boldprop
= TextProperties(fontweight
="bold", fontfamily
="NotCourierSans", letterspacing
="2mm")
45 boldstyle
.addElement(boldprop
)
46 odt
.automaticstyles
.addElement(boldstyle
)
48 ### header frame (for letter)
53 graphic_style
= Style(name
="Main Body Frame", family
="graphic")
54 graphic_properties
= GraphicProperties(backgroundcolor
="#ffffff", border
="10mm double #ffffff")
55 graphic_style
.addElement(graphic_properties
)
56 frame
= make_frame(odt
, graphic_style
, "240mm", "170mm", "0mm", "0mm", "1")
57 frameframe
= frame
["frame"]
58 textbox
= frame
["textbox"]
60 for paragraph
in txt
[genre
]:
61 special_kinda_p("Body Text", boldstyle
, paragraph
, textbox
)
63 odt
.text
.addElement(frameframe
)
65 def loop_over_character_spices(genre
, style
):
66 spices
= ["sexy", "champagne", "lungo"]
67 for myspice
in spices
:
68 myodt
= OpenDocumentText()
70 genredotstyle
= Spice
.read_stylesheet(genre
, style
)
71 Spice
.myodt
.styles
.addElement(genredotstyle
) ?????
72 Spice
.frame_border(myodt
)
74 Spice
.character_text_frame(myodt
, genre
, myspice
)
77 Spice
.label(myodt
, myspice
, style
)
79 # myname = genre + "/" + style + "/character/" + genre + "_" + style + "_" + myspice
81 # myodt.save(myname, True)
85 for genre
in ["brief", "verhaal", "gedicht"]:
86 for style
in text_style
[genre
].keys():
87 loop_over_character_spices(genre
, style
)