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,122 @@
|
|
1
|
+
/* Lasem
|
2
|
+
*
|
3
|
+
* Copyright © 2007-2008 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 <lsmmathmltablecellelement.h>
|
25
|
+
|
26
|
+
static GObjectClass *parent_class;
|
27
|
+
|
28
|
+
/* GdomNode implementation */
|
29
|
+
|
30
|
+
static const char *
|
31
|
+
lsm_mathml_table_cell_get_node_name (LsmDomNode *node)
|
32
|
+
{
|
33
|
+
return "mtd";
|
34
|
+
}
|
35
|
+
|
36
|
+
/* LsmMathmlElement implementation */
|
37
|
+
|
38
|
+
static const LsmMathmlBbox *
|
39
|
+
lsm_mathml_table_cell_element_measure (LsmMathmlElement *self, LsmMathmlView *view, const LsmMathmlBbox *bbox)
|
40
|
+
{
|
41
|
+
LSM_MATHML_ELEMENT_CLASS (parent_class)->measure (self, view, bbox);
|
42
|
+
|
43
|
+
return &self->bbox;
|
44
|
+
}
|
45
|
+
|
46
|
+
static void
|
47
|
+
lsm_mathml_table_cell_element_layout (LsmMathmlElement *self, LsmMathmlView *view,
|
48
|
+
double x, double y, const LsmMathmlBbox *bbox)
|
49
|
+
{
|
50
|
+
LSM_MATHML_ELEMENT_CLASS (parent_class)->layout (self, view, x, y, bbox);
|
51
|
+
}
|
52
|
+
|
53
|
+
/* LsmMathmlTableCellElement implementation */
|
54
|
+
|
55
|
+
void
|
56
|
+
lsm_mathml_table_cell_element_get_spans (const LsmMathmlTableCellElement *self,
|
57
|
+
unsigned int *row_span,
|
58
|
+
unsigned int *column_span)
|
59
|
+
{
|
60
|
+
if (row_span != NULL)
|
61
|
+
*row_span = 0;
|
62
|
+
if (column_span != NULL)
|
63
|
+
*column_span = 0;
|
64
|
+
|
65
|
+
g_return_if_fail (LSM_IS_MATHML_TABLE_CELL_ELEMENT (self));
|
66
|
+
|
67
|
+
if (row_span != NULL)
|
68
|
+
*row_span = self->row_span.value;
|
69
|
+
if (column_span != NULL)
|
70
|
+
*column_span = self->column_span.value;
|
71
|
+
}
|
72
|
+
|
73
|
+
static const unsigned int span_default = 1;
|
74
|
+
|
75
|
+
LsmDomNode *
|
76
|
+
lsm_mathml_table_cell_element_new (void)
|
77
|
+
{
|
78
|
+
return g_object_new (LSM_TYPE_MATHML_TABLE_CELL_ELEMENT, NULL);
|
79
|
+
}
|
80
|
+
|
81
|
+
static void
|
82
|
+
lsm_mathml_table_cell_element_init (LsmMathmlTableCellElement *self)
|
83
|
+
{
|
84
|
+
}
|
85
|
+
|
86
|
+
/* LsmMathmlTableCellElement class */
|
87
|
+
|
88
|
+
static const LsmAttributeInfos _attribute_infos[] = {
|
89
|
+
{
|
90
|
+
.name = "rowspan",
|
91
|
+
.attribute_offset = offsetof (LsmMathmlTableCellElement, row_span),
|
92
|
+
.trait_class = &lsm_mathml_unsigned_trait_class,
|
93
|
+
.trait_default = &span_default
|
94
|
+
},
|
95
|
+
{
|
96
|
+
.name = "columnspan",
|
97
|
+
.attribute_offset = offsetof (LsmMathmlTableCellElement, column_span),
|
98
|
+
.trait_class = &lsm_mathml_unsigned_trait_class,
|
99
|
+
.trait_default = &span_default
|
100
|
+
}
|
101
|
+
};
|
102
|
+
|
103
|
+
static void
|
104
|
+
lsm_mathml_table_cell_element_class_init (LsmMathmlTableCellElementClass *table_cell_class)
|
105
|
+
{
|
106
|
+
LsmDomNodeClass *d_node_class = LSM_DOM_NODE_CLASS (table_cell_class);
|
107
|
+
LsmMathmlElementClass *m_element_class = LSM_MATHML_ELEMENT_CLASS (table_cell_class);
|
108
|
+
|
109
|
+
parent_class = g_type_class_peek_parent (table_cell_class);
|
110
|
+
|
111
|
+
d_node_class->get_node_name = lsm_mathml_table_cell_get_node_name;
|
112
|
+
|
113
|
+
m_element_class->measure = lsm_mathml_table_cell_element_measure;
|
114
|
+
m_element_class->layout = lsm_mathml_table_cell_element_layout;
|
115
|
+
m_element_class->attribute_manager = lsm_attribute_manager_duplicate (m_element_class->attribute_manager);
|
116
|
+
|
117
|
+
lsm_attribute_manager_add_attributes (m_element_class->attribute_manager,
|
118
|
+
G_N_ELEMENTS (_attribute_infos),
|
119
|
+
_attribute_infos);
|
120
|
+
}
|
121
|
+
|
122
|
+
G_DEFINE_TYPE (LsmMathmlTableCellElement, lsm_mathml_table_cell_element, LSM_TYPE_MATHML_ELEMENT)
|
@@ -0,0 +1,62 @@
|
|
1
|
+
/* Lasem
|
2
|
+
*
|
3
|
+
* Copyright © 2007-2008 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_MATHML_TABLE_CELL_ELEMENT_H
|
25
|
+
#define LSM_MATHML_TABLE_CELL_ELEMENT_H
|
26
|
+
|
27
|
+
#include <lsmmathmltypes.h>
|
28
|
+
#include <lsmmathmlelement.h>
|
29
|
+
|
30
|
+
G_BEGIN_DECLS
|
31
|
+
|
32
|
+
#define LSM_TYPE_MATHML_TABLE_CELL_ELEMENT (lsm_mathml_table_cell_element_get_type ())
|
33
|
+
#define LSM_MATHML_TABLE_CELL_ELEMENT(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), LSM_TYPE_MATHML_TABLE_CELL_ELEMENT, LsmMathmlTableCellElement))
|
34
|
+
#define LSM_MATHML_TABLE_CELL_ELEMENT_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), LSM_TYPE_MATHML_TABLE_CELL_ELEMENT, LsmMathmlTableCellElementClass))
|
35
|
+
#define LSM_IS_MATHML_TABLE_CELL_ELEMENT(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), LSM_TYPE_MATHML_TABLE_CELL_ELEMENT))
|
36
|
+
#define LSM_IS_MATHML_TABLE_CELL_ELEMENT_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), LSM_TYPE_MATHML_TABLE_CELL_ELEMENT))
|
37
|
+
#define LSM_MATHML_TABLE_CELL_ELEMENT_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS((obj), LSM_TYPE_MATHML_TABLE_CELL_ELEMENT, LsmMathmlTableCellElementClass))
|
38
|
+
|
39
|
+
typedef struct _LsmMathmlTableCellElementClass LsmMathmlTableCellElementClass;
|
40
|
+
|
41
|
+
struct _LsmMathmlTableCellElement {
|
42
|
+
LsmMathmlElement element;
|
43
|
+
|
44
|
+
LsmMathmlUnsignedAttribute row_span;
|
45
|
+
LsmMathmlUnsignedAttribute column_span;
|
46
|
+
};
|
47
|
+
|
48
|
+
struct _LsmMathmlTableCellElementClass {
|
49
|
+
LsmMathmlElementClass parent_class;
|
50
|
+
};
|
51
|
+
|
52
|
+
GType lsm_mathml_table_cell_element_get_type (void);
|
53
|
+
|
54
|
+
LsmDomNode * lsm_mathml_table_cell_element_new (void);
|
55
|
+
void lsm_mathml_table_cell_element_get_spans (const LsmMathmlTableCellElement *self,
|
56
|
+
unsigned int *row_span,
|
57
|
+
unsigned int *column_span);
|
58
|
+
|
59
|
+
G_END_DECLS
|
60
|
+
|
61
|
+
#endif
|
62
|
+
|
@@ -0,0 +1,545 @@
|
|
1
|
+
/* Lasem
|
2
|
+
*
|
3
|
+
* Copyright © 2007-2008 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 <lsmmathmltableelement.h>
|
25
|
+
#include <lsmmathmltablerowelement.h>
|
26
|
+
#include <lsmmathmloperatorelement.h>
|
27
|
+
#include <lsmmathmlview.h>
|
28
|
+
|
29
|
+
#define LSM_MATHML_TABLE_ELEMENT_LINE_WIDTH 1 /* 1 pt */
|
30
|
+
|
31
|
+
static const gboolean equal_default = FALSE;
|
32
|
+
static const LsmMathmlLine frame_default = LSM_MATHML_LINE_NONE;
|
33
|
+
static int row_align_values[1] = {LSM_MATHML_ROW_ALIGN_BASELINE};
|
34
|
+
static const LsmMathmlEnumList row_align_default = {.n_values = 1, .values = row_align_values};
|
35
|
+
static int column_align_values[1] = {LSM_MATHML_COLUMN_ALIGN_CENTER};
|
36
|
+
static const LsmMathmlEnumList column_align_default = {.n_values = 1, .values = column_align_values};
|
37
|
+
static LsmMathmlSpace row_spacing_values[1] = {
|
38
|
+
{.name = LSM_MATHML_SPACE_NAME_ERROR, .length = {.unit = LSM_MATHML_UNIT_EX, .value = 1.0}}
|
39
|
+
};
|
40
|
+
static const LsmMathmlSpaceList row_spacing_default = {.n_spaces = 1, .spaces = row_spacing_values};
|
41
|
+
static LsmMathmlSpace column_spacing_values[1] = {
|
42
|
+
{.name = LSM_MATHML_SPACE_NAME_ERROR, .length = {.unit = LSM_MATHML_UNIT_EM, .value = 0.8}}
|
43
|
+
};
|
44
|
+
static const LsmMathmlSpaceList column_spacing_default = {.n_spaces = 1, .spaces = column_spacing_values};
|
45
|
+
static int lines_values[1] = {LSM_MATHML_LINE_NONE};
|
46
|
+
static const LsmMathmlEnumList lines_default = {.n_values = 1, .values = lines_values};
|
47
|
+
static LsmMathmlSpace frame_spacing_values[2] = {
|
48
|
+
{.name = LSM_MATHML_SPACE_NAME_ERROR, .length = {.unit = LSM_MATHML_UNIT_EM, .value = 0.4}},
|
49
|
+
{.name = LSM_MATHML_SPACE_NAME_ERROR, .length = {.unit = LSM_MATHML_UNIT_EX, .value = 0.5}}
|
50
|
+
};
|
51
|
+
static const LsmMathmlSpaceList frame_spacing_default = {.n_spaces = 2, .spaces = frame_spacing_values};
|
52
|
+
|
53
|
+
static GObjectClass *parent_class;
|
54
|
+
|
55
|
+
/* GdomNode implementation */
|
56
|
+
|
57
|
+
static const char *
|
58
|
+
lsm_mathml_table_get_node_name (LsmDomNode *node)
|
59
|
+
{
|
60
|
+
return "mtable";
|
61
|
+
}
|
62
|
+
|
63
|
+
static gboolean
|
64
|
+
lsm_mathml_table_element_can_append_child (LsmDomNode *self, LsmDomNode *child)
|
65
|
+
{
|
66
|
+
return LSM_IS_MATHML_TABLE_ROW_ELEMENT (child);
|
67
|
+
}
|
68
|
+
|
69
|
+
/* LsmMathmlElement implementation */
|
70
|
+
|
71
|
+
static void
|
72
|
+
lsm_mathml_table_element_update (LsmMathmlElement *self, LsmMathmlStyle *style)
|
73
|
+
{
|
74
|
+
LsmMathmlTableElement *table = LSM_MATHML_TABLE_ELEMENT (self);
|
75
|
+
|
76
|
+
lsm_mathml_space_list_attribute_normalize (&table->row_spacing, 0.0, &row_spacing_default, style);
|
77
|
+
lsm_mathml_space_list_attribute_normalize (&table->column_spacing, 0.0, &column_spacing_default, style);
|
78
|
+
lsm_mathml_space_list_attribute_normalize (&table->frame_spacing, 0.0, &frame_spacing_default, style);
|
79
|
+
}
|
80
|
+
|
81
|
+
static const LsmMathmlBbox *
|
82
|
+
lsm_mathml_table_element_measure (LsmMathmlElement *self, LsmMathmlView *view, const LsmMathmlBbox *bbox)
|
83
|
+
{
|
84
|
+
LsmMathmlTableElement *table = LSM_MATHML_TABLE_ELEMENT (self);
|
85
|
+
LsmDomNode *row_node;
|
86
|
+
LsmDomNode *cell_node;
|
87
|
+
const LsmMathmlBbox *cell_bbox;
|
88
|
+
unsigned int row, column;
|
89
|
+
unsigned int max_index;
|
90
|
+
double max_height = 0.0;
|
91
|
+
double max_width = 0.0;
|
92
|
+
double max_depth = 0.0;
|
93
|
+
double height;
|
94
|
+
gboolean stretchy_found = FALSE;
|
95
|
+
|
96
|
+
table->line_width = LSM_MATHML_TABLE_ELEMENT_LINE_WIDTH;
|
97
|
+
|
98
|
+
g_free (table->widths);
|
99
|
+
g_free (table->heights);
|
100
|
+
g_free (table->depths);
|
101
|
+
|
102
|
+
table->n_columns = 0;
|
103
|
+
table->n_rows = 0;
|
104
|
+
|
105
|
+
self->bbox = lsm_mathml_bbox_null;
|
106
|
+
|
107
|
+
/* Count the number of columns and rows */
|
108
|
+
|
109
|
+
for (row_node = LSM_DOM_NODE (self)->first_child;
|
110
|
+
row_node != NULL;
|
111
|
+
row_node = row_node->next_sibling) {
|
112
|
+
unsigned int counter = 0;
|
113
|
+
|
114
|
+
for (cell_node = row_node->first_child;
|
115
|
+
cell_node != NULL;
|
116
|
+
cell_node = cell_node->next_sibling)
|
117
|
+
counter++;
|
118
|
+
table->n_rows++;
|
119
|
+
if (table->n_columns < counter)
|
120
|
+
table->n_columns = counter;
|
121
|
+
}
|
122
|
+
|
123
|
+
if (table->n_rows < 1 || table->n_columns < 1) {
|
124
|
+
table->n_columns = 0;
|
125
|
+
table->n_rows = 0;
|
126
|
+
return &self->bbox;
|
127
|
+
}
|
128
|
+
|
129
|
+
self->bbox.is_defined = TRUE;
|
130
|
+
|
131
|
+
table->widths = g_new (double, table->n_columns);
|
132
|
+
table->heights = g_new (double, table->n_rows);
|
133
|
+
table->depths = g_new (double, table->n_rows);
|
134
|
+
|
135
|
+
/* Calculate maximum height for each row and maximum width for each column */
|
136
|
+
|
137
|
+
row = 0;
|
138
|
+
for (row_node = LSM_DOM_NODE (self)->first_child;
|
139
|
+
row_node != NULL;
|
140
|
+
row_node = row_node->next_sibling) {
|
141
|
+
column = 0;
|
142
|
+
table->heights[row] = 0.0;
|
143
|
+
table->depths[row] = 0.0;
|
144
|
+
for (cell_node = row_node->first_child;
|
145
|
+
cell_node != NULL;
|
146
|
+
cell_node = cell_node->next_sibling) {
|
147
|
+
cell_bbox = lsm_mathml_element_measure (LSM_MATHML_ELEMENT (cell_node), view, NULL);
|
148
|
+
max_width = MAX (max_width, cell_bbox->width);
|
149
|
+
max_height = MAX (max_height, cell_bbox->height);
|
150
|
+
max_depth = MAX (max_depth, cell_bbox->depth);
|
151
|
+
if (row == 0)
|
152
|
+
table->widths[column] = cell_bbox->width;
|
153
|
+
else
|
154
|
+
table->widths[column] = MAX (table->widths[column], cell_bbox->width);
|
155
|
+
if (column == 0) {
|
156
|
+
table->heights[row] = cell_bbox->height;
|
157
|
+
table->depths[row] = cell_bbox->depth;
|
158
|
+
} else {
|
159
|
+
table->heights[row] = MAX (table->heights[row], cell_bbox->height);
|
160
|
+
table->depths[row] = MAX (table->depths[row], cell_bbox->depth);
|
161
|
+
}
|
162
|
+
|
163
|
+
if (!stretchy_found) {
|
164
|
+
const LsmMathmlOperatorElement *operator;
|
165
|
+
|
166
|
+
operator = lsm_mathml_element_get_embellished_core (LSM_MATHML_ELEMENT (cell_node));
|
167
|
+
if (operator != NULL && operator->stretchy.value)
|
168
|
+
stretchy_found = TRUE;
|
169
|
+
}
|
170
|
+
|
171
|
+
column++;
|
172
|
+
}
|
173
|
+
row++;
|
174
|
+
}
|
175
|
+
|
176
|
+
/* All rows have the same height ? */
|
177
|
+
|
178
|
+
if (table->equal_rows.value)
|
179
|
+
for (row = 0; row < table->n_rows; row++) {
|
180
|
+
table->heights[row] = max_height;
|
181
|
+
table->depths[row] = max_depth;
|
182
|
+
}
|
183
|
+
|
184
|
+
/* All columns have the same width ? */
|
185
|
+
|
186
|
+
if (table->equal_columns.value)
|
187
|
+
for (column = 0; column < table->n_columns; column++)
|
188
|
+
table->widths[column] = max_width;
|
189
|
+
|
190
|
+
max_index = table->column_spacing.n_values - 1;
|
191
|
+
for (column = 0; column < table->n_columns; column++) {
|
192
|
+
self->bbox.width += table->widths[column];
|
193
|
+
if (column < table->n_columns - 1)
|
194
|
+
self->bbox.width += table->column_spacing.values[MIN (column, max_index)];
|
195
|
+
}
|
196
|
+
|
197
|
+
height = 0.0;
|
198
|
+
|
199
|
+
max_index = table->row_spacing.n_values - 1;
|
200
|
+
for (row = 0; row < table->n_rows; row++) {
|
201
|
+
height += table->heights[row] + table->depths[row];
|
202
|
+
if (row < table->n_rows - 1)
|
203
|
+
height += table->row_spacing.values[MIN (row, max_index)];
|
204
|
+
}
|
205
|
+
|
206
|
+
height += 2 * table->frame_spacing.values[1];
|
207
|
+
|
208
|
+
/* Add the line widths to the table bbox */
|
209
|
+
|
210
|
+
self->bbox.width += table->line_width * (1 + table->n_columns);
|
211
|
+
height += table->line_width * (1 + table->n_rows);
|
212
|
+
|
213
|
+
/* Center vertically */
|
214
|
+
|
215
|
+
self->bbox.height = 0.5 * height;
|
216
|
+
self->bbox.depth = height - self->bbox.height;
|
217
|
+
|
218
|
+
self->bbox.width += 2 * table->frame_spacing.values[0];
|
219
|
+
|
220
|
+
{
|
221
|
+
double axis_offset;
|
222
|
+
double length;
|
223
|
+
|
224
|
+
axis_offset = lsm_mathml_view_measure_axis_offset (view, self->style.math_size);
|
225
|
+
length = (self->bbox.height + self->bbox.depth) * 0.5;
|
226
|
+
self->bbox.height = axis_offset + length;
|
227
|
+
self->bbox.depth = length - axis_offset;
|
228
|
+
}
|
229
|
+
|
230
|
+
if (stretchy_found) {
|
231
|
+
const LsmMathmlOperatorElement *operator;
|
232
|
+
LsmMathmlBbox stretch_bbox;
|
233
|
+
|
234
|
+
row = 0;
|
235
|
+
for (row_node = LSM_DOM_NODE (self)->first_child;
|
236
|
+
row_node != NULL;
|
237
|
+
row_node = row_node->next_sibling) {
|
238
|
+
column = 0;
|
239
|
+
for (cell_node = row_node->first_child;
|
240
|
+
cell_node != NULL;
|
241
|
+
cell_node = cell_node->next_sibling) {
|
242
|
+
operator = lsm_mathml_element_get_embellished_core (LSM_MATHML_ELEMENT (cell_node));
|
243
|
+
if (operator != NULL && operator->stretchy.value) {
|
244
|
+
stretch_bbox.width = table->widths[column];
|
245
|
+
stretch_bbox.height = table->heights[row];
|
246
|
+
stretch_bbox.depth = table->depths[row];
|
247
|
+
lsm_mathml_element_measure (LSM_MATHML_ELEMENT (cell_node), view,
|
248
|
+
&stretch_bbox);
|
249
|
+
}
|
250
|
+
column++;
|
251
|
+
}
|
252
|
+
row++;
|
253
|
+
}
|
254
|
+
}
|
255
|
+
|
256
|
+
return &self->bbox;
|
257
|
+
}
|
258
|
+
|
259
|
+
static void
|
260
|
+
lsm_mathml_table_element_layout (LsmMathmlElement *self, LsmMathmlView *view,
|
261
|
+
double x, double y, const LsmMathmlBbox *bbox)
|
262
|
+
{
|
263
|
+
LsmMathmlTableElement *table = LSM_MATHML_TABLE_ELEMENT (self);
|
264
|
+
LsmDomNode *row_node, *cell_node;
|
265
|
+
double y_offset, x_offset;
|
266
|
+
unsigned int max_column;
|
267
|
+
unsigned int max_row;
|
268
|
+
unsigned int row, column;
|
269
|
+
double x_cell, y_cell;
|
270
|
+
|
271
|
+
if (table->n_rows < 1 || table->n_columns < 1)
|
272
|
+
return;
|
273
|
+
|
274
|
+
max_column = table->column_spacing.n_values - 1;
|
275
|
+
max_row = table->row_spacing.n_values - 1;
|
276
|
+
|
277
|
+
y_offset = -self->bbox.height;
|
278
|
+
y_offset += table->frame_spacing.values[1];
|
279
|
+
y_offset += table->line_width;
|
280
|
+
|
281
|
+
row = 0;
|
282
|
+
for (row_node = LSM_DOM_NODE (self)->first_child;
|
283
|
+
row_node != NULL;
|
284
|
+
row_node = row_node->next_sibling) {
|
285
|
+
column = 0;
|
286
|
+
x_offset = table->frame_spacing.values[0];
|
287
|
+
x_offset += table->line_width;
|
288
|
+
for (cell_node = row_node->first_child;
|
289
|
+
cell_node != NULL;
|
290
|
+
cell_node = cell_node->next_sibling) {
|
291
|
+
bbox = lsm_mathml_element_get_bbox (LSM_MATHML_ELEMENT (cell_node));
|
292
|
+
|
293
|
+
switch (table->row_align.enum_list.values[MIN (row,
|
294
|
+
table->row_align.enum_list.n_values - 1)]) {
|
295
|
+
case LSM_MATHML_ROW_ALIGN_TOP:
|
296
|
+
y_cell = y + y_offset + bbox->height;
|
297
|
+
break;
|
298
|
+
case LSM_MATHML_ROW_ALIGN_BOTTOM:
|
299
|
+
y_cell = y + y_offset + table->heights[row] + table->depths[row] -
|
300
|
+
bbox->depth;
|
301
|
+
break;
|
302
|
+
case LSM_MATHML_ROW_ALIGN_CENTER:
|
303
|
+
y_cell = y + y_offset + (table->heights[row] +
|
304
|
+
table->depths[row] -
|
305
|
+
bbox->height - bbox->depth) * 0.5 +
|
306
|
+
bbox->height;
|
307
|
+
break;
|
308
|
+
default:
|
309
|
+
y_cell = y + y_offset + table->heights[row];
|
310
|
+
}
|
311
|
+
|
312
|
+
switch (table->column_align.enum_list.values[MIN (column,
|
313
|
+
table->column_align.enum_list.n_values
|
314
|
+
- 1)]) {
|
315
|
+
case LSM_MATHML_COLUMN_ALIGN_LEFT:
|
316
|
+
x_cell = x + x_offset;
|
317
|
+
break;
|
318
|
+
case LSM_MATHML_COLUMN_ALIGN_RIGHT:
|
319
|
+
x_cell = x + x_offset + table->widths[column] - bbox->width;
|
320
|
+
break;
|
321
|
+
default:
|
322
|
+
x_cell = x + x_offset + (table->widths[column] - bbox->width) * 0.5;
|
323
|
+
}
|
324
|
+
|
325
|
+
lsm_mathml_element_layout (LSM_MATHML_ELEMENT (cell_node), view,
|
326
|
+
x_cell, y_cell, bbox);
|
327
|
+
|
328
|
+
if (column < table->n_columns - 1) {
|
329
|
+
x_offset += table->widths[column];
|
330
|
+
x_offset += table->column_spacing.values[MIN (column, max_column)];
|
331
|
+
x_offset += table->line_width;
|
332
|
+
column++;
|
333
|
+
}
|
334
|
+
}
|
335
|
+
|
336
|
+
if (row < table->n_rows - 1) {
|
337
|
+
y_offset += table->heights[row] + table->depths[row];
|
338
|
+
y_offset += table->row_spacing.values[MIN (row, max_row)];
|
339
|
+
y_offset += table->line_width;
|
340
|
+
row++;
|
341
|
+
}
|
342
|
+
}
|
343
|
+
}
|
344
|
+
|
345
|
+
static void
|
346
|
+
lsm_mathml_table_element_render (LsmMathmlElement *self, LsmMathmlView *view)
|
347
|
+
{
|
348
|
+
LsmMathmlTableElement *table = LSM_MATHML_TABLE_ELEMENT (self);
|
349
|
+
double x, y;
|
350
|
+
double x0, y0, x1, y1;
|
351
|
+
double position;
|
352
|
+
double spacing;
|
353
|
+
unsigned int i;
|
354
|
+
|
355
|
+
if (table->n_rows < 1 || table->n_columns < 1)
|
356
|
+
return;
|
357
|
+
|
358
|
+
x0 = self->x + 0.5 * table->line_width;
|
359
|
+
y0 = self->y - self->bbox.height + 0.5 * table->line_width;
|
360
|
+
x1 = x0 + self->bbox.width - table->line_width;
|
361
|
+
y1 = y0 + self->bbox.height + self->bbox.depth - table->line_width;
|
362
|
+
|
363
|
+
lsm_mathml_view_show_rectangle (view, &self->style,
|
364
|
+
x0, y0, x1 - x0, y1 - y0,
|
365
|
+
table->frame.value, table->line_width);
|
366
|
+
|
367
|
+
position = self->y - self->bbox.height;
|
368
|
+
position += table->frame_spacing.values[1];
|
369
|
+
position += table->line_width;
|
370
|
+
|
371
|
+
for (i = 0; i < table->n_rows - 1; i++) {
|
372
|
+
position += table->heights[i] + table->depths[i];
|
373
|
+
spacing = table->row_spacing.values[MIN (i, table->row_spacing.n_values - 1)];
|
374
|
+
y = position + (0.5 * spacing) + table->line_width * 0.5;
|
375
|
+
lsm_mathml_view_show_line (view, &self->style,
|
376
|
+
x0, y, x1, y,
|
377
|
+
table->row_lines.enum_list.values[MIN (i,
|
378
|
+
table->row_lines.enum_list.n_values
|
379
|
+
- 1)],
|
380
|
+
table->line_width);
|
381
|
+
position += spacing + table->line_width;
|
382
|
+
}
|
383
|
+
|
384
|
+
position = self->x;
|
385
|
+
position += table->frame_spacing.values[0];
|
386
|
+
position += table->line_width;
|
387
|
+
|
388
|
+
for (i = 0; i < table->n_columns - 1; i++) {
|
389
|
+
position += table->widths[i];
|
390
|
+
spacing = table->column_spacing.values[MIN (i, table->column_spacing.n_values - 1)];
|
391
|
+
x = position + 0.5 * (spacing + table->line_width);
|
392
|
+
lsm_mathml_view_show_line (view, &self->style,
|
393
|
+
x, y0, x, y1,
|
394
|
+
table->column_lines.enum_list.values[MIN (i,
|
395
|
+
table->column_lines.enum_list.n_values
|
396
|
+
- 1)],
|
397
|
+
table->line_width);
|
398
|
+
position += spacing + table->line_width;
|
399
|
+
}
|
400
|
+
|
401
|
+
LSM_MATHML_ELEMENT_CLASS (parent_class)->render (self, view);
|
402
|
+
}
|
403
|
+
|
404
|
+
/* LsmMathmlTableElement implementation */
|
405
|
+
|
406
|
+
LsmDomNode *
|
407
|
+
lsm_mathml_table_element_new (void)
|
408
|
+
{
|
409
|
+
return g_object_new (LSM_TYPE_MATHML_TABLE_ELEMENT, NULL);
|
410
|
+
}
|
411
|
+
|
412
|
+
static void
|
413
|
+
lsm_mathml_table_element_init (LsmMathmlTableElement *table)
|
414
|
+
{
|
415
|
+
table->widths = NULL;
|
416
|
+
table->heights = NULL;
|
417
|
+
table->depths = NULL;
|
418
|
+
table->n_columns = 0;
|
419
|
+
table->n_rows = 0;
|
420
|
+
table->line_width = 0;
|
421
|
+
|
422
|
+
table->equal_columns.value = equal_default;
|
423
|
+
table->equal_rows.value = equal_default;
|
424
|
+
table->frame.value = frame_default;
|
425
|
+
|
426
|
+
lsm_mathml_enum_list_init (&table->row_align.enum_list, &row_align_default);
|
427
|
+
lsm_mathml_enum_list_init (&table->column_align.enum_list, &column_align_default);
|
428
|
+
lsm_mathml_enum_list_init (&table->row_lines.enum_list, &lines_default);
|
429
|
+
lsm_mathml_enum_list_init (&table->column_lines.enum_list, &lines_default);
|
430
|
+
}
|
431
|
+
|
432
|
+
static void
|
433
|
+
lsm_mathml_table_element_finalize (GObject *object)
|
434
|
+
{
|
435
|
+
LsmMathmlTableElement *table = LSM_MATHML_TABLE_ELEMENT (object);
|
436
|
+
|
437
|
+
g_free (table->widths);
|
438
|
+
g_free (table->heights);
|
439
|
+
g_free (table->depths);
|
440
|
+
table->widths = NULL;
|
441
|
+
table->heights = NULL;
|
442
|
+
table->depths = NULL;
|
443
|
+
|
444
|
+
g_free (table->row_spacing.values);
|
445
|
+
g_free (table->column_spacing.values);
|
446
|
+
g_free (table->frame_spacing.values);
|
447
|
+
table->row_spacing.values = NULL;
|
448
|
+
table->column_spacing.values = NULL;
|
449
|
+
table->frame_spacing.values = NULL;
|
450
|
+
|
451
|
+
parent_class->finalize (object);
|
452
|
+
}
|
453
|
+
|
454
|
+
/* LsmMathmlTableElement class */
|
455
|
+
|
456
|
+
static const LsmAttributeInfos _attribute_infos[] = {
|
457
|
+
{
|
458
|
+
.name = "equalrows",
|
459
|
+
.attribute_offset = offsetof (LsmMathmlTableElement, equal_rows),
|
460
|
+
.trait_class = &lsm_mathml_boolean_trait_class,
|
461
|
+
.trait_default = &equal_default
|
462
|
+
},
|
463
|
+
{
|
464
|
+
.name = "equalcolumns",
|
465
|
+
.attribute_offset = offsetof (LsmMathmlTableElement, equal_columns),
|
466
|
+
.trait_class = &lsm_mathml_boolean_trait_class,
|
467
|
+
.trait_default = &equal_default
|
468
|
+
},
|
469
|
+
{
|
470
|
+
.name = "frame",
|
471
|
+
.attribute_offset = offsetof (LsmMathmlTableElement, frame),
|
472
|
+
.trait_class = &lsm_mathml_line_trait_class,
|
473
|
+
.trait_default = &frame_default
|
474
|
+
},
|
475
|
+
{
|
476
|
+
.name = "rowalign",
|
477
|
+
.attribute_offset = offsetof (LsmMathmlTableElement, row_align),
|
478
|
+
.trait_class = &lsm_mathml_row_align_list_trait_class,
|
479
|
+
.trait_default = &row_align_default
|
480
|
+
},
|
481
|
+
{
|
482
|
+
.name = "columnalign",
|
483
|
+
.attribute_offset = offsetof (LsmMathmlTableElement, column_align),
|
484
|
+
.trait_class = &lsm_mathml_column_align_list_trait_class,
|
485
|
+
.trait_default = &column_align_default
|
486
|
+
},
|
487
|
+
{
|
488
|
+
.name = "rowspacing",
|
489
|
+
.attribute_offset = offsetof (LsmMathmlTableElement, row_spacing),
|
490
|
+
.trait_class = &lsm_mathml_space_list_trait_class,
|
491
|
+
.trait_default = &row_spacing_default
|
492
|
+
},
|
493
|
+
{
|
494
|
+
.name = "columnspacing",
|
495
|
+
.attribute_offset = offsetof (LsmMathmlTableElement, column_spacing),
|
496
|
+
.trait_class = &lsm_mathml_space_list_trait_class,
|
497
|
+
.trait_default = &column_spacing_default
|
498
|
+
},
|
499
|
+
{
|
500
|
+
.name = "rowlines",
|
501
|
+
.attribute_offset = offsetof (LsmMathmlTableElement, row_lines),
|
502
|
+
.trait_class = &lsm_mathml_line_list_trait_class,
|
503
|
+
.trait_default = &lines_default
|
504
|
+
},
|
505
|
+
{
|
506
|
+
.name = "columnlines",
|
507
|
+
.attribute_offset = offsetof (LsmMathmlTableElement, column_lines),
|
508
|
+
.trait_class = &lsm_mathml_line_list_trait_class,
|
509
|
+
.trait_default = &lines_default
|
510
|
+
},
|
511
|
+
{
|
512
|
+
.name = "framespacing",
|
513
|
+
.attribute_offset = offsetof (LsmMathmlTableElement, frame_spacing),
|
514
|
+
.trait_class = &lsm_mathml_space_list_trait_class,
|
515
|
+
.trait_default = &frame_spacing_default
|
516
|
+
}
|
517
|
+
};
|
518
|
+
|
519
|
+
static void
|
520
|
+
lsm_mathml_table_element_class_init (LsmMathmlTableElementClass *table_class)
|
521
|
+
{
|
522
|
+
GObjectClass *object_class = G_OBJECT_CLASS (table_class);
|
523
|
+
LsmDomNodeClass *d_node_class = LSM_DOM_NODE_CLASS (table_class);
|
524
|
+
LsmMathmlElementClass *m_element_class = LSM_MATHML_ELEMENT_CLASS (table_class);
|
525
|
+
|
526
|
+
parent_class = g_type_class_peek_parent (table_class);
|
527
|
+
|
528
|
+
object_class->finalize = lsm_mathml_table_element_finalize;
|
529
|
+
|
530
|
+
d_node_class->get_node_name = lsm_mathml_table_get_node_name;
|
531
|
+
d_node_class->can_append_child = lsm_mathml_table_element_can_append_child;
|
532
|
+
|
533
|
+
m_element_class->update = lsm_mathml_table_element_update;
|
534
|
+
m_element_class->measure = lsm_mathml_table_element_measure;
|
535
|
+
m_element_class->layout = lsm_mathml_table_element_layout;
|
536
|
+
m_element_class->render = lsm_mathml_table_element_render;
|
537
|
+
m_element_class->is_inferred_row = NULL;
|
538
|
+
m_element_class->attribute_manager = lsm_attribute_manager_duplicate (m_element_class->attribute_manager);
|
539
|
+
|
540
|
+
lsm_attribute_manager_add_attributes (m_element_class->attribute_manager,
|
541
|
+
G_N_ELEMENTS (_attribute_infos),
|
542
|
+
_attribute_infos);
|
543
|
+
}
|
544
|
+
|
545
|
+
G_DEFINE_TYPE (LsmMathmlTableElement, lsm_mathml_table_element, LSM_TYPE_MATHML_ELEMENT)
|