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 class CharSpice(Spice
):
12 def __init__(self
, spices
, words
):
13 Spice
.__init
__(self
, ["sexy", "champagne", "lungo"], [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
"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"])
15 def special_kinda_p(paragraphic_style
, boldstyle
, text
, textbox
):
16 sectioned
= text
.split()
17 p
= P(text
=u
"", stylename
=paragraphic_style
)
20 for i
in range(len(sectioned
)-1):
21 if sectioned
[i
].lower() in self
.words
:
22 boldpart
= Span(stylename
=boldstyle
, text
=sectioned
[i
] + u
" ")
23 p
.addElement(boldpart
)
25 normalpart
= Span(text
=sectioned
[i
] + u
" ")
26 p
.addElement(normalpart
)
27 p
.addText(sectioned
[-1])
32 def character_text_frame(self
, odt
, spice
):
35 boldstyle
= Style(name
=spice
+ "Bold", family
="text")
36 boldprop
= TextProperties(fontfamily
="diluvienne", fontsize
="28pt")
37 boldstyle
.addElement(boldprop
)
38 odt
.automaticstyles
.addElement(boldstyle
)
39 elif spice
== "champagne":
40 boldstyle
= Style(name
=spice
+ "Bold", family
="text")
41 boldprop
= TextProperties(fontfamily
="Cimatics_Trash")
42 boldstyle
.addElement(boldprop
)
43 odt
.automaticstyles
.addElement(boldstyle
)
45 boldstyle
= Style(name
=spice
+ "Bold", family
="text")
46 boldprop
= TextProperties(fontweight
="bold", fontfamily
="NotCourierSans", letterspacing
="2mm")
47 boldstyle
.addElement(boldprop
)
48 odt
.automaticstyles
.addElement(boldstyle
)
50 ### header frame (for letter)
51 if self
.genre
== "brief":
55 graphic_style
= Style(name
="Main Body Frame", family
="graphic")
56 graphic_properties
= GraphicProperties(backgroundcolor
="#ffffff", border
="10mm double #ffffff")
57 graphic_style
.addElement(graphic_properties
)
58 frame
= self
.make_frame(odt
, graphic_style
, "240mm", "170mm", "0mm", "0mm", "1")
59 frameframe
= frame
["frame"]
60 textbox
= frame
["textbox"]
62 for paragraph
in txt
[self
.genre
]:
63 special_kinda_p("Body Text", boldstyle
, paragraph
, textbox
)
65 odt
.text
.addElement(frameframe
)
68 for myspice
in self
.spices
:
70 myodt
= OpenDocumentText()
72 # genredotstyle... is this really the name we want?
73 genredotstyle
= self
.read_stylesheet(self
.genre
, self
.style
)
74 myodt
.styles
.addElement(genredotstyle
)
75 self
.frame_border(myodt
)
77 self
.character_text_frame(self
, myodt
, myspice
)
80 self
.label(myodt
, myspice
, self
.style
)
82 self
.myname
= self
.genre
+ "/" + self
.style
+ "/character/" + self
.genre
+ "_" + self
.style
+ "_" + myspice
83 myodt
.save(self
.myname
, True)
86 for genre
in ["brief", "verhaal", "gedicht"]:
87 for style
in text_style
[genre
].keys():
89 one_odt
.setgenrestyle(genre
, style
)