]>
Commit | Line | Data |
---|---|---|
45516216 | 1 | typedef struct _GObject { |
2 | } GObject; | |
3 | namespace std { | |
4 | struct random_access_iterator_tag { | |
5 | }; | |
6 | template < typename _Iterator > struct iterator_traits { | |
7 | }; | |
8 | template < typename _Tp > struct iterator_traits <_Tp * > { | |
9 | struct iterator_category {}; | |
10 | }; | |
11 | } namespace __gnu_cxx { | |
12 | using std::iterator_traits; | |
13 | template < typename _Iterator, | |
14 | typename _Container > class __normal_iterator { | |
15 | protected:_Iterator _M_current; | |
16 | public:typedef typename iterator_traits < | |
17 | _Iterator >:: | |
18 | iterator_category iterator_category; | |
19 | typedef typename iterator_traits < | |
20 | _Iterator >::int int; | |
21 | explicit __normal_iterator(const _Iterator & | |
22 | __i):_M_current(__i) { | |
23 | } const _Iterator & base() const { | |
24 | return _M_current; | |
25 | }}; | |
26 | template < typename _IteratorL, typename _IteratorR, | |
27 | typename _Container > inline typename __normal_iterator < | |
28 | _IteratorL, | |
29 | _Container >::int operator-(const __normal_iterator < | |
30 | _IteratorL, | |
31 | _Container > &__lhs, | |
32 | const __normal_iterator < | |
33 | _IteratorR, | |
34 | _Container > &__rhs) { | |
35 | return __lhs.base() - __rhs.base(); | |
36 | } | |
37 | template < typename _Tp > class new_allocator { | |
38 | public:typedef const _Tp *const_pointer; | |
39 | typedef const _Tp & const_reference; | |
40 | template < typename _Tp1 > struct rebind { | |
41 | typedef new_allocator < _Tp1 > other; | |
42 | }; | |
43 | }; | |
44 | } | |
45 | ||
46 | namespace std { | |
47 | template < typename _Tp > | |
48 | class allocator:public __gnu_cxx::new_allocator < _Tp > { | |
49 | }; | |
50 | } | |
51 | extern double fabs(double); | |
52 | namespace Inkscape { | |
53 | namespace GC { | |
54 | enum ScanPolicy { | |
55 | SCANNED | |
56 | }; | |
57 | enum CollectionPolicy { | |
58 | AUTO, MANUAL | |
59 | }; | |
60 | template < ScanPolicy default_scan = | |
61 | SCANNED, CollectionPolicy default_collect = | |
62 | AUTO > class Managed { | |
63 | }; | |
64 | class Finalized { | |
65 | public:Finalized() { | |
66 | }}; | |
67 | class Anchored { | |
68 | protected:Anchored():_anchor(__null) | |
69 | { | |
70 | } private:struct Anchor:public Managed < SCANNED, | |
71 | MANUAL > { | |
72 | }; | |
73 | mutable Anchor *_anchor; | |
74 | }; | |
75 | } | |
76 | namespace UI { | |
77 | namespace View { | |
78 | class View:public GC::Managed <>, public GC::Finalized, | |
79 | public GC::Anchored { | |
80 | }; | |
81 | }}} struct SPDesktop:public Inkscape::UI::View::View { | |
82 | }; | |
83 | enum SPMarkerLoc { | |
84 | SP_CSS_UNIT_NONE, SP_CSS_UNIT_PX, SP_CSS_UNIT_PT, SP_CSS_UNIT_PC, | |
85 | SP_CSS_UNIT_MM, SP_CSS_UNIT_CM, SP_CSS_UNIT_IN, SP_CSS_UNIT_EM, | |
86 | SP_CSS_UNIT_EX, SP_CSS_UNIT_PERCENT | |
87 | }; | |
88 | struct SPILengthOrNormal { | |
89 | unsigned unit; | |
90 | float value; | |
91 | float computed; | |
92 | }; | |
93 | struct SPStyle { | |
94 | SPILengthOrNormal line_height; | |
95 | }; | |
96 | namespace std { | |
97 | template < typename _Tp, typename _Alloc > struct _Vector_base { | |
98 | typedef typename _Alloc::template rebind < | |
99 | _Tp >::other _Tp_alloc_type; | |
100 | struct _Vector_impl:public _Tp_alloc_type { | |
101 | _Tp *_M_start; | |
102 | _Tp *_M_finish; | |
103 | }; | |
104 | public:_Vector_impl _M_impl; | |
105 | }; | |
106 | template < typename _Tp, typename _Alloc = std::allocator < _Tp > >class vector:protected _Vector_base < _Tp, | |
107 | _Alloc > | |
108 | { | |
109 | typedef _Vector_base < _Tp, _Alloc > _Base; | |
110 | typedef vector < _Tp, _Alloc > vector_type; | |
111 | typedef typename _Base::_Tp_alloc_type _Tp_alloc_type; | |
112 | public:typedef _Tp value_type; | |
113 | typedef typename _Tp_alloc_type::const_pointer const_pointer; | |
114 | typedef typename _Tp_alloc_type:: | |
115 | const_reference const_reference; | |
116 | typedef __gnu_cxx::__normal_iterator < const_pointer, | |
117 | vector_type > const_iterator; | |
118 | const_iterator begin() const { | |
119 | return const_iterator(this->_M_impl._M_start); | |
120 | } const_iterator end() const { | |
121 | return const_iterator(this->_M_impl._M_finish); | |
122 | } unsigned int size() const { | |
123 | return end() - begin(); | |
124 | } const_reference operator[] (unsigned int __n)const { | |
125 | }}; | |
126 | } | |
127 | ||
128 | namespace Inkscape { | |
129 | namespace Text { | |
130 | class Layout { | |
131 | public:class iterator; | |
132 | inline iterator end() const; | |
133 | inline unsigned lineIndex(iterator const &it) const; | |
134 | struct Chunk; | |
135 | struct Glyph { | |
136 | }; | |
137 | struct Character { | |
138 | inline Chunk const &chunk(Layout const *l) const { | |
139 | }}; | |
140 | struct Chunk { | |
141 | unsigned in_line; | |
142 | }; | |
143 | struct Line { | |
144 | }; | |
145 | std::vector < Line > _lines; | |
146 | std::vector < Character > _characters; | |
147 | std::vector < Glyph > _glyphs; | |
148 | class PredicateLineToCharacter { | |
149 | Layout const *const _flow; | |
150 | public:inline PredicateLineToCharacter(Layout const | |
151 | *flow):_flow | |
152 | (flow) { | |
153 | }}; | |
154 | }; | |
155 | class Layout::iterator { | |
156 | public:friend class Layout; | |
157 | private:Layout const | |
158 | *_parent_layout; | |
159 | int _glyph_index; | |
160 | unsigned _char_index; | |
161 | bool _cursor_moving_vertically; | |
162 | double _x_coordinate; | |
163 | inline iterator(Layout const *p, unsigned c, | |
164 | int g):_parent_layout(p), | |
165 | _glyph_index(g), _char_index(c), | |
166 | _cursor_moving_vertically(false), | |
167 | _x_coordinate(0.0) { | |
168 | }}; | |
169 | inline Layout::iterator Layout::end() const { | |
170 | return iterator(this, _characters.size(), | |
171 | _glyphs.size()); | |
172 | } inline unsigned Layout::lineIndex(iterator const &it) const { | |
173 | return it._char_index == | |
174 | _characters.size()? _lines.size() - | |
175 | 1 : _characters[it._char_index].chunk(this).in_line; | |
176 | }}}; | |
177 | void sp_te_adjust_linespacing_screen(GObject * text, | |
178 | Inkscape::Text::Layout:: | |
179 | iterator const &start, | |
180 | Inkscape::Text::Layout:: | |
181 | iterator const &end, SPDesktop * desktop, | |
182 | double by) | |
183 | { | |
184 | Inkscape::Text::Layout const *layout; | |
185 | SPStyle *style; | |
186 | unsigned line_count = layout->lineIndex(layout->end()); | |
187 | double all_lines_height; | |
188 | double average_line_height = | |
189 | all_lines_height / (line_count == 0 ? 1 : line_count); | |
190 | double zby; | |
191 | switch (style->line_height.unit) { | |
192 | case SP_CSS_UNIT_NONE: | |
193 | default: | |
194 | if (fabs(style->line_height.computed) < 0.001) | |
195 | style->line_height.computed = by; | |
196 | else | |
197 | style->line_height.computed *= | |
198 | (average_line_height + zby) / average_line_height; | |
199 | case SP_CSS_UNIT_EM: | |
200 | case SP_CSS_UNIT_EX: | |
201 | case SP_CSS_UNIT_PERCENT: | |
202 | if (fabs(style->line_height.value) < 0.001) | |
203 | style->line_height.value = by; | |
204 | else | |
205 | style->line_height.value *= | |
206 | (average_line_height + zby) / average_line_height; | |
207 | } | |
208 | } |