| 1 |
# Copyright (C) 2006-2007 Søren Roug, European Environment Agency |
| 2 |
# |
| 3 |
# This library is free software; you can redistribute it and/or |
| 4 |
# modify it under the terms of the GNU Lesser General Public |
| 5 |
# License as published by the Free Software Foundation; either |
| 6 |
# version 2.1 of the License, or (at your option) any later version. |
| 7 |
# |
| 8 |
# This library is distributed in the hope that it will be useful, |
| 9 |
# but WITHOUT ANY WARRANTY; without even the implied warranty of |
| 10 |
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU |
| 11 |
# Lesser General Public License for more details. |
| 12 |
# |
| 13 |
# You should have received a copy of the GNU Lesser General Public |
| 14 |
# License along with this library; if not, write to the Free Software |
| 15 |
# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA |
| 16 |
# |
| 17 |
# Contributor(s): |
| 18 |
# |
| 19 |
|
| 20 |
|
| 21 |
from .element import Element |
| 22 |
from .namespaces import DRAWNS, PRESENTATIONNS, STYLENS |
| 23 |
|
| 24 |
|
| 25 |
def StyleRefElement(stylename=None, classnames=None, **args): |
| 26 |
qattrs = {} |
| 27 |
if stylename is not None: |
| 28 |
f = stylename.getAttrNS(STYLENS, 'family') |
| 29 |
if f == 'graphic': |
| 30 |
qattrs[(DRAWNS, 'style-name')] = stylename |
| 31 |
elif f == 'presentation': |
| 32 |
qattrs[(PRESENTATIONNS, 'style-name')] = stylename |
| 33 |
else: |
| 34 |
raise ValueError("Style's family must be either 'graphic' or 'presentation'") |
| 35 |
if classnames is not None: |
| 36 |
f = classnames[0].getAttrNS(STYLENS, 'family') |
| 37 |
if f == 'graphic': |
| 38 |
qattrs[(DRAWNS, 'class-names')] = classnames |
| 39 |
elif f == 'presentation': |
| 40 |
qattrs[(PRESENTATIONNS, 'class-names')] = classnames |
| 41 |
else: |
| 42 |
raise ValueError("Style's family must be either 'graphic' or 'presentation'") |
| 43 |
return Element(qattributes=qattrs, **args) |
| 44 |
|
| 45 |
|
| 46 |
def DrawElement(name=None, **args): |
| 47 |
e = Element(name=name, **args) |
| 48 |
if 'displayname' not in args: |
| 49 |
e.setAttrNS(DRAWNS, 'display-name', name) |
| 50 |
return e |
| 51 |
|
| 52 |
|
| 53 |
# Autogenerated |
| 54 |
|
| 55 |
|
| 56 |
def A(**args): |
| 57 |
return Element(qname=(DRAWNS, 'a'), **args) |
| 58 |
|
| 59 |
|
| 60 |
def Applet(**args): |
| 61 |
return Element(qname=(DRAWNS, 'applet'), **args) |
| 62 |
|
| 63 |
|
| 64 |
def AreaCircle(**args): |
| 65 |
return Element(qname=(DRAWNS, 'area-circle'), **args) |
| 66 |
|
| 67 |
|
| 68 |
def AreaPolygon(**args): |
| 69 |
return Element(qname=(DRAWNS, 'area-polygon'), **args) |
| 70 |
|
| 71 |
|
| 72 |
def AreaRectangle(**args): |
| 73 |
return Element(qname=(DRAWNS, 'area-rectangle'), **args) |
| 74 |
|
| 75 |
|
| 76 |
def Caption(**args): |
| 77 |
return StyleRefElement(qname=(DRAWNS, 'caption'), **args) |
| 78 |
|
| 79 |
|
| 80 |
def Circle(**args): |
| 81 |
return StyleRefElement(qname=(DRAWNS, 'circle'), **args) |
| 82 |
|
| 83 |
|
| 84 |
def Connector(**args): |
| 85 |
return StyleRefElement(qname=(DRAWNS, 'connector'), **args) |
| 86 |
|
| 87 |
|
| 88 |
def ContourPath(**args): |
| 89 |
return Element(qname=(DRAWNS, 'contour-path'), **args) |
| 90 |
|
| 91 |
|
| 92 |
def ContourPolygon(**args): |
| 93 |
return Element(qname=(DRAWNS, 'contour-polygon'), **args) |
| 94 |
|
| 95 |
|
| 96 |
def Control(**args): |
| 97 |
return StyleRefElement(qname=(DRAWNS, 'control'), **args) |
| 98 |
|
| 99 |
|
| 100 |
def CustomShape(**args): |
| 101 |
return StyleRefElement(qname=(DRAWNS, 'custom-shape'), **args) |
| 102 |
|
| 103 |
|
| 104 |
def Ellipse(**args): |
| 105 |
return StyleRefElement(qname=(DRAWNS, 'ellipse'), **args) |
| 106 |
|
| 107 |
|
| 108 |
def EnhancedGeometry(**args): |
| 109 |
return Element(qname=(DRAWNS, 'enhanced-geometry'), **args) |
| 110 |
|
| 111 |
|
| 112 |
def Equation(**args): |
| 113 |
return Element(qname=(DRAWNS, 'equation'), **args) |
| 114 |
|
| 115 |
|
| 116 |
def FillImage(**args): |
| 117 |
return DrawElement(qname=(DRAWNS, 'fill-image'), **args) |
| 118 |
|
| 119 |
|
| 120 |
def FloatingFrame(**args): |
| 121 |
return Element(qname=(DRAWNS, 'floating-frame'), **args) |
| 122 |
|
| 123 |
|
| 124 |
def Frame(**args): |
| 125 |
return StyleRefElement(qname=(DRAWNS, 'frame'), **args) |
| 126 |
|
| 127 |
|
| 128 |
def G(**args): |
| 129 |
return StyleRefElement(qname=(DRAWNS, 'g'), **args) |
| 130 |
|
| 131 |
|
| 132 |
def GluePoint(**args): |
| 133 |
return Element(qname=(DRAWNS, 'glue-point'), **args) |
| 134 |
|
| 135 |
|
| 136 |
def Gradient(**args): |
| 137 |
return DrawElement(qname=(DRAWNS, 'gradient'), **args) |
| 138 |
|
| 139 |
|
| 140 |
def Handle(**args): |
| 141 |
return Element(qname=(DRAWNS, 'handle'), **args) |
| 142 |
|
| 143 |
|
| 144 |
def Hatch(**args): |
| 145 |
return DrawElement(qname=(DRAWNS, 'hatch'), **args) |
| 146 |
|
| 147 |
|
| 148 |
def Image(**args): |
| 149 |
return Element(qname=(DRAWNS, 'image'), **args) |
| 150 |
|
| 151 |
|
| 152 |
def ImageMap(**args): |
| 153 |
return Element(qname=(DRAWNS, 'image-map'), **args) |
| 154 |
|
| 155 |
|
| 156 |
def Layer(**args): |
| 157 |
return Element(qname=(DRAWNS, 'layer'), **args) |
| 158 |
|
| 159 |
|
| 160 |
def LayerSet(**args): |
| 161 |
return Element(qname=(DRAWNS, 'layer-set'), **args) |
| 162 |
|
| 163 |
|
| 164 |
def Line(**args): |
| 165 |
return StyleRefElement(qname=(DRAWNS, 'line'), **args) |
| 166 |
|
| 167 |
|
| 168 |
def Marker(**args): |
| 169 |
return DrawElement(qname=(DRAWNS, 'marker'), **args) |
| 170 |
|
| 171 |
|
| 172 |
def Measure(**args): |
| 173 |
return StyleRefElement(qname=(DRAWNS, 'measure'), **args) |
| 174 |
|
| 175 |
|
| 176 |
def Object(**args): |
| 177 |
return Element(qname=(DRAWNS, 'object'), **args) |
| 178 |
|
| 179 |
|
| 180 |
def ObjectOle(**args): |
| 181 |
return Element(qname=(DRAWNS, 'object-ole'), **args) |
| 182 |
|
| 183 |
|
| 184 |
def Opacity(**args): |
| 185 |
return DrawElement(qname=(DRAWNS, 'opacity'), **args) |
| 186 |
|
| 187 |
|
| 188 |
def Page(**args): |
| 189 |
return Element(qname=(DRAWNS, 'page'), **args) |
| 190 |
|
| 191 |
|
| 192 |
def PageThumbnail(**args): |
| 193 |
return StyleRefElement(qname=(DRAWNS, 'page-thumbnail'), **args) |
| 194 |
|
| 195 |
|
| 196 |
def Param(**args): |
| 197 |
return Element(qname=(DRAWNS, 'param'), **args) |
| 198 |
|
| 199 |
|
| 200 |
def Path(**args): |
| 201 |
return StyleRefElement(qname=(DRAWNS, 'path'), **args) |
| 202 |
|
| 203 |
|
| 204 |
def Plugin(**args): |
| 205 |
return Element(qname=(DRAWNS, 'plugin'), **args) |
| 206 |
|
| 207 |
|
| 208 |
def Polygon(**args): |
| 209 |
return StyleRefElement(qname=(DRAWNS, 'polygon'), **args) |
| 210 |
|
| 211 |
|
| 212 |
def Polyline(**args): |
| 213 |
return StyleRefElement(qname=(DRAWNS, 'polyline'), **args) |
| 214 |
|
| 215 |
|
| 216 |
def Rect(**args): |
| 217 |
return StyleRefElement(qname=(DRAWNS, 'rect'), **args) |
| 218 |
|
| 219 |
|
| 220 |
def RegularPolygon(**args): |
| 221 |
return StyleRefElement(qname=(DRAWNS, 'regular-polygon'), **args) |
| 222 |
|
| 223 |
|
| 224 |
def StrokeDash(**args): |
| 225 |
return DrawElement(qname=(DRAWNS, 'stroke-dash'), **args) |
| 226 |
|
| 227 |
|
| 228 |
def TextBox(**args): |
| 229 |
return Element(qname=(DRAWNS, 'text-box'), **args) |