Coverage for /var/srv/projects/api.amasfac.comuna18.com/tmp/venv/lib/python3.9/site-packages/odf/draw.py: 38%

118 statements  

« prev     ^ index     » next       coverage.py v6.4.4, created at 2023-07-17 14:22 -0600

1# -*- coding: utf-8 -*- 

2# Copyright (C) 2006-2007 Søren Roug, European Environment Agency 

3# 

4# This library is free software; you can redistribute it and/or 

5# modify it under the terms of the GNU Lesser General Public 

6# License as published by the Free Software Foundation; either 

7# version 2.1 of the License, or (at your option) any later version. 

8# 

9# This library is distributed in the hope that it will be useful, 

10# but WITHOUT ANY WARRANTY; without even the implied warranty of 

11# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 

12# Lesser General Public License for more details. 

13# 

14# You should have received a copy of the GNU Lesser General Public 

15# License along with this library; if not, write to the Free Software 

16# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA 

17# 

18# Contributor(s): 

19# 

20 

21import sys, os.path 

22sys.path.append(os.path.dirname(__file__)) 

23from odf.namespaces import DRAWNS, STYLENS, PRESENTATIONNS 

24from odf.element import Element 

25 

26def StyleRefElement(stylename=None, classnames=None, **args): 

27 qattrs = {} 

28 if stylename is not None: 

29 f = stylename.getAttrNS(STYLENS, 'family') 

30 if f == 'graphic': 

31 qattrs[(DRAWNS,u'style-name')]= stylename 

32 elif f == 'presentation': 

33 qattrs[(PRESENTATIONNS,u'style-name')]= stylename 

34 else: 

35 raise ValueError( "Style's family must be either 'graphic' or 'presentation'") 

36 if classnames is not None: 

37 f = classnames[0].getAttrNS(STYLENS, 'family') 

38 if f == 'graphic': 

39 qattrs[(DRAWNS,u'class-names')]= classnames 

40 elif f == 'presentation': 

41 qattrs[(PRESENTATIONNS,u'class-names')]= classnames 

42 else: 

43 raise ValueError( "Style's family must be either 'graphic' or 'presentation'") 

44 return Element(qattributes=qattrs, **args) 

45 

46def 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# Autogenerated 

53def A(**args): 

54 args.setdefault('type', 'simple') 

55 return Element(qname = (DRAWNS,'a'), **args) 

56 

57def Applet(**args): 

58 return Element(qname = (DRAWNS,'applet'), **args) 

59 

60def AreaCircle(**args): 

61 return Element(qname = (DRAWNS,'area-circle'), **args) 

62 

63def AreaPolygon(**args): 

64 return Element(qname = (DRAWNS,'area-polygon'), **args) 

65 

66def AreaRectangle(**args): 

67 return Element(qname = (DRAWNS,'area-rectangle'), **args) 

68 

69def Caption(**args): 

70 return StyleRefElement(qname = (DRAWNS,'caption'), **args) 

71 

72def Circle(**args): 

73 return StyleRefElement(qname = (DRAWNS,'circle'), **args) 

74 

75def Connector(**args): 

76 return StyleRefElement(qname = (DRAWNS,'connector'), **args) 

77 

78def ContourPath(**args): 

79 return Element(qname = (DRAWNS,'contour-path'), **args) 

80 

81def ContourPolygon(**args): 

82 return Element(qname = (DRAWNS,'contour-polygon'), **args) 

83 

84def Control(**args): 

85 return StyleRefElement(qname = (DRAWNS,'control'), **args) 

86 

87def CustomShape(**args): 

88 return StyleRefElement(qname = (DRAWNS,'custom-shape'), **args) 

89 

90def Ellipse(**args): 

91 return StyleRefElement(qname = (DRAWNS,'ellipse'), **args) 

92 

93def EnhancedGeometry(**args): 

94 return Element(qname = (DRAWNS,'enhanced-geometry'), **args) 

95 

96def Equation(**args): 

97 return Element(qname = (DRAWNS,'equation'), **args) 

98 

99def FillImage(**args): 

100 args.setdefault('type', 'simple') 

101 return DrawElement(qname = (DRAWNS,'fill-image'), **args) 

102 

103def FloatingFrame(**args): 

104 args.setdefault('type', 'simple') 

105 return Element(qname = (DRAWNS,'floating-frame'), **args) 

106 

107def Frame(**args): 

108 return StyleRefElement(qname = (DRAWNS,'frame'), **args) 

109 

110def G(**args): 

111 return StyleRefElement(qname = (DRAWNS,'g'), **args) 

112 

113def GluePoint(**args): 

114 return Element(qname = (DRAWNS,'glue-point'), **args) 

115 

116def Gradient(**args): 

117 return DrawElement(qname = (DRAWNS,'gradient'), **args) 

118 

119def Handle(**args): 

120 return Element(qname = (DRAWNS,'handle'), **args) 

121 

122def Hatch(**args): 

123 return DrawElement(qname = (DRAWNS,'hatch'), **args) 

124 

125def Image(**args): 

126 return Element(qname = (DRAWNS,'image'), **args) 

127 

128def ImageMap(**args): 

129 return Element(qname = (DRAWNS,'image-map'), **args) 

130 

131def Layer(**args): 

132 return Element(qname = (DRAWNS,'layer'), **args) 

133 

134def LayerSet(**args): 

135 return Element(qname = (DRAWNS,'layer-set'), **args) 

136 

137def Line(**args): 

138 return StyleRefElement(qname = (DRAWNS,'line'), **args) 

139 

140def Marker(**args): 

141 return DrawElement(qname = (DRAWNS,'marker'), **args) 

142 

143def Measure(**args): 

144 return StyleRefElement(qname = (DRAWNS,'measure'), **args) 

145 

146def Object(**args): 

147 return Element(qname = (DRAWNS,'object'), **args) 

148 

149def ObjectOle(**args): 

150 return Element(qname = (DRAWNS,'object-ole'), **args) 

151 

152def Opacity(**args): 

153 return DrawElement(qname = (DRAWNS,'opacity'), **args) 

154 

155def Page(**args): 

156 return Element(qname = (DRAWNS,'page'), **args) 

157 

158def PageThumbnail(**args): 

159 return StyleRefElement(qname = (DRAWNS,'page-thumbnail'), **args) 

160 

161def Param(**args): 

162 return Element(qname = (DRAWNS,'param'), **args) 

163 

164def Path(**args): 

165 return StyleRefElement(qname = (DRAWNS,'path'), **args) 

166 

167def Plugin(**args): 

168 args.setdefault('type', 'simple') 

169 return Element(qname = (DRAWNS,'plugin'), **args) 

170 

171def Polygon(**args): 

172 return StyleRefElement(qname = (DRAWNS,'polygon'), **args) 

173 

174def Polyline(**args): 

175 return StyleRefElement(qname = (DRAWNS,'polyline'), **args) 

176 

177def Rect(**args): 

178 return StyleRefElement(qname = (DRAWNS,'rect'), **args) 

179 

180def RegularPolygon(**args): 

181 return StyleRefElement(qname = (DRAWNS,'regular-polygon'), **args) 

182 

183def StrokeDash(**args): 

184 return DrawElement(qname = (DRAWNS,'stroke-dash'), **args) 

185 

186def TextBox(**args): 

187 return Element(qname = (DRAWNS,'text-box'), **args) 

188