mathematical 0.1.0 → 0.1.1
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/ext/mathematical/extconf.rb +14 -0
- data/ext/mathematical/itex2MML.h +63 -0
- data/ext/mathematical/lasemrender.c +257 -0
- data/ext/mathematical/lex.yy.c +6548 -0
- data/ext/mathematical/lsm.c +31 -0
- data/ext/mathematical/lsm.h +39 -0
- data/ext/mathematical/lsmattributes.c +279 -0
- data/ext/mathematical/lsmattributes.h +75 -0
- data/ext/mathematical/lsmcairo.c +598 -0
- data/ext/mathematical/lsmcairo.h +51 -0
- data/ext/mathematical/lsmdebug.c +183 -0
- data/ext/mathematical/lsmdebug.h +73 -0
- data/ext/mathematical/lsmdom.h +43 -0
- data/ext/mathematical/lsmdomcharacterdata.c +114 -0
- data/ext/mathematical/lsmdomcharacterdata.h +59 -0
- data/ext/mathematical/lsmdomdocument.c +255 -0
- data/ext/mathematical/lsmdomdocument.h +75 -0
- data/ext/mathematical/lsmdomdocumentfragment.c +81 -0
- data/ext/mathematical/lsmdomdocumentfragment.h +55 -0
- data/ext/mathematical/lsmdomelement.c +148 -0
- data/ext/mathematical/lsmdomelement.h +62 -0
- data/ext/mathematical/lsmdomentities.c +2166 -0
- data/ext/mathematical/lsmdomentities.h +35 -0
- data/ext/mathematical/lsmdomenumtypes.c +99 -0
- data/ext/mathematical/lsmdomenumtypes.h +26 -0
- data/ext/mathematical/lsmdomimplementation.c +82 -0
- data/ext/mathematical/lsmdomimplementation.h +41 -0
- data/ext/mathematical/lsmdomnamednodemap.c +118 -0
- data/ext/mathematical/lsmdomnamednodemap.h +64 -0
- data/ext/mathematical/lsmdomnode.c +737 -0
- data/ext/mathematical/lsmdomnode.h +122 -0
- data/ext/mathematical/lsmdomnodelist.c +70 -0
- data/ext/mathematical/lsmdomnodelist.h +58 -0
- data/ext/mathematical/lsmdomparser.c +461 -0
- data/ext/mathematical/lsmdomparser.h +54 -0
- data/ext/mathematical/lsmdomtext.c +82 -0
- data/ext/mathematical/lsmdomtext.h +55 -0
- data/ext/mathematical/lsmdomtypes.h +44 -0
- data/ext/mathematical/lsmdomview.c +422 -0
- data/ext/mathematical/lsmdomview.h +94 -0
- data/ext/mathematical/lsmitex.c +76 -0
- data/ext/mathematical/lsmitex.h +36 -0
- data/ext/mathematical/lsmmathml.h +66 -0
- data/ext/mathematical/lsmmathmlactionelement.c +93 -0
- data/ext/mathematical/lsmmathmlactionelement.h +57 -0
- data/ext/mathematical/lsmmathmlaligngroupelement.c +102 -0
- data/ext/mathematical/lsmmathmlaligngroupelement.h +56 -0
- data/ext/mathematical/lsmmathmlalignmarkelement.c +102 -0
- data/ext/mathematical/lsmmathmlalignmarkelement.h +56 -0
- data/ext/mathematical/lsmmathmlattributes.c +197 -0
- data/ext/mathematical/lsmmathmlattributes.h +126 -0
- data/ext/mathematical/lsmmathmldocument.c +304 -0
- data/ext/mathematical/lsmmathmldocument.h +61 -0
- data/ext/mathematical/lsmmathmlelement.c +491 -0
- data/ext/mathematical/lsmmathmlelement.h +107 -0
- data/ext/mathematical/lsmmathmlenums.c +429 -0
- data/ext/mathematical/lsmmathmlenums.h +182 -0
- data/ext/mathematical/lsmmathmlenumtypes.c +666 -0
- data/ext/mathematical/lsmmathmlenumtypes.h +90 -0
- data/ext/mathematical/lsmmathmlerrorelement.c +58 -0
- data/ext/mathematical/lsmmathmlerrorelement.h +56 -0
- data/ext/mathematical/lsmmathmlfencedelement.c +178 -0
- data/ext/mathematical/lsmmathmlfencedelement.h +65 -0
- data/ext/mathematical/lsmmathmlfractionelement.c +253 -0
- data/ext/mathematical/lsmmathmlfractionelement.h +62 -0
- data/ext/mathematical/lsmmathmlglyphtableams.c +597 -0
- data/ext/mathematical/lsmmathmlglyphtableams.h +45 -0
- data/ext/mathematical/lsmmathmlitexelement.c +187 -0
- data/ext/mathematical/lsmmathmlitexelement.h +60 -0
- data/ext/mathematical/lsmmathmllayoututils.c +191 -0
- data/ext/mathematical/lsmmathmllayoututils.h +58 -0
- data/ext/mathematical/lsmmathmlmathelement.c +204 -0
- data/ext/mathematical/lsmmathmlmathelement.h +81 -0
- data/ext/mathematical/lsmmathmloperatordictionary.c +3332 -0
- data/ext/mathematical/lsmmathmloperatordictionary.h +54 -0
- data/ext/mathematical/lsmmathmloperatorelement.c +307 -0
- data/ext/mathematical/lsmmathmloperatorelement.h +73 -0
- data/ext/mathematical/lsmmathmlpaddedelement.c +58 -0
- data/ext/mathematical/lsmmathmlpaddedelement.h +56 -0
- data/ext/mathematical/lsmmathmlphantomelement.c +71 -0
- data/ext/mathematical/lsmmathmlphantomelement.h +56 -0
- data/ext/mathematical/lsmmathmlpresentationcontainer.c +43 -0
- data/ext/mathematical/lsmmathmlpresentationcontainer.h +54 -0
- data/ext/mathematical/lsmmathmlpresentationtoken.c +303 -0
- data/ext/mathematical/lsmmathmlpresentationtoken.h +83 -0
- data/ext/mathematical/lsmmathmlradicalelement.c +266 -0
- data/ext/mathematical/lsmmathmlradicalelement.h +71 -0
- data/ext/mathematical/lsmmathmlrowelement.c +58 -0
- data/ext/mathematical/lsmmathmlrowelement.h +56 -0
- data/ext/mathematical/lsmmathmlscriptelement.c +282 -0
- data/ext/mathematical/lsmmathmlscriptelement.h +78 -0
- data/ext/mathematical/lsmmathmlsemanticselement.c +84 -0
- data/ext/mathematical/lsmmathmlsemanticselement.h +56 -0
- data/ext/mathematical/lsmmathmlspaceelement.c +142 -0
- data/ext/mathematical/lsmmathmlspaceelement.h +60 -0
- data/ext/mathematical/lsmmathmlstringelement.c +123 -0
- data/ext/mathematical/lsmmathmlstringelement.h +58 -0
- data/ext/mathematical/lsmmathmlstyle.c +130 -0
- data/ext/mathematical/lsmmathmlstyle.h +81 -0
- data/ext/mathematical/lsmmathmlstyleelement.c +307 -0
- data/ext/mathematical/lsmmathmlstyleelement.h +87 -0
- data/ext/mathematical/lsmmathmltablecellelement.c +122 -0
- data/ext/mathematical/lsmmathmltablecellelement.h +62 -0
- data/ext/mathematical/lsmmathmltableelement.c +545 -0
- data/ext/mathematical/lsmmathmltableelement.h +78 -0
- data/ext/mathematical/lsmmathmltablerowelement.c +120 -0
- data/ext/mathematical/lsmmathmltablerowelement.h +64 -0
- data/ext/mathematical/lsmmathmltraits.c +819 -0
- data/ext/mathematical/lsmmathmltraits.h +119 -0
- data/ext/mathematical/lsmmathmltypes.h +66 -0
- data/ext/mathematical/lsmmathmlunderoverelement.c +485 -0
- data/ext/mathematical/lsmmathmlunderoverelement.h +82 -0
- data/ext/mathematical/lsmmathmlutils.c +170 -0
- data/ext/mathematical/lsmmathmlutils.h +50 -0
- data/ext/mathematical/lsmmathmlview.c +1048 -0
- data/ext/mathematical/lsmmathmlview.h +164 -0
- data/ext/mathematical/lsmproperties.c +418 -0
- data/ext/mathematical/lsmproperties.h +85 -0
- data/ext/mathematical/lsmstr.c +231 -0
- data/ext/mathematical/lsmstr.h +114 -0
- data/ext/mathematical/lsmsvg.h +67 -0
- data/ext/mathematical/lsmsvgaelement.c +73 -0
- data/ext/mathematical/lsmsvgaelement.h +55 -0
- data/ext/mathematical/lsmsvgattributes.h +118 -0
- data/ext/mathematical/lsmsvgcircleelement.c +153 -0
- data/ext/mathematical/lsmsvgcircleelement.h +59 -0
- data/ext/mathematical/lsmsvgclippathelement.c +134 -0
- data/ext/mathematical/lsmsvgclippathelement.h +59 -0
- data/ext/mathematical/lsmsvgcolors.c +212 -0
- data/ext/mathematical/lsmsvgcolors.h +39 -0
- data/ext/mathematical/lsmsvgdefselement.c +74 -0
- data/ext/mathematical/lsmsvgdefselement.h +55 -0
- data/ext/mathematical/lsmsvgdocument.c +288 -0
- data/ext/mathematical/lsmsvgdocument.h +64 -0
- data/ext/mathematical/lsmsvgelement.c +373 -0
- data/ext/mathematical/lsmsvgelement.h +81 -0
- data/ext/mathematical/lsmsvgellipseelement.c +158 -0
- data/ext/mathematical/lsmsvgellipseelement.h +60 -0
- data/ext/mathematical/lsmsvgenums.c +544 -0
- data/ext/mathematical/lsmsvgenums.h +357 -0
- data/ext/mathematical/lsmsvgenumtypes.c +1083 -0
- data/ext/mathematical/lsmsvgenumtypes.h +111 -0
- data/ext/mathematical/lsmsvgfilterblend.c +105 -0
- data/ext/mathematical/lsmsvgfilterblend.h +58 -0
- data/ext/mathematical/lsmsvgfiltercomposite.c +109 -0
- data/ext/mathematical/lsmsvgfiltercomposite.h +58 -0
- data/ext/mathematical/lsmsvgfilterelement.c +266 -0
- data/ext/mathematical/lsmsvgfilterelement.h +66 -0
- data/ext/mathematical/lsmsvgfilterflood.c +86 -0
- data/ext/mathematical/lsmsvgfilterflood.h +55 -0
- data/ext/mathematical/lsmsvgfiltergaussianblur.c +114 -0
- data/ext/mathematical/lsmsvgfiltergaussianblur.h +57 -0
- data/ext/mathematical/lsmsvgfiltermerge.c +98 -0
- data/ext/mathematical/lsmsvgfiltermerge.h +55 -0
- data/ext/mathematical/lsmsvgfiltermergenode.c +87 -0
- data/ext/mathematical/lsmsvgfiltermergenode.h +57 -0
- data/ext/mathematical/lsmsvgfilteroffset.c +112 -0
- data/ext/mathematical/lsmsvgfilteroffset.h +58 -0
- data/ext/mathematical/lsmsvgfilterprimitive.c +168 -0
- data/ext/mathematical/lsmsvgfilterprimitive.h +66 -0
- data/ext/mathematical/lsmsvgfilterspecularlighting.c +127 -0
- data/ext/mathematical/lsmsvgfilterspecularlighting.h +60 -0
- data/ext/mathematical/lsmsvgfiltersurface.c +455 -0
- data/ext/mathematical/lsmsvgfiltersurface.h +66 -0
- data/ext/mathematical/lsmsvgfiltertile.c +102 -0
- data/ext/mathematical/lsmsvgfiltertile.h +57 -0
- data/ext/mathematical/lsmsvggelement.c +73 -0
- data/ext/mathematical/lsmsvggelement.h +55 -0
- data/ext/mathematical/lsmsvggradientelement.c +151 -0
- data/ext/mathematical/lsmsvggradientelement.h +68 -0
- data/ext/mathematical/lsmsvgimageelement.c +261 -0
- data/ext/mathematical/lsmsvgimageelement.h +67 -0
- data/ext/mathematical/lsmsvglength.c +152 -0
- data/ext/mathematical/lsmsvglength.h +65 -0
- data/ext/mathematical/lsmsvglineargradientelement.c +271 -0
- data/ext/mathematical/lsmsvglineargradientelement.h +60 -0
- data/ext/mathematical/lsmsvglineelement.c +153 -0
- data/ext/mathematical/lsmsvglineelement.h +60 -0
- data/ext/mathematical/lsmsvgmarkerelement.c +266 -0
- data/ext/mathematical/lsmsvgmarkerelement.h +74 -0
- data/ext/mathematical/lsmsvgmaskelement.c +232 -0
- data/ext/mathematical/lsmsvgmaskelement.h +64 -0
- data/ext/mathematical/lsmsvgmatrix.c +205 -0
- data/ext/mathematical/lsmsvgmatrix.h +59 -0
- data/ext/mathematical/lsmsvgpathelement.c +115 -0
- data/ext/mathematical/lsmsvgpathelement.h +59 -0
- data/ext/mathematical/lsmsvgpatternelement.c +398 -0
- data/ext/mathematical/lsmsvgpatternelement.h +69 -0
- data/ext/mathematical/lsmsvgpolygonelement.c +106 -0
- data/ext/mathematical/lsmsvgpolygonelement.h +57 -0
- data/ext/mathematical/lsmsvgpolylineelement.c +106 -0
- data/ext/mathematical/lsmsvgpolylineelement.h +57 -0
- data/ext/mathematical/lsmsvgradialgradientelement.c +323 -0
- data/ext/mathematical/lsmsvgradialgradientelement.h +61 -0
- data/ext/mathematical/lsmsvgrectelement.c +184 -0
- data/ext/mathematical/lsmsvgrectelement.h +62 -0
- data/ext/mathematical/lsmsvgstopelement.c +106 -0
- data/ext/mathematical/lsmsvgstopelement.h +57 -0
- data/ext/mathematical/lsmsvgstyle.c +560 -0
- data/ext/mathematical/lsmsvgstyle.h +217 -0
- data/ext/mathematical/lsmsvgsvgelement.c +260 -0
- data/ext/mathematical/lsmsvgsvgelement.h +71 -0
- data/ext/mathematical/lsmsvgswitchelement.c +103 -0
- data/ext/mathematical/lsmsvgswitchelement.h +55 -0
- data/ext/mathematical/lsmsvgsymbolelement.c +74 -0
- data/ext/mathematical/lsmsvgsymbolelement.h +55 -0
- data/ext/mathematical/lsmsvgtextelement.c +203 -0
- data/ext/mathematical/lsmsvgtextelement.h +60 -0
- data/ext/mathematical/lsmsvgtraits.c +1232 -0
- data/ext/mathematical/lsmsvgtraits.h +104 -0
- data/ext/mathematical/lsmsvgtransformable.c +106 -0
- data/ext/mathematical/lsmsvgtransformable.h +54 -0
- data/ext/mathematical/lsmsvgtspanelement.c +174 -0
- data/ext/mathematical/lsmsvgtspanelement.h +60 -0
- data/ext/mathematical/lsmsvgtypes.h +77 -0
- data/ext/mathematical/lsmsvguseelement.c +237 -0
- data/ext/mathematical/lsmsvguseelement.h +69 -0
- data/ext/mathematical/lsmsvgview.c +2583 -0
- data/ext/mathematical/lsmsvgview.h +179 -0
- data/ext/mathematical/lsmtraits.c +119 -0
- data/ext/mathematical/lsmtraits.h +49 -0
- data/ext/mathematical/lsmtypes.h +36 -0
- data/ext/mathematical/lsmutils.c +54 -0
- data/ext/mathematical/lsmutils.h +56 -0
- data/ext/mathematical/mathematical.c +145 -0
- data/ext/mathematical/y.tab.c +6179 -0
- data/ext/mathematical/y.tab.h +389 -0
- data/lib/mathematical/version.rb +1 -1
- data/mathematical.gemspec +8 -6
- data/test/mathematical/basic_test.rb +9 -0
- data/test/mathematical/fixtures/after/brackets_display.html +1 -0
- data/test/mathematical/fixtures/after/compliance_accents.html +17 -0
- data/test/mathematical/fixtures/after/compliance_arrows.html +71 -0
- data/test/mathematical/fixtures/after/compliance_colors.html +4 -0
- data/test/mathematical/fixtures/after/compliance_greek_letters.html +42 -0
- data/test/mathematical/fixtures/after/compliance_large_math.html +19 -0
- data/test/mathematical/fixtures/after/compliance_log_symbols.html +34 -0
- data/test/mathematical/fixtures/after/compliance_operators.html +262 -0
- data/test/mathematical/fixtures/after/dollar_sign_inline.html +1 -0
- data/test/mathematical/fixtures/after/equation_display.html +1 -0
- data/test/mathematical/fixtures/after/multiple_dollar_inline.html +1 -0
- data/test/mathematical/fixtures/after/parens_inline.html +1 -0
- data/test/mathematical/fixtures/before/brackets_display.text +1 -0
- data/test/mathematical/fixtures/before/compliance_accents.text +17 -0
- data/test/mathematical/fixtures/before/compliance_arrows.text +71 -0
- data/test/mathematical/fixtures/before/compliance_colors.text +4 -0
- data/test/mathematical/fixtures/before/compliance_greek_letters.text +42 -0
- data/test/mathematical/fixtures/before/compliance_large_math.text +19 -0
- data/test/mathematical/fixtures/before/compliance_log_symbols.text +34 -0
- data/test/mathematical/fixtures/before/compliance_operators.text +262 -0
- data/test/mathematical/fixtures/before/dollar_sign_inline.text +1 -0
- data/test/mathematical/fixtures/before/equation_display.text +1 -0
- data/test/mathematical/fixtures/before/multiple_dollar_inline.text +1 -0
- data/test/mathematical/fixtures/before/parens_inline.text +1 -0
- data/test/mathematical/fixtures/performance/big_file.text +1767 -0
- data/test/mathematical/fixtures_test.rb +45 -0
- data/test/mathematical/maliciousness_test.rb +45 -0
- data/test/mathematical/performance_test.rb +15 -0
- data/test/test_helper.rb +5 -0
- metadata +301 -14
- data/lib/mathematical.bundle +0 -0
- data/lib/mathematical/mathematical.bundle +0 -0
@@ -0,0 +1,60 @@
|
|
1
|
+
/* Lasem
|
2
|
+
*
|
3
|
+
* Copyright © 2009-2012 Emmanuel Pacaud
|
4
|
+
*
|
5
|
+
* This library is free software; you can redistribute it and/or
|
6
|
+
* modify it under the terms of the GNU Lesser General Public
|
7
|
+
* License as published by the Free Software Foundation; either
|
8
|
+
* version 2 of the License, or (at your option) any later version.
|
9
|
+
*
|
10
|
+
* This library is distributed in the hope that it will be useful,
|
11
|
+
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
12
|
+
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
13
|
+
* Lesser General Public License for more details.
|
14
|
+
*
|
15
|
+
* You should have received a copy of the GNU Lesser General
|
16
|
+
* Public License along with this library; if not, write to the
|
17
|
+
* Free Software Foundation, Inc., 59 Temple Place, Suite 330,
|
18
|
+
* Boston, MA 02111-1307, USA.
|
19
|
+
*
|
20
|
+
* Author:
|
21
|
+
* Emmanuel Pacaud <emmanuel@gnome.org>
|
22
|
+
*/
|
23
|
+
|
24
|
+
#ifndef LSM_SVG_TEXT_ELEMENT_H
|
25
|
+
#define LSM_SVG_TEXT_ELEMENT_H
|
26
|
+
|
27
|
+
#include <lsmsvgtypes.h>
|
28
|
+
#include <lsmsvgtransformable.h>
|
29
|
+
|
30
|
+
G_BEGIN_DECLS
|
31
|
+
|
32
|
+
#define LSM_TYPE_SVG_TEXT_ELEMENT (lsm_svg_text_element_get_type ())
|
33
|
+
#define LSM_SVG_TEXT_ELEMENT(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), LSM_TYPE_SVG_TEXT_ELEMENT, LsmSvgTextElement))
|
34
|
+
#define LSM_SVG_TEXT_ELEMENT_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), LSM_TYPE_SVG_TEXT_ELEMENT, LsmSvgTextElementClass))
|
35
|
+
#define LSM_IS_SVG_TEXT_ELEMENT(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), LSM_TYPE_SVG_TEXT_ELEMENT))
|
36
|
+
#define LSM_IS_SVG_TEXT_ELEMENT_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), LSM_TYPE_SVG_TEXT_ELEMENT))
|
37
|
+
#define LSM_SVG_TEXT_ELEMENT_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS((obj), LSM_TYPE_SVG_TEXT_ELEMENT, LsmSvgTextElementClass))
|
38
|
+
|
39
|
+
typedef struct _LsmSvgTextElementClass LsmSvgTextElementClass;
|
40
|
+
|
41
|
+
struct _LsmSvgTextElement {
|
42
|
+
LsmSvgTransformable base;
|
43
|
+
|
44
|
+
LsmSvgLengthListAttribute x;
|
45
|
+
LsmSvgLengthListAttribute y;
|
46
|
+
LsmSvgLengthListAttribute dx;
|
47
|
+
LsmSvgLengthListAttribute dy;
|
48
|
+
};
|
49
|
+
|
50
|
+
struct _LsmSvgTextElementClass {
|
51
|
+
LsmSvgTransformableClass base_class;
|
52
|
+
};
|
53
|
+
|
54
|
+
GType lsm_svg_text_element_get_type (void);
|
55
|
+
|
56
|
+
LsmDomNode * lsm_svg_text_element_new (void);
|
57
|
+
|
58
|
+
G_END_DECLS
|
59
|
+
|
60
|
+
#endif
|
@@ -0,0 +1,1232 @@
|
|
1
|
+
/* Lasem
|
2
|
+
*
|
3
|
+
* Copyright © 2009 Emmanuel Pacaud
|
4
|
+
*
|
5
|
+
* This library is free software; you can redistribute it and/or
|
6
|
+
* modify it under the terms of the GNU Lesser General Public
|
7
|
+
* License as published by the Free Software Foundation; either
|
8
|
+
* version 2 of the License, or (at your option) any later version.
|
9
|
+
*
|
10
|
+
* This library is distributed in the hope that it will be useful,
|
11
|
+
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
12
|
+
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
13
|
+
* Lesser General Public License for more details.
|
14
|
+
*
|
15
|
+
* You should have received a copy of the GNU Lesser General
|
16
|
+
* Public License along with this library; if not, write to the
|
17
|
+
* Free Software Foundation, Inc., 59 Temple Place, Suite 330,
|
18
|
+
* Boston, MA 02111-1307, USA.
|
19
|
+
*
|
20
|
+
* Author:
|
21
|
+
* Emmanuel Pacaud <emmanuel@gnome.org>
|
22
|
+
*/
|
23
|
+
|
24
|
+
#include <lsmsvgtraits.h>
|
25
|
+
#include <lsmstr.h>
|
26
|
+
#include <lsmsvgcolors.h>
|
27
|
+
#include <math.h>
|
28
|
+
#include <string.h>
|
29
|
+
#include <stdlib.h>
|
30
|
+
|
31
|
+
const LsmSvgColor lsm_svg_color_null = {0.0, 0.0, 0.0};
|
32
|
+
const LsmSvgDashArray lsm_svg_dash_array_null = {0, NULL};
|
33
|
+
|
34
|
+
static gboolean
|
35
|
+
lsm_svg_blending_mode_trait_from_string (LsmTrait *abstract_trait, char *string)
|
36
|
+
{
|
37
|
+
LsmSvgBlendingMode *trait = (LsmSvgBlendingMode *) abstract_trait;
|
38
|
+
|
39
|
+
*trait = lsm_svg_blending_mode_from_string (string);
|
40
|
+
|
41
|
+
return *trait >= 0;
|
42
|
+
}
|
43
|
+
|
44
|
+
static char *
|
45
|
+
lsm_svg_blending_mode_trait_to_string (LsmTrait *abstract_trait)
|
46
|
+
{
|
47
|
+
LsmSvgBlendingMode *trait = (LsmSvgBlendingMode *) abstract_trait;
|
48
|
+
|
49
|
+
return g_strdup (lsm_svg_blending_mode_to_string (*trait));
|
50
|
+
}
|
51
|
+
|
52
|
+
const LsmTraitClass lsm_svg_blending_mode_trait_class = {
|
53
|
+
.size = sizeof (LsmSvgBlendingMode),
|
54
|
+
.from_string = lsm_svg_blending_mode_trait_from_string,
|
55
|
+
.to_string = lsm_svg_blending_mode_trait_to_string
|
56
|
+
};
|
57
|
+
|
58
|
+
static gboolean
|
59
|
+
lsm_svg_comp_op_trait_from_string (LsmTrait *abstract_trait, char *string)
|
60
|
+
{
|
61
|
+
LsmSvgCompOp *trait = (LsmSvgCompOp *) abstract_trait;
|
62
|
+
|
63
|
+
*trait = lsm_svg_comp_op_from_string (string);
|
64
|
+
|
65
|
+
return *trait >= 0;
|
66
|
+
}
|
67
|
+
|
68
|
+
static char *
|
69
|
+
lsm_svg_comp_op_trait_to_string (LsmTrait *abstract_trait)
|
70
|
+
{
|
71
|
+
LsmSvgCompOp *trait = (LsmSvgCompOp *) abstract_trait;
|
72
|
+
|
73
|
+
return g_strdup (lsm_svg_comp_op_to_string (*trait));
|
74
|
+
}
|
75
|
+
|
76
|
+
const LsmTraitClass lsm_svg_comp_op_trait_class = {
|
77
|
+
.size = sizeof (LsmSvgCompOp),
|
78
|
+
.from_string = lsm_svg_comp_op_trait_from_string,
|
79
|
+
.to_string = lsm_svg_comp_op_trait_to_string
|
80
|
+
};
|
81
|
+
|
82
|
+
static gboolean
|
83
|
+
lsm_svg_enable_background_trait_from_string (LsmTrait *abstract_trait, char *string)
|
84
|
+
{
|
85
|
+
LsmSvgEnableBackground *trait = (LsmSvgEnableBackground *) abstract_trait;
|
86
|
+
|
87
|
+
*trait = lsm_svg_enable_background_from_string (string);
|
88
|
+
|
89
|
+
return *trait >= 0;
|
90
|
+
}
|
91
|
+
|
92
|
+
static char *
|
93
|
+
lsm_svg_enable_background_trait_to_string (LsmTrait *abstract_trait)
|
94
|
+
{
|
95
|
+
LsmSvgEnableBackground *trait = (LsmSvgEnableBackground *) abstract_trait;
|
96
|
+
|
97
|
+
return g_strdup (lsm_svg_enable_background_to_string (*trait));
|
98
|
+
}
|
99
|
+
|
100
|
+
const LsmTraitClass lsm_svg_enable_background_trait_class = {
|
101
|
+
.size = sizeof (LsmSvgEnableBackground),
|
102
|
+
.from_string = lsm_svg_enable_background_trait_from_string,
|
103
|
+
.to_string = lsm_svg_enable_background_trait_to_string
|
104
|
+
};
|
105
|
+
|
106
|
+
static gboolean
|
107
|
+
lsm_svg_length_trait_from_string (LsmTrait *abstract_trait, char *string)
|
108
|
+
{
|
109
|
+
LsmSvgLength *svg_length = (LsmSvgLength *) abstract_trait;
|
110
|
+
char *length_type_str;
|
111
|
+
|
112
|
+
svg_length->value_unit = g_ascii_strtod (string, &length_type_str);
|
113
|
+
svg_length->type = lsm_svg_length_type_from_string (length_type_str);
|
114
|
+
|
115
|
+
return length_type_str != string && svg_length->type >= 0;
|
116
|
+
}
|
117
|
+
|
118
|
+
static char *
|
119
|
+
lsm_svg_length_trait_to_string (LsmTrait *abstract_trait)
|
120
|
+
{
|
121
|
+
LsmSvgLength *svg_length = (LsmSvgLength *) abstract_trait;
|
122
|
+
|
123
|
+
return g_strdup_printf ("%g%s",
|
124
|
+
svg_length->value_unit,
|
125
|
+
lsm_svg_length_type_to_string (svg_length->type));
|
126
|
+
}
|
127
|
+
|
128
|
+
const LsmTraitClass lsm_svg_length_trait_class = {
|
129
|
+
.size = sizeof (LsmSvgLength),
|
130
|
+
.from_string = lsm_svg_length_trait_from_string,
|
131
|
+
.to_string = lsm_svg_length_trait_to_string
|
132
|
+
};
|
133
|
+
|
134
|
+
static gboolean
|
135
|
+
lsm_svg_length_list_trait_from_string (LsmTrait *abstract_trait, char *string)
|
136
|
+
{
|
137
|
+
LsmSvgLengthList *length_list = (LsmSvgLengthList *) abstract_trait;
|
138
|
+
unsigned int n_lengths = 1;
|
139
|
+
unsigned int i;
|
140
|
+
gboolean success = FALSE;
|
141
|
+
char *iter = (char *) string;
|
142
|
+
|
143
|
+
g_free (length_list->lengths);
|
144
|
+
length_list->n_lengths = 0;
|
145
|
+
length_list->lengths = NULL;
|
146
|
+
|
147
|
+
while (*iter != '\0') {
|
148
|
+
if (*iter == ',' ||
|
149
|
+
*iter == ' ') {
|
150
|
+
n_lengths++;
|
151
|
+
do {
|
152
|
+
iter++;
|
153
|
+
} while (*iter == ',' ||
|
154
|
+
*iter == ' ');
|
155
|
+
} else
|
156
|
+
iter++;
|
157
|
+
}
|
158
|
+
|
159
|
+
length_list->lengths = g_new (LsmSvgLength, n_lengths);
|
160
|
+
length_list->n_lengths = n_lengths;
|
161
|
+
iter = (char *)string;
|
162
|
+
lsm_str_skip_spaces (&iter);
|
163
|
+
|
164
|
+
for (i = 0; i < n_lengths; i++) {
|
165
|
+
success = lsm_svg_parse_length (&iter, &length_list->lengths[i]);
|
166
|
+
|
167
|
+
if (!success)
|
168
|
+
break;
|
169
|
+
lsm_str_skip_comma_and_spaces (&iter);
|
170
|
+
}
|
171
|
+
|
172
|
+
if (!success) {
|
173
|
+
g_free (length_list->lengths);
|
174
|
+
length_list->lengths = NULL;
|
175
|
+
length_list->n_lengths = 0;
|
176
|
+
}
|
177
|
+
|
178
|
+
return TRUE;
|
179
|
+
}
|
180
|
+
|
181
|
+
static char *
|
182
|
+
lsm_svg_length_list_trait_to_string (LsmTrait *abstract_trait)
|
183
|
+
{
|
184
|
+
g_assert_not_reached ();
|
185
|
+
|
186
|
+
return NULL;
|
187
|
+
}
|
188
|
+
|
189
|
+
static void
|
190
|
+
lsm_svg_length_list_trait_finalize (LsmTrait *abstract_trait)
|
191
|
+
{
|
192
|
+
LsmSvgLengthList *svg_length_list = (LsmSvgLengthList *) abstract_trait;
|
193
|
+
|
194
|
+
g_free (svg_length_list->lengths);
|
195
|
+
svg_length_list->n_lengths = 0;
|
196
|
+
svg_length_list->lengths = NULL;
|
197
|
+
}
|
198
|
+
|
199
|
+
const LsmTraitClass lsm_svg_length_list_trait_class = {
|
200
|
+
.size = sizeof (LsmSvgLengthList),
|
201
|
+
.from_string = lsm_svg_length_list_trait_from_string,
|
202
|
+
.to_string = lsm_svg_length_list_trait_to_string,
|
203
|
+
.finalize = lsm_svg_length_list_trait_finalize
|
204
|
+
};
|
205
|
+
|
206
|
+
static void
|
207
|
+
_init_matrix (LsmSvgMatrix *matrix, LsmSvgTransformType transform, unsigned int n_values, double values[])
|
208
|
+
{
|
209
|
+
switch (transform) {
|
210
|
+
case LSM_SVG_TRANSFORM_TYPE_SCALE:
|
211
|
+
if (n_values == 1) {
|
212
|
+
lsm_svg_matrix_init_scale (matrix, values[0], values[0]);
|
213
|
+
return;
|
214
|
+
} else if (n_values == 2) {
|
215
|
+
lsm_svg_matrix_init_scale (matrix, values[0], values[1]);
|
216
|
+
return;
|
217
|
+
}
|
218
|
+
break;
|
219
|
+
case LSM_SVG_TRANSFORM_TYPE_TRANSLATE:
|
220
|
+
if (n_values == 1) {
|
221
|
+
lsm_svg_matrix_init_translate (matrix, values[0], values[0]);
|
222
|
+
return;
|
223
|
+
} else if (n_values == 2) {
|
224
|
+
lsm_svg_matrix_init_translate (matrix, values[0], values[1]);
|
225
|
+
return;
|
226
|
+
}
|
227
|
+
break;
|
228
|
+
case LSM_SVG_TRANSFORM_TYPE_MATRIX:
|
229
|
+
if (n_values == 6) {
|
230
|
+
lsm_svg_matrix_init (matrix,
|
231
|
+
values[0], values[1],
|
232
|
+
values[2], values[3],
|
233
|
+
values[4], values[5]);
|
234
|
+
return;
|
235
|
+
}
|
236
|
+
break;
|
237
|
+
case LSM_SVG_TRANSFORM_TYPE_ROTATE:
|
238
|
+
if (n_values == 1) {
|
239
|
+
lsm_svg_matrix_init_rotate (matrix, values[0] * M_PI / 180.0);
|
240
|
+
return;
|
241
|
+
} else if (n_values == 3) {
|
242
|
+
LsmSvgMatrix matrix_b;
|
243
|
+
|
244
|
+
lsm_svg_matrix_init_translate (matrix, values[1], values[2]);
|
245
|
+
lsm_svg_matrix_init_rotate (&matrix_b, values[0] * M_PI / 180.0);
|
246
|
+
lsm_svg_matrix_multiply (matrix, &matrix_b, matrix);
|
247
|
+
lsm_svg_matrix_init_translate (&matrix_b, -values[1], -values[2]);
|
248
|
+
lsm_svg_matrix_multiply (matrix, &matrix_b, matrix);
|
249
|
+
return;
|
250
|
+
}
|
251
|
+
break;
|
252
|
+
case LSM_SVG_TRANSFORM_TYPE_SKEW_X:
|
253
|
+
if (n_values == 1) {
|
254
|
+
lsm_svg_matrix_init_skew_x (matrix, values[0] * M_PI / 180.0);
|
255
|
+
return;
|
256
|
+
}
|
257
|
+
break;
|
258
|
+
case LSM_SVG_TRANSFORM_TYPE_SKEW_Y:
|
259
|
+
if (n_values == 1) {
|
260
|
+
lsm_svg_matrix_init_skew_y (matrix, values[0] * M_PI / 180.0);
|
261
|
+
return;
|
262
|
+
}
|
263
|
+
default:
|
264
|
+
break;
|
265
|
+
}
|
266
|
+
|
267
|
+
lsm_svg_matrix_init_identity (matrix);
|
268
|
+
}
|
269
|
+
|
270
|
+
static gboolean
|
271
|
+
lsm_svg_matrix_trait_from_string (LsmTrait *abstract_trait, char *string)
|
272
|
+
{
|
273
|
+
LsmSvgMatrix *matrix = (LsmSvgMatrix *) abstract_trait;
|
274
|
+
|
275
|
+
lsm_svg_matrix_init_identity (matrix);
|
276
|
+
|
277
|
+
while (*string != '\0') {
|
278
|
+
LsmSvgTransformType transform;
|
279
|
+
double values[6];
|
280
|
+
|
281
|
+
lsm_str_skip_spaces (&string);
|
282
|
+
|
283
|
+
if (strncmp (string, "translate", 9) == 0) {
|
284
|
+
transform = LSM_SVG_TRANSFORM_TYPE_TRANSLATE;
|
285
|
+
string += 9;
|
286
|
+
} else if (strncmp (string, "scale", 5) == 0) {
|
287
|
+
transform = LSM_SVG_TRANSFORM_TYPE_SCALE;
|
288
|
+
string += 5;
|
289
|
+
} else if (strncmp (string, "rotate", 6) == 0) {
|
290
|
+
transform = LSM_SVG_TRANSFORM_TYPE_ROTATE;
|
291
|
+
string += 6;
|
292
|
+
} else if (strncmp (string, "matrix", 6) == 0) {
|
293
|
+
transform = LSM_SVG_TRANSFORM_TYPE_MATRIX;
|
294
|
+
string += 6;
|
295
|
+
} else if (strncmp (string, "skewX", 5) == 0) {
|
296
|
+
transform = LSM_SVG_TRANSFORM_TYPE_SKEW_X;
|
297
|
+
string += 5;
|
298
|
+
} else if (strncmp (string, "skewY", 5) == 0) {
|
299
|
+
transform = LSM_SVG_TRANSFORM_TYPE_SKEW_Y;
|
300
|
+
string += 5;
|
301
|
+
} else
|
302
|
+
return FALSE;
|
303
|
+
|
304
|
+
lsm_str_skip_spaces (&string);
|
305
|
+
|
306
|
+
if (*string == '(') {
|
307
|
+
unsigned int n_values = 0;
|
308
|
+
|
309
|
+
string++;
|
310
|
+
|
311
|
+
while (*string != ')' && *string != '\0' && n_values < 6) {
|
312
|
+
lsm_str_skip_comma_and_spaces (&string);
|
313
|
+
|
314
|
+
if (!lsm_str_parse_double (&string, &values[n_values]))
|
315
|
+
break;
|
316
|
+
|
317
|
+
n_values++;
|
318
|
+
}
|
319
|
+
|
320
|
+
lsm_str_skip_comma_and_spaces (&string);
|
321
|
+
|
322
|
+
if (*string == ')') {
|
323
|
+
LsmSvgMatrix new_matrix;
|
324
|
+
|
325
|
+
string++;
|
326
|
+
|
327
|
+
_init_matrix (&new_matrix, transform, n_values, values);
|
328
|
+
|
329
|
+
lsm_svg_matrix_multiply (matrix, &new_matrix, matrix);
|
330
|
+
} else
|
331
|
+
return FALSE;
|
332
|
+
} else
|
333
|
+
return FALSE;
|
334
|
+
}
|
335
|
+
|
336
|
+
return TRUE;
|
337
|
+
}
|
338
|
+
|
339
|
+
static char *
|
340
|
+
lsm_svg_matrix_trait_to_string (LsmTrait *abstract_trait)
|
341
|
+
{
|
342
|
+
LsmSvgMatrix *matrix = (LsmSvgMatrix *) abstract_trait;
|
343
|
+
|
344
|
+
/* TODO smarter serialization, checking for zeros */
|
345
|
+
return g_strdup_printf ("matrix(%g,%g,%g,%g,%g,%g)",
|
346
|
+
matrix->a,
|
347
|
+
matrix->b,
|
348
|
+
matrix->c,
|
349
|
+
matrix->d,
|
350
|
+
matrix->e,
|
351
|
+
matrix->f);
|
352
|
+
}
|
353
|
+
|
354
|
+
const LsmTraitClass lsm_svg_matrix_trait_class = {
|
355
|
+
.size = sizeof (LsmSvgMatrix),
|
356
|
+
.from_string = lsm_svg_matrix_trait_from_string,
|
357
|
+
.to_string = lsm_svg_matrix_trait_to_string
|
358
|
+
};
|
359
|
+
|
360
|
+
static double
|
361
|
+
_hue_to_rgb (double m1, double m2, double h)
|
362
|
+
{
|
363
|
+
if (h < 0)
|
364
|
+
h = h + 1.0;
|
365
|
+
if (h > 1)
|
366
|
+
h = h - 1.0;
|
367
|
+
if (h * 6.0 < 1.0)
|
368
|
+
return m1 + (m2 - m1 ) * h * 6.0;
|
369
|
+
if (h * 2.0 < 1.0)
|
370
|
+
return m2;
|
371
|
+
if (h * 3.0 < 2.0)
|
372
|
+
return m1 + (m2 - m1) * (2.0 / 3.0 - h) * 6.0;
|
373
|
+
|
374
|
+
return m1;
|
375
|
+
}
|
376
|
+
|
377
|
+
static char *
|
378
|
+
_parse_color (char *string,
|
379
|
+
LsmSvgColor *svg_color,
|
380
|
+
LsmSvgPaintType *paint_type)
|
381
|
+
{
|
382
|
+
unsigned int color = 0;
|
383
|
+
|
384
|
+
lsm_str_skip_spaces (&string);
|
385
|
+
|
386
|
+
if (g_strcmp0 (string, "currentColor") == 0) {
|
387
|
+
svg_color->red = -1.0;
|
388
|
+
svg_color->green = -1.0;
|
389
|
+
svg_color->blue = -1.0;
|
390
|
+
|
391
|
+
*paint_type = LSM_SVG_PAINT_TYPE_CURRENT_COLOR;
|
392
|
+
|
393
|
+
string += 12; /* strlen ("current_color") */
|
394
|
+
|
395
|
+
return string;
|
396
|
+
}
|
397
|
+
|
398
|
+
if (*string == '#') {
|
399
|
+
int value, i;
|
400
|
+
string++;
|
401
|
+
|
402
|
+
for (i = 0; i < 6; i++) {
|
403
|
+
if (*string >= '0' && *string <= '9')
|
404
|
+
value = *string - '0';
|
405
|
+
else if (*string >= 'A' && *string <= 'F')
|
406
|
+
value = *string - 'A' + 10;
|
407
|
+
else if (*string >= 'a' && *string <= 'f')
|
408
|
+
value = *string - 'a' + 10;
|
409
|
+
else
|
410
|
+
break;
|
411
|
+
|
412
|
+
color = (color << 4) + value;
|
413
|
+
string++;
|
414
|
+
}
|
415
|
+
|
416
|
+
if (i == 3) {
|
417
|
+
color = ((color & 0xf00) << 8) | ((color & 0x0f0) << 4) | (color & 0x00f);
|
418
|
+
color |= color << 4;
|
419
|
+
} else if (i != 6)
|
420
|
+
color = 0;
|
421
|
+
|
422
|
+
*paint_type = LSM_SVG_PAINT_TYPE_RGB_COLOR;
|
423
|
+
} else if (strncmp (string, "rgb(", 4) == 0) {
|
424
|
+
int i;
|
425
|
+
double value;
|
426
|
+
|
427
|
+
|
428
|
+
string += 4; /* strlen ("rgb(") */
|
429
|
+
|
430
|
+
lsm_str_skip_spaces (&string);
|
431
|
+
|
432
|
+
for (i = 0; i < 3; i++) {
|
433
|
+
if (!lsm_str_parse_double (&string, &value))
|
434
|
+
break;
|
435
|
+
|
436
|
+
if (*string == '%') {
|
437
|
+
value = value * 255.0 / 100.0;
|
438
|
+
string++;
|
439
|
+
}
|
440
|
+
|
441
|
+
if (i < 2)
|
442
|
+
lsm_str_skip_comma_and_spaces (&string);
|
443
|
+
|
444
|
+
color = (color << 8) + (int) (0.5 + CLAMP (value, 0.0, 255.0));
|
445
|
+
}
|
446
|
+
|
447
|
+
lsm_str_skip_spaces (&string);
|
448
|
+
|
449
|
+
if (*string != ')' || i != 3)
|
450
|
+
color = 0;
|
451
|
+
|
452
|
+
*paint_type = LSM_SVG_PAINT_TYPE_RGB_COLOR;
|
453
|
+
} else if (strncmp (string, "hsl(", 4) == 0) {
|
454
|
+
double value[3];
|
455
|
+
int i;
|
456
|
+
|
457
|
+
string += 4; /* strlen ("hsl(") */
|
458
|
+
|
459
|
+
lsm_str_skip_spaces (&string);
|
460
|
+
|
461
|
+
for (i = 0; i < 3; i++) {
|
462
|
+
if (!lsm_str_parse_double (&string, &value[i]))
|
463
|
+
break;
|
464
|
+
|
465
|
+
if (i > 0) {
|
466
|
+
if (*string != '%')
|
467
|
+
break;
|
468
|
+
string++;
|
469
|
+
}
|
470
|
+
|
471
|
+
lsm_str_skip_comma_and_spaces (&string);
|
472
|
+
}
|
473
|
+
|
474
|
+
lsm_str_skip_spaces (&string);
|
475
|
+
|
476
|
+
if (*string == ')' && i == 3) {
|
477
|
+
double m1, m2;
|
478
|
+
double h,s,l;
|
479
|
+
|
480
|
+
h = value[0] / 360.0;
|
481
|
+
s = value[1] / 100.0;
|
482
|
+
l = value[2] / 100.0;
|
483
|
+
|
484
|
+
if (l <= 0.5)
|
485
|
+
m2 = l*(s + 1.0);
|
486
|
+
else
|
487
|
+
m2 = l + s - l * s;
|
488
|
+
m1 = l * 2.0 - m2;
|
489
|
+
|
490
|
+
svg_color->red = _hue_to_rgb (m1, m2, h + 1.0/3.0);
|
491
|
+
svg_color->green = _hue_to_rgb (m1, m2, h);
|
492
|
+
svg_color->blue = _hue_to_rgb (m1, m2, h - 1.0/3.0);
|
493
|
+
|
494
|
+
*paint_type = LSM_SVG_PAINT_TYPE_RGB_COLOR;
|
495
|
+
|
496
|
+
return string;
|
497
|
+
}
|
498
|
+
} else if (g_strcmp0 (string, "none") != 0) {
|
499
|
+
color = lsm_svg_color_from_string (string);
|
500
|
+
|
501
|
+
*paint_type = LSM_SVG_PAINT_TYPE_RGB_COLOR;
|
502
|
+
} else {
|
503
|
+
*paint_type = LSM_SVG_PAINT_TYPE_NONE;
|
504
|
+
}
|
505
|
+
|
506
|
+
svg_color->red = (double) ((color & 0xff0000) >> 16) / 255.0;
|
507
|
+
svg_color->green = (double) ((color & 0x00ff00) >> 8) / 255.0;
|
508
|
+
svg_color->blue = (double) (color & 0x0000ff) / 255.0;
|
509
|
+
|
510
|
+
return string;
|
511
|
+
}
|
512
|
+
|
513
|
+
static gboolean
|
514
|
+
lsm_svg_paint_trait_from_string (LsmTrait *abstract_trait, char *string)
|
515
|
+
{
|
516
|
+
LsmSvgPaint *paint = (LsmSvgPaint *) abstract_trait;
|
517
|
+
LsmSvgPaintType paint_type;
|
518
|
+
|
519
|
+
g_free (paint->url);
|
520
|
+
|
521
|
+
if (strncmp (string, "url(#", 5) == 0) {
|
522
|
+
unsigned int length;
|
523
|
+
|
524
|
+
length = 5;
|
525
|
+
while (string[length] != ')')
|
526
|
+
length++;
|
527
|
+
length++;
|
528
|
+
|
529
|
+
paint->url = g_new (char, length);
|
530
|
+
if (paint->url != NULL) {
|
531
|
+
memcpy (paint->url, string, length - 1);
|
532
|
+
paint->url[length - 1] = '\0';
|
533
|
+
}
|
534
|
+
string += length;
|
535
|
+
} else {
|
536
|
+
paint->url = NULL;
|
537
|
+
}
|
538
|
+
|
539
|
+
string = _parse_color (string, &paint->color, &paint_type);
|
540
|
+
|
541
|
+
if (paint->url != NULL)
|
542
|
+
switch (paint_type) {
|
543
|
+
case LSM_SVG_PAINT_TYPE_RGB_COLOR:
|
544
|
+
paint_type = LSM_SVG_PAINT_TYPE_URI_RGB_COLOR;
|
545
|
+
break;
|
546
|
+
case LSM_SVG_PAINT_TYPE_CURRENT_COLOR:
|
547
|
+
paint_type = LSM_SVG_PAINT_TYPE_URI_CURRENT_COLOR;
|
548
|
+
break;
|
549
|
+
case LSM_SVG_PAINT_TYPE_NONE:
|
550
|
+
paint_type = LSM_SVG_PAINT_TYPE_URI;
|
551
|
+
break;
|
552
|
+
case LSM_SVG_PAINT_TYPE_RGB_COLOR_ICC_COLOR:
|
553
|
+
paint_type = LSM_SVG_PAINT_TYPE_URI_RGB_COLOR_ICC_COLOR;
|
554
|
+
break;
|
555
|
+
default:
|
556
|
+
paint_type = LSM_SVG_PAINT_TYPE_URI;
|
557
|
+
break;
|
558
|
+
}
|
559
|
+
|
560
|
+
paint->type = paint_type;
|
561
|
+
|
562
|
+
/* TODO better syntax error check */
|
563
|
+
|
564
|
+
return TRUE;
|
565
|
+
}
|
566
|
+
|
567
|
+
static char *
|
568
|
+
lsm_svg_paint_trait_to_string (LsmTrait *abstract_trait)
|
569
|
+
{
|
570
|
+
LsmSvgPaint *paint = (LsmSvgPaint *) abstract_trait;
|
571
|
+
|
572
|
+
if (paint->color.red < 0.0 || paint->color.green < 0.0 || paint->color.blue < 0.0)
|
573
|
+
return g_strdup ("currentColor");
|
574
|
+
|
575
|
+
/* FIXME */
|
576
|
+
if (paint->url != NULL)
|
577
|
+
return g_strdup (paint->url);
|
578
|
+
|
579
|
+
return g_strdup_printf ("rgb(%g%%,%g%%,%g%%)",
|
580
|
+
100.0 * paint->color.red,
|
581
|
+
100.0 * paint->color.green,
|
582
|
+
100.0 * paint->color.blue);
|
583
|
+
}
|
584
|
+
|
585
|
+
const LsmTraitClass lsm_svg_paint_trait_class = {
|
586
|
+
.size = sizeof (LsmSvgPaint),
|
587
|
+
.from_string = lsm_svg_paint_trait_from_string,
|
588
|
+
.to_string = lsm_svg_paint_trait_to_string
|
589
|
+
};
|
590
|
+
|
591
|
+
static gboolean
|
592
|
+
lsm_svg_fill_rule_trait_from_string (LsmTrait *abstract_trait, char *string)
|
593
|
+
{
|
594
|
+
LsmSvgFillRule *trait = (LsmSvgFillRule *) abstract_trait;
|
595
|
+
|
596
|
+
*trait = lsm_svg_fill_rule_from_string (string);
|
597
|
+
|
598
|
+
return *trait >= 0;
|
599
|
+
}
|
600
|
+
|
601
|
+
static char *
|
602
|
+
lsm_svg_fill_rule_trait_to_string (LsmTrait *abstract_trait)
|
603
|
+
{
|
604
|
+
LsmSvgFillRule *trait = (LsmSvgFillRule *) abstract_trait;
|
605
|
+
|
606
|
+
return g_strdup (lsm_svg_fill_rule_to_string (*trait));
|
607
|
+
}
|
608
|
+
|
609
|
+
const LsmTraitClass lsm_svg_fill_rule_trait_class = {
|
610
|
+
.size = sizeof (LsmSvgFillRule),
|
611
|
+
.from_string = lsm_svg_fill_rule_trait_from_string,
|
612
|
+
.to_string = lsm_svg_fill_rule_trait_to_string
|
613
|
+
};
|
614
|
+
|
615
|
+
static gboolean
|
616
|
+
lsm_svg_font_style_trait_from_string (LsmTrait *abstract_trait, char *string)
|
617
|
+
{
|
618
|
+
LsmSvgFontStyle *trait = (LsmSvgFontStyle *) abstract_trait;
|
619
|
+
|
620
|
+
*trait = lsm_svg_font_style_from_string (string);
|
621
|
+
|
622
|
+
return *trait >= 0;
|
623
|
+
}
|
624
|
+
|
625
|
+
static char *
|
626
|
+
lsm_svg_font_style_trait_to_string (LsmTrait *abstract_trait)
|
627
|
+
{
|
628
|
+
LsmSvgFontStyle *trait = (LsmSvgFontStyle *) abstract_trait;
|
629
|
+
|
630
|
+
return g_strdup (lsm_svg_font_style_to_string (*trait));
|
631
|
+
}
|
632
|
+
|
633
|
+
const LsmTraitClass lsm_svg_font_style_trait_class = {
|
634
|
+
.size = sizeof (LsmSvgFontStyle),
|
635
|
+
.from_string = lsm_svg_font_style_trait_from_string,
|
636
|
+
.to_string = lsm_svg_font_style_trait_to_string
|
637
|
+
};
|
638
|
+
|
639
|
+
static gboolean
|
640
|
+
lsm_svg_font_stretch_trait_from_string (LsmTrait *abstract_trait, char *string)
|
641
|
+
{
|
642
|
+
LsmSvgFontStretch *trait = (LsmSvgFontStretch *) abstract_trait;
|
643
|
+
|
644
|
+
*trait = lsm_svg_font_stretch_from_string (string);
|
645
|
+
|
646
|
+
return *trait >= 0;
|
647
|
+
}
|
648
|
+
|
649
|
+
static char *
|
650
|
+
lsm_svg_font_stretch_trait_to_string (LsmTrait *abstract_trait)
|
651
|
+
{
|
652
|
+
LsmSvgFontStretch *trait = (LsmSvgFontStretch *) abstract_trait;
|
653
|
+
|
654
|
+
return g_strdup (lsm_svg_font_stretch_to_string (*trait));
|
655
|
+
}
|
656
|
+
|
657
|
+
const LsmTraitClass lsm_svg_font_stretch_trait_class = {
|
658
|
+
.size = sizeof (LsmSvgFontStretch),
|
659
|
+
.from_string = lsm_svg_font_stretch_trait_from_string,
|
660
|
+
.to_string = lsm_svg_font_stretch_trait_to_string
|
661
|
+
};
|
662
|
+
|
663
|
+
static gboolean
|
664
|
+
lsm_svg_font_weight_trait_from_string (LsmTrait *abstract_trait, char *string)
|
665
|
+
{
|
666
|
+
LsmSvgFontWeight *trait = (LsmSvgFontWeight *) abstract_trait;
|
667
|
+
|
668
|
+
*trait = lsm_svg_font_weight_from_string (string);
|
669
|
+
|
670
|
+
if (*trait < 0)
|
671
|
+
*trait = strtol (string, NULL, 10);
|
672
|
+
|
673
|
+
return *trait >= 100 && *trait <= 1000;
|
674
|
+
}
|
675
|
+
|
676
|
+
static char *
|
677
|
+
lsm_svg_font_weight_trait_to_string (LsmTrait *abstract_trait)
|
678
|
+
{
|
679
|
+
LsmSvgFontWeight *trait = (LsmSvgFontWeight *) abstract_trait;
|
680
|
+
const char *string;
|
681
|
+
|
682
|
+
string = lsm_svg_font_weight_to_string (*trait);
|
683
|
+
|
684
|
+
if (string != NULL)
|
685
|
+
return g_strdup (string);
|
686
|
+
|
687
|
+
return g_strdup_printf ("%d", *trait);
|
688
|
+
}
|
689
|
+
|
690
|
+
const LsmTraitClass lsm_svg_font_weight_trait_class = {
|
691
|
+
.size = sizeof (LsmSvgFontWeight),
|
692
|
+
.from_string = lsm_svg_font_weight_trait_from_string,
|
693
|
+
.to_string = lsm_svg_font_weight_trait_to_string
|
694
|
+
};
|
695
|
+
|
696
|
+
static gboolean
|
697
|
+
lsm_svg_line_join_trait_from_string (LsmTrait *abstract_trait, char *string)
|
698
|
+
{
|
699
|
+
LsmSvgLineJoin *trait = (LsmSvgLineJoin *) abstract_trait;
|
700
|
+
|
701
|
+
*trait = lsm_svg_line_join_from_string (string);
|
702
|
+
|
703
|
+
return *trait >= 0;
|
704
|
+
}
|
705
|
+
|
706
|
+
static char *
|
707
|
+
lsm_svg_line_join_trait_to_string (LsmTrait *abstract_trait)
|
708
|
+
{
|
709
|
+
LsmSvgLineJoin *trait = (LsmSvgLineJoin *) abstract_trait;
|
710
|
+
|
711
|
+
return g_strdup (lsm_svg_line_join_to_string (*trait));
|
712
|
+
}
|
713
|
+
|
714
|
+
const LsmTraitClass lsm_svg_line_join_trait_class = {
|
715
|
+
.size = sizeof (LsmSvgLineJoin),
|
716
|
+
.from_string = lsm_svg_line_join_trait_from_string,
|
717
|
+
.to_string = lsm_svg_line_join_trait_to_string
|
718
|
+
};
|
719
|
+
|
720
|
+
static gboolean
|
721
|
+
lsm_svg_line_cap_trait_from_string (LsmTrait *abstract_trait, char *string)
|
722
|
+
{
|
723
|
+
LsmSvgLineCap *trait = (LsmSvgLineCap *) abstract_trait;
|
724
|
+
|
725
|
+
*trait = lsm_svg_line_cap_from_string (string);
|
726
|
+
|
727
|
+
return *trait >= 0;
|
728
|
+
}
|
729
|
+
|
730
|
+
static char *
|
731
|
+
lsm_svg_line_cap_trait_to_string (LsmTrait *abstract_trait)
|
732
|
+
{
|
733
|
+
LsmSvgLineCap *trait = (LsmSvgLineCap *) abstract_trait;
|
734
|
+
|
735
|
+
return g_strdup (lsm_svg_line_cap_to_string (*trait));
|
736
|
+
}
|
737
|
+
|
738
|
+
const LsmTraitClass lsm_svg_line_cap_trait_class = {
|
739
|
+
.size = sizeof (LsmSvgLineCap),
|
740
|
+
.from_string = lsm_svg_line_cap_trait_from_string,
|
741
|
+
.to_string = lsm_svg_line_cap_trait_to_string
|
742
|
+
};
|
743
|
+
|
744
|
+
LsmSvgDashArray *
|
745
|
+
lsm_svg_dash_array_new (unsigned int n_dashes)
|
746
|
+
{
|
747
|
+
LsmSvgDashArray *array;
|
748
|
+
|
749
|
+
g_return_val_if_fail (n_dashes > 0, (LsmSvgDashArray *) &lsm_svg_dash_array_null);
|
750
|
+
|
751
|
+
array = g_new (LsmSvgDashArray, 1);
|
752
|
+
array->n_dashes = n_dashes;
|
753
|
+
array->dashes = g_new (LsmSvgLength, n_dashes);
|
754
|
+
|
755
|
+
return array;
|
756
|
+
}
|
757
|
+
|
758
|
+
void
|
759
|
+
lsm_svg_dash_array_free (LsmSvgDashArray *array)
|
760
|
+
{
|
761
|
+
if (array == NULL || array == &lsm_svg_dash_array_null)
|
762
|
+
return;
|
763
|
+
|
764
|
+
g_free (array->dashes);
|
765
|
+
g_free (array);
|
766
|
+
}
|
767
|
+
|
768
|
+
LsmSvgDashArray *
|
769
|
+
lsm_svg_dash_array_duplicate (const LsmSvgDashArray *origin)
|
770
|
+
{
|
771
|
+
LsmSvgDashArray *duplicate;
|
772
|
+
|
773
|
+
if (origin == NULL || origin == &lsm_svg_dash_array_null)
|
774
|
+
return (LsmSvgDashArray *) &lsm_svg_dash_array_null;
|
775
|
+
|
776
|
+
duplicate = lsm_svg_dash_array_new (origin->n_dashes);
|
777
|
+
|
778
|
+
if (duplicate != &lsm_svg_dash_array_null)
|
779
|
+
memcpy (duplicate->dashes, origin->dashes, sizeof (LsmSvgLength) * origin->n_dashes);
|
780
|
+
|
781
|
+
return duplicate;
|
782
|
+
}
|
783
|
+
|
784
|
+
static gboolean
|
785
|
+
lsm_svg_dash_array_trait_from_string (LsmTrait *abstract_trait, char *string)
|
786
|
+
{
|
787
|
+
LsmSvgDashArray *dash_array = (LsmSvgDashArray *) abstract_trait;
|
788
|
+
unsigned int n_dashes = 1;
|
789
|
+
double value;
|
790
|
+
double sum = 0.0;
|
791
|
+
gboolean is_error = FALSE;
|
792
|
+
|
793
|
+
g_free (dash_array->dashes);
|
794
|
+
dash_array->n_dashes = 0;
|
795
|
+
dash_array->dashes = NULL;
|
796
|
+
|
797
|
+
if (strcmp (string, "none") != 0 &&
|
798
|
+
strcmp (string, "inherit")) {
|
799
|
+
char *iter = (char *) string;
|
800
|
+
unsigned int i;
|
801
|
+
|
802
|
+
while (*iter != '\0') {
|
803
|
+
if (*iter == ',' ||
|
804
|
+
*iter == ' ') {
|
805
|
+
n_dashes++;
|
806
|
+
do {
|
807
|
+
iter++;
|
808
|
+
} while (*iter == ',' ||
|
809
|
+
*iter == ' ');
|
810
|
+
} else
|
811
|
+
iter++;
|
812
|
+
}
|
813
|
+
|
814
|
+
if (n_dashes > 0) {
|
815
|
+
LsmSvgLength length;
|
816
|
+
|
817
|
+
dash_array->n_dashes = n_dashes;
|
818
|
+
dash_array->dashes = g_new (LsmSvgLength, n_dashes);
|
819
|
+
|
820
|
+
iter = (char *)string;
|
821
|
+
lsm_str_skip_spaces (&iter);
|
822
|
+
|
823
|
+
for (i = 0; i < n_dashes; i++) {
|
824
|
+
if (lsm_str_parse_double (&iter, &length.value_unit)) {
|
825
|
+
length.type = lsm_svg_length_type_from_string (iter);
|
826
|
+
dash_array->dashes[i] = length;
|
827
|
+
while (*iter != '\0' && *iter != ' ' && *iter != ',')
|
828
|
+
iter ++;
|
829
|
+
} else {
|
830
|
+
dash_array->dashes[i].value_unit = 0.0;
|
831
|
+
dash_array->dashes[i].type = LSM_SVG_LENGTH_TYPE_NUMBER;
|
832
|
+
}
|
833
|
+
lsm_str_skip_comma_and_spaces (&iter);
|
834
|
+
|
835
|
+
value = dash_array->dashes[i].value_unit;
|
836
|
+
if (value < 0.0) {
|
837
|
+
is_error = TRUE;
|
838
|
+
break;
|
839
|
+
}
|
840
|
+
sum += value;
|
841
|
+
}
|
842
|
+
}
|
843
|
+
|
844
|
+
if (is_error || sum <= 0.0) {
|
845
|
+
g_free (dash_array->dashes);
|
846
|
+
dash_array->n_dashes = 0;
|
847
|
+
dash_array->dashes = NULL;
|
848
|
+
|
849
|
+
return !is_error;
|
850
|
+
}
|
851
|
+
}
|
852
|
+
|
853
|
+
return TRUE;
|
854
|
+
}
|
855
|
+
|
856
|
+
static char *
|
857
|
+
lsm_svg_dash_array_trait_to_string (LsmTrait *abstract_trait)
|
858
|
+
{
|
859
|
+
g_assert_not_reached ();
|
860
|
+
|
861
|
+
return NULL;
|
862
|
+
}
|
863
|
+
|
864
|
+
static void
|
865
|
+
lsm_svg_dash_array_trait_finalize (LsmTrait *abstract_trait)
|
866
|
+
{
|
867
|
+
LsmSvgDashArray *dash_array = (LsmSvgDashArray *) abstract_trait;
|
868
|
+
|
869
|
+
g_free (dash_array->dashes);
|
870
|
+
dash_array->n_dashes = 0;
|
871
|
+
dash_array->dashes = NULL;
|
872
|
+
}
|
873
|
+
|
874
|
+
const LsmTraitClass lsm_svg_dash_array_trait_class = {
|
875
|
+
.size = sizeof (LsmSvgDashArray),
|
876
|
+
.from_string = lsm_svg_dash_array_trait_from_string,
|
877
|
+
.to_string = lsm_svg_dash_array_trait_to_string,
|
878
|
+
.finalize = lsm_svg_dash_array_trait_finalize
|
879
|
+
};
|
880
|
+
|
881
|
+
static gboolean
|
882
|
+
lsm_svg_display_trait_from_string (LsmTrait *abstract_trait, char *string)
|
883
|
+
{
|
884
|
+
LsmSvgDisplay *trait = (LsmSvgDisplay *) abstract_trait;
|
885
|
+
|
886
|
+
*trait = lsm_svg_display_from_string (string);
|
887
|
+
|
888
|
+
return *trait >= 0;
|
889
|
+
}
|
890
|
+
|
891
|
+
static char *
|
892
|
+
lsm_svg_display_trait_to_string (LsmTrait *abstract_trait)
|
893
|
+
{
|
894
|
+
LsmSvgDisplay *trait = (LsmSvgDisplay *) abstract_trait;
|
895
|
+
|
896
|
+
return g_strdup (lsm_svg_display_to_string (*trait));
|
897
|
+
}
|
898
|
+
|
899
|
+
const LsmTraitClass lsm_svg_display_trait_class = {
|
900
|
+
.size = sizeof (LsmSvgDisplay),
|
901
|
+
.from_string = lsm_svg_display_trait_from_string,
|
902
|
+
.to_string = lsm_svg_display_trait_to_string
|
903
|
+
};
|
904
|
+
|
905
|
+
static gboolean
|
906
|
+
lsm_svg_color_trait_from_string (LsmTrait *abstract_trait, char *string)
|
907
|
+
{
|
908
|
+
LsmSvgColor *color = (LsmSvgColor *) abstract_trait;
|
909
|
+
LsmSvgPaintType paint_type;
|
910
|
+
|
911
|
+
_parse_color (string, color, &paint_type);
|
912
|
+
|
913
|
+
/* TODO Better error check */
|
914
|
+
|
915
|
+
return TRUE;
|
916
|
+
}
|
917
|
+
|
918
|
+
static char *
|
919
|
+
lsm_svg_color_trait_to_string (LsmTrait *abstract_trait)
|
920
|
+
{
|
921
|
+
LsmSvgColor *color = (LsmSvgColor *) abstract_trait;
|
922
|
+
|
923
|
+
if (color->red < 0.0 || color->green < 0.0 || color->blue < 0.0)
|
924
|
+
return g_strdup ("currentColor");
|
925
|
+
|
926
|
+
return g_strdup_printf ("rgb(%g%%,%g%%,%g%%)",
|
927
|
+
100.0 * color->red,
|
928
|
+
100.0 * color->green,
|
929
|
+
100.0 * color->blue);
|
930
|
+
}
|
931
|
+
|
932
|
+
const LsmTraitClass lsm_svg_color_trait_class = {
|
933
|
+
.size = sizeof (LsmSvgColor),
|
934
|
+
.from_string = lsm_svg_color_trait_from_string,
|
935
|
+
.to_string = lsm_svg_color_trait_to_string
|
936
|
+
};
|
937
|
+
|
938
|
+
static gboolean
|
939
|
+
lsm_svg_marker_units_trait_from_string (LsmTrait *abstract_trait, char *string)
|
940
|
+
{
|
941
|
+
LsmSvgMarkerUnits *trait = (LsmSvgMarkerUnits *) abstract_trait;
|
942
|
+
|
943
|
+
*trait = lsm_svg_marker_units_from_string (string);
|
944
|
+
|
945
|
+
return *trait >= 0;
|
946
|
+
}
|
947
|
+
|
948
|
+
static char *
|
949
|
+
lsm_svg_marker_units_trait_to_string (LsmTrait *abstract_trait)
|
950
|
+
{
|
951
|
+
LsmSvgMarkerUnits *trait = (LsmSvgMarkerUnits *) abstract_trait;
|
952
|
+
|
953
|
+
return g_strdup (lsm_svg_marker_units_to_string (*trait));
|
954
|
+
}
|
955
|
+
|
956
|
+
const LsmTraitClass lsm_svg_marker_units_trait_class = {
|
957
|
+
.size = sizeof (LsmSvgMarkerUnits),
|
958
|
+
.from_string = lsm_svg_marker_units_trait_from_string,
|
959
|
+
.to_string = lsm_svg_marker_units_trait_to_string
|
960
|
+
};
|
961
|
+
|
962
|
+
static gboolean
|
963
|
+
lsm_svg_pattern_units_trait_from_string (LsmTrait *abstract_trait, char *string)
|
964
|
+
{
|
965
|
+
LsmSvgPatternUnits *trait = (LsmSvgPatternUnits *) abstract_trait;
|
966
|
+
|
967
|
+
*trait = lsm_svg_pattern_units_from_string (string);
|
968
|
+
|
969
|
+
return *trait >= 0;
|
970
|
+
}
|
971
|
+
|
972
|
+
static char *
|
973
|
+
lsm_svg_pattern_units_trait_to_string (LsmTrait *abstract_trait)
|
974
|
+
{
|
975
|
+
LsmSvgPatternUnits *trait = (LsmSvgPatternUnits *) abstract_trait;
|
976
|
+
|
977
|
+
return g_strdup (lsm_svg_pattern_units_to_string (*trait));
|
978
|
+
}
|
979
|
+
|
980
|
+
const LsmTraitClass lsm_svg_pattern_units_trait_class = {
|
981
|
+
.size = sizeof (LsmSvgPatternUnits),
|
982
|
+
.from_string = lsm_svg_pattern_units_trait_from_string,
|
983
|
+
.to_string = lsm_svg_pattern_units_trait_to_string
|
984
|
+
};
|
985
|
+
|
986
|
+
static gboolean
|
987
|
+
lsm_svg_preserve_aspect_ratio_trait_from_string (LsmTrait *abstract_trait, char *string)
|
988
|
+
{
|
989
|
+
LsmSvgPreserveAspectRatio *trait = (LsmSvgPreserveAspectRatio *) abstract_trait;
|
990
|
+
|
991
|
+
char **tokens;
|
992
|
+
unsigned int i = 0;
|
993
|
+
|
994
|
+
tokens = g_strsplit (string, " ", -1);
|
995
|
+
|
996
|
+
if (tokens[i] != NULL && strcmp (tokens[i], "defer") == 0) {
|
997
|
+
trait->defer = TRUE;
|
998
|
+
i++;
|
999
|
+
} else
|
1000
|
+
trait->defer = FALSE;
|
1001
|
+
|
1002
|
+
if (tokens[i] != NULL) {
|
1003
|
+
trait->align = lsm_svg_align_from_string (tokens[i]);
|
1004
|
+
i++;
|
1005
|
+
if (tokens[i] != NULL)
|
1006
|
+
trait->meet_or_slice = lsm_svg_meet_or_slice_from_string (tokens[i]);
|
1007
|
+
else
|
1008
|
+
trait->meet_or_slice = LSM_SVG_MEET_OR_SLICE_MEET;
|
1009
|
+
} else trait->align = LSM_SVG_ALIGN_X_MID_Y_MID;
|
1010
|
+
|
1011
|
+
g_strfreev (tokens);
|
1012
|
+
|
1013
|
+
/* TODO Better error check */
|
1014
|
+
|
1015
|
+
return TRUE;
|
1016
|
+
}
|
1017
|
+
|
1018
|
+
static char *
|
1019
|
+
lsm_svg_preserve_aspect_ratio_trait_to_string (LsmTrait *abstract_trait)
|
1020
|
+
{
|
1021
|
+
LsmSvgPreserveAspectRatio *trait = (LsmSvgPreserveAspectRatio *) abstract_trait;
|
1022
|
+
|
1023
|
+
return g_strdup_printf ("%s%s %s", trait->defer ? "defer " : "",
|
1024
|
+
lsm_svg_align_to_string (trait->align),
|
1025
|
+
lsm_svg_meet_or_slice_to_string (trait->meet_or_slice));
|
1026
|
+
}
|
1027
|
+
|
1028
|
+
const LsmTraitClass lsm_svg_preserve_aspect_ratio_trait_class = {
|
1029
|
+
.size = sizeof (LsmSvgPreserveAspectRatio),
|
1030
|
+
.from_string = lsm_svg_preserve_aspect_ratio_trait_from_string,
|
1031
|
+
.to_string = lsm_svg_preserve_aspect_ratio_trait_to_string
|
1032
|
+
};
|
1033
|
+
|
1034
|
+
static gboolean
|
1035
|
+
lsm_svg_spread_method_trait_from_string (LsmTrait *abstract_trait, char *string)
|
1036
|
+
{
|
1037
|
+
LsmSvgSpreadMethod *trait = (LsmSvgSpreadMethod *) abstract_trait;
|
1038
|
+
|
1039
|
+
*trait = lsm_svg_spread_method_from_string (string);
|
1040
|
+
|
1041
|
+
return *trait >= 0;
|
1042
|
+
}
|
1043
|
+
|
1044
|
+
static char *
|
1045
|
+
lsm_svg_spread_method_trait_to_string (LsmTrait *abstract_trait)
|
1046
|
+
{
|
1047
|
+
LsmSvgSpreadMethod *trait = (LsmSvgSpreadMethod *) abstract_trait;
|
1048
|
+
|
1049
|
+
return g_strdup (lsm_svg_spread_method_to_string (*trait));
|
1050
|
+
}
|
1051
|
+
|
1052
|
+
const LsmTraitClass lsm_svg_spread_method_trait_class = {
|
1053
|
+
.size = sizeof (LsmSvgSpreadMethod),
|
1054
|
+
.from_string = lsm_svg_spread_method_trait_from_string,
|
1055
|
+
.to_string = lsm_svg_spread_method_trait_to_string
|
1056
|
+
};
|
1057
|
+
|
1058
|
+
static gboolean
|
1059
|
+
lsm_svg_angle_trait_from_string (LsmTrait *abstract_trait, char *string)
|
1060
|
+
{
|
1061
|
+
LsmSvgAngle *trait = (LsmSvgAngle *) abstract_trait;
|
1062
|
+
char *end_ptr;
|
1063
|
+
|
1064
|
+
if (g_strcmp0 (string, "auto") == 0) {
|
1065
|
+
trait->type = LSM_SVG_ANGLE_TYPE_AUTO;
|
1066
|
+
trait->angle = 0.0;
|
1067
|
+
|
1068
|
+
return TRUE;
|
1069
|
+
}
|
1070
|
+
|
1071
|
+
trait->type = LSM_SVG_ANGLE_TYPE_FIXED;
|
1072
|
+
trait->angle = g_ascii_strtod (string, &end_ptr);
|
1073
|
+
|
1074
|
+
return end_ptr != string;
|
1075
|
+
}
|
1076
|
+
|
1077
|
+
static char *
|
1078
|
+
lsm_svg_angle_trait_to_string (LsmTrait *abstract_trait)
|
1079
|
+
{
|
1080
|
+
LsmSvgAngle *trait = (LsmSvgAngle *) abstract_trait;
|
1081
|
+
|
1082
|
+
if (trait->type == LSM_SVG_ANGLE_TYPE_AUTO)
|
1083
|
+
return g_strdup ("auto");
|
1084
|
+
|
1085
|
+
return g_strdup_printf ("%g", trait->angle);
|
1086
|
+
}
|
1087
|
+
|
1088
|
+
const LsmTraitClass lsm_svg_angle_trait_class = {
|
1089
|
+
.size = sizeof (LsmSvgAngle),
|
1090
|
+
.from_string = lsm_svg_angle_trait_from_string,
|
1091
|
+
.to_string = lsm_svg_angle_trait_to_string
|
1092
|
+
};
|
1093
|
+
|
1094
|
+
static gboolean
|
1095
|
+
lsm_svg_text_anchor_trait_from_string (LsmTrait *abstract_trait, char *string)
|
1096
|
+
{
|
1097
|
+
LsmSvgTextAnchor *trait = (LsmSvgTextAnchor *) abstract_trait;
|
1098
|
+
|
1099
|
+
*trait = lsm_svg_text_anchor_from_string (string);
|
1100
|
+
|
1101
|
+
return *trait >= 0;
|
1102
|
+
}
|
1103
|
+
|
1104
|
+
static char *
|
1105
|
+
lsm_svg_text_anchor_trait_to_string (LsmTrait *abstract_trait)
|
1106
|
+
{
|
1107
|
+
LsmSvgTextAnchor *trait = (LsmSvgTextAnchor *) abstract_trait;
|
1108
|
+
|
1109
|
+
return g_strdup (lsm_svg_text_anchor_to_string (*trait));
|
1110
|
+
}
|
1111
|
+
|
1112
|
+
const LsmTraitClass lsm_svg_text_anchor_trait_class = {
|
1113
|
+
.size = sizeof (LsmSvgTextAnchor),
|
1114
|
+
.from_string = lsm_svg_text_anchor_trait_from_string,
|
1115
|
+
.to_string = lsm_svg_text_anchor_trait_to_string
|
1116
|
+
};
|
1117
|
+
|
1118
|
+
static gboolean
|
1119
|
+
lsm_svg_visibility_trait_from_string (LsmTrait *abstract_trait, char *string)
|
1120
|
+
{
|
1121
|
+
LsmSvgVisibility *trait = (LsmSvgVisibility *) abstract_trait;
|
1122
|
+
|
1123
|
+
*trait = lsm_svg_visibility_from_string (string);
|
1124
|
+
|
1125
|
+
return *trait >= 0;
|
1126
|
+
}
|
1127
|
+
|
1128
|
+
static char *
|
1129
|
+
lsm_svg_visibility_trait_to_string (LsmTrait *abstract_trait)
|
1130
|
+
{
|
1131
|
+
LsmSvgVisibility *trait = (LsmSvgVisibility *) abstract_trait;
|
1132
|
+
|
1133
|
+
return g_strdup (lsm_svg_visibility_to_string (*trait));
|
1134
|
+
}
|
1135
|
+
|
1136
|
+
const LsmTraitClass lsm_svg_visibility_trait_class = {
|
1137
|
+
.size = sizeof (LsmSvgVisibility),
|
1138
|
+
.from_string = lsm_svg_visibility_trait_from_string,
|
1139
|
+
.to_string = lsm_svg_visibility_trait_to_string
|
1140
|
+
};
|
1141
|
+
|
1142
|
+
static gboolean
|
1143
|
+
lsm_svg_one_or_two_double_trait_from_string (LsmTrait *abstract_trait, char *string)
|
1144
|
+
{
|
1145
|
+
LsmSvgOneOrTwoDouble *trait = (LsmSvgOneOrTwoDouble *) abstract_trait;
|
1146
|
+
char *end_ptr;
|
1147
|
+
|
1148
|
+
trait->a = g_ascii_strtod (string, &end_ptr);
|
1149
|
+
if (end_ptr == string) {
|
1150
|
+
trait->b = 0.0;
|
1151
|
+
return FALSE;
|
1152
|
+
}
|
1153
|
+
|
1154
|
+
string = end_ptr;
|
1155
|
+
|
1156
|
+
lsm_str_skip_spaces (&string);
|
1157
|
+
|
1158
|
+
if (string[0] == '\0') {
|
1159
|
+
trait->b = trait->a;
|
1160
|
+
return TRUE;
|
1161
|
+
}
|
1162
|
+
|
1163
|
+
trait->b = g_ascii_strtod (string, &end_ptr);
|
1164
|
+
|
1165
|
+
return end_ptr != string;
|
1166
|
+
}
|
1167
|
+
|
1168
|
+
static char *
|
1169
|
+
lsm_svg_one_or_two_double_trait_to_string (LsmTrait *abstract_trait)
|
1170
|
+
{
|
1171
|
+
LsmSvgOneOrTwoDouble *trait = (LsmSvgOneOrTwoDouble *) abstract_trait;
|
1172
|
+
|
1173
|
+
if (trait->a == trait->b)
|
1174
|
+
return g_strdup_printf ("%g", trait->a);
|
1175
|
+
|
1176
|
+
return g_strdup_printf ("%g %g", trait->a, trait->b);
|
1177
|
+
}
|
1178
|
+
|
1179
|
+
const LsmTraitClass lsm_svg_one_or_two_double_trait_class = {
|
1180
|
+
.size = sizeof (double),
|
1181
|
+
.from_string = lsm_svg_one_or_two_double_trait_from_string,
|
1182
|
+
.to_string = lsm_svg_one_or_two_double_trait_to_string
|
1183
|
+
};
|
1184
|
+
|
1185
|
+
static gboolean
|
1186
|
+
lsm_svg_overflow_trait_from_string (LsmTrait *abstract_trait, char *string)
|
1187
|
+
{
|
1188
|
+
LsmSvgOverflow *trait = (LsmSvgOverflow *) abstract_trait;
|
1189
|
+
|
1190
|
+
*trait = lsm_svg_overflow_from_string (string);
|
1191
|
+
|
1192
|
+
return *trait >= 0;
|
1193
|
+
}
|
1194
|
+
|
1195
|
+
static char *
|
1196
|
+
lsm_svg_overflow_trait_to_string (LsmTrait *abstract_trait)
|
1197
|
+
{
|
1198
|
+
LsmSvgOverflow *trait = (LsmSvgOverflow *) abstract_trait;
|
1199
|
+
|
1200
|
+
return g_strdup (lsm_svg_overflow_to_string (*trait));
|
1201
|
+
}
|
1202
|
+
|
1203
|
+
const LsmTraitClass lsm_svg_overflow_trait_class = {
|
1204
|
+
.size = sizeof (LsmSvgOverflow),
|
1205
|
+
.from_string = lsm_svg_overflow_trait_from_string,
|
1206
|
+
.to_string = lsm_svg_overflow_trait_to_string
|
1207
|
+
};
|
1208
|
+
|
1209
|
+
static gboolean
|
1210
|
+
lsm_svg_writing_mode_trait_from_string (LsmTrait *abstract_trait, char *string)
|
1211
|
+
{
|
1212
|
+
LsmSvgWritingMode *trait = (LsmSvgWritingMode *) abstract_trait;
|
1213
|
+
|
1214
|
+
*trait = lsm_svg_writing_mode_from_string (string);
|
1215
|
+
|
1216
|
+
return *trait >= 0;
|
1217
|
+
}
|
1218
|
+
|
1219
|
+
static char *
|
1220
|
+
lsm_svg_writing_mode_trait_to_string (LsmTrait *abstract_trait)
|
1221
|
+
{
|
1222
|
+
LsmSvgWritingMode *trait = (LsmSvgWritingMode *) abstract_trait;
|
1223
|
+
|
1224
|
+
return g_strdup (lsm_svg_writing_mode_to_string (*trait));
|
1225
|
+
}
|
1226
|
+
|
1227
|
+
const LsmTraitClass lsm_svg_writing_mode_trait_class = {
|
1228
|
+
.size = sizeof (LsmSvgWritingMode),
|
1229
|
+
.from_string = lsm_svg_writing_mode_trait_from_string,
|
1230
|
+
.to_string = lsm_svg_writing_mode_trait_to_string
|
1231
|
+
};
|
1232
|
+
|