1
##############################################################################
3
# Copyright (c) 2004 TINY SPRL. (http://tiny.be) All Rights Reserved.
4
# Fabien Pinckaers <fp@tiny.Be>
6
# WARNING: This program as such is intended to be used by professional
7
# programmers who take the whole responsability of assessing all potential
8
# consequences resulting from its eventual inadequacies and bugs
9
# End users who are looking for a ready-to-use solution with commercial
10
# garantees and support are strongly adviced to contract a Free Software
13
# This program is Free Software; you can redistribute it and/or
14
# modify it under the terms of the GNU General Public License
15
# as published by the Free Software Foundation; either version 2
16
# of the License, or (at your option) any later version.
18
# This program is distributed in the hope that it will be useful,
19
# but WITHOUT ANY WARRANTY; without even the implied warranty of
20
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
21
# GNU General Public License for more details.
23
# You should have received a copy of the GNU General Public License
24
# along with this program; if not, write to the Free Software
25
# Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
27
##############################################################################
29
# trml2pdf - An RML to PDF converter
30
# Copyright (C) 2003, Fabien Pinckaers, UCL, FSA
32
# This library is free software; you can redistribute it and/or
33
# modify it under the terms of the GNU Lesser General Public
34
# License as published by the Free Software Foundation; either
35
# version 2.1 of the License, or (at your option) any later version.
37
# This library is distributed in the hope that it will be useful,
38
# but WITHOUT ANY WARRANTY; without even the implied warranty of
39
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
40
# Lesser General Public License for more details.
42
# You should have received a copy of the GNU Lesser General Public
43
# License along with this library; if not, write to the Free Software
44
# Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
51
for node in node.childNodes:
52
if node.nodeType == node.TEXT_NODE:
57
(re.compile('^(-?[0-9\.]+)\s*in$'), reportlab.lib.units.inch),
58
(re.compile('^(-?[0-9\.]+)\s*cm$'), reportlab.lib.units.cm),
59
(re.compile('^(-?[0-9\.]+)\s*mm$'), reportlab.lib.units.mm),
60
(re.compile('^(-?[0-9\.]+)\s*$'), 1)
66
res = unit[0].search(size, 0)
68
return unit[1]*float(res.group(1))
71
def tuple_int_get(node, attr_name, default=None):
72
if not node.hasAttribute(attr_name):
74
res = [int(x) for x in node.getAttribute(attr_name).split(',')]
78
return (str(value)=="1") or (value.lower()=='yes')
80
def attr_get(node, attrs, dict={}):
83
if node.hasAttribute(name):
84
res[name] = unit_get(node.getAttribute(name))
86
if node.hasAttribute(key):
88
res[key] = str(node.getAttribute(key))
89
elif dict[key]=='bool':
90
res[key] = bool_get(node.getAttribute(key))
91
elif dict[key]=='int':
92
res[key] = int(node.getAttribute(key))