This file is indexed.

/usr/include/mapnik/svg/svg_converter.hpp is in libmapnik-dev 2.2.0+ds1-6build2.

This file is owned by root:root, with mode 0o644.

The actual contents of the file can be viewed below.

  1
  2
  3
  4
  5
  6
  7
  8
  9
 10
 11
 12
 13
 14
 15
 16
 17
 18
 19
 20
 21
 22
 23
 24
 25
 26
 27
 28
 29
 30
 31
 32
 33
 34
 35
 36
 37
 38
 39
 40
 41
 42
 43
 44
 45
 46
 47
 48
 49
 50
 51
 52
 53
 54
 55
 56
 57
 58
 59
 60
 61
 62
 63
 64
 65
 66
 67
 68
 69
 70
 71
 72
 73
 74
 75
 76
 77
 78
 79
 80
 81
 82
 83
 84
 85
 86
 87
 88
 89
 90
 91
 92
 93
 94
 95
 96
 97
 98
 99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
/*****************************************************************************
 *
 * This file is part of Mapnik (c++ mapping toolkit)
 *
 * Copyright (C) 2011 Artem Pavlenko
 *
 * This library is free software; you can redistribute it and/or
 * modify it under the terms of the GNU Lesser General Public
 * License as published by the Free Software Foundation; either
 * version 2.1 of the License, or (at your option) any later version.
 *
 * This library is distributed in the hope that it will be useful,
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
 * Lesser General Public License for more details.
 *
 * You should have received a copy of the GNU Lesser General Public
 * License along with this library; if not, write to the Free Software
 * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA
 *
 *****************************************************************************/

#ifndef MAPNIK_SVG_CONVERTER_HPP
#define MAPNIK_SVG_CONVERTER_HPP

// mapnik
#include <mapnik/svg/svg_path_attributes.hpp>
#include <mapnik/svg/svg_path_adapter.hpp>
#include <mapnik/noncopyable.hpp>

// agg
#include "agg_path_storage.h"
#include "agg_conv_transform.h"
#include "agg_conv_stroke.h"
#include "agg_conv_contour.h"
#include "agg_conv_curve.h"
#include "agg_color_rgba.h"
#include "agg_bounding_rect.h"

// stl
#include <stdexcept>

namespace mapnik {
namespace svg {

template <typename VertexSource, typename AttributeSource>
class svg_converter : mapnik::noncopyable
{
public:

    svg_converter(VertexSource & source, AttributeSource & attributes)
        : source_(source),
          attributes_(attributes) {}

    void begin_path()
    {
        unsigned idx = source_.start_new_path();
        attributes_.add(path_attributes(cur_attr(), idx));
    }
    
    void end_path()
    {
        if(attributes_.size() == 0)
        {
            throw std::runtime_error("end_path : The path was not begun");
        }
        path_attributes& attr = attributes_[attributes_.size() - 1];
        unsigned idx = attr.index;
        attr = cur_attr();
        attr.index = idx;
    }

    void move_to(double x, double y, bool rel=false)  // M, m
    {
        if(rel) source_.rel_to_abs(&x, &y);
        source_.move_to(x, y);
    }

    void line_to(double x,  double y, bool rel=false)  // L, l
    {
        if(rel) source_.rel_to_abs(&x, &y);
        source_.line_to(x, y);
    }

    void hline_to(double x, bool rel=false)           // H, h
    {
        double x2 = 0.0;
        double y2 = 0.0;
        if(source_.total_vertices())
        {
            source_.vertex(source_.total_vertices() - 1, &x2, &y2);
            if(rel) x += x2;
            source_.line_to(x, y2);
        }
    }

    void vline_to(double y, bool rel=false)           // V, v
    {
        double x2 = 0.0;
        double y2 = 0.0;
        if(source_.total_vertices())
        {
            source_.vertex(source_.total_vertices() - 1, &x2, &y2);
            if(rel) y += y2;
            source_.line_to(x2, y);
        }
    }
    void curve3(double x1, double y1,                   // Q, q
                double x,  double y, bool rel=false)
    {
        if(rel)
        {
            source_.rel_to_abs(&x1, &y1);
            source_.rel_to_abs(&x,  &y);
        }
        source_.curve3(x1, y1, x, y);
    }

    void curve3(double x, double y, bool rel=false)   // T, t
    {
        if(rel)
        {
            source_.curve3_rel(x, y);
        } else
        {
            source_.curve3(x, y);
        }
    }

    void curve4(double x1, double y1,                   // C, c
                double x2, double y2,
                double x,  double y, bool rel=false)
    {
        if(rel)
        {
            source_.rel_to_abs(&x1, &y1);
            source_.rel_to_abs(&x2, &y2);
            source_.rel_to_abs(&x,  &y);
        }
        source_.curve4(x1, y1, x2, y2, x, y);
    }

    void curve4(double x2, double y2,                   // S, s
                double x,  double y, bool rel=false)
    {
        if(rel)
        {
            source_.curve4_rel(x2, y2, x, y);
        } else
        {
            source_.curve4(x2, y2, x, y);
        }
    }

    void arc_to(double rx, double ry,                   // A, a
                double angle,
                bool large_arc_flag,
                bool sweep_flag,
                double x, double y,bool rel=false)
    {

        if(rel)
        {
            source_.arc_rel(rx, ry, angle, large_arc_flag, sweep_flag, x, y);
        }
        else
        {
            source_.arc_to(rx, ry, angle, large_arc_flag, sweep_flag, x, y);

        }
    }

    void close_subpath()                              // Z, z
    {
        source_.end_poly(agg::path_flags_close);
    }

    void push_attr()
    {
        attr_stack_.add(attr_stack_.size() ?
                        attr_stack_[attr_stack_.size() - 1] :
                        path_attributes());
    }
    void pop_attr()
    {
        if(attr_stack_.size() == 0)
        {
            throw std::runtime_error("pop_attr : Attribute stack is empty");
        }
        attr_stack_.remove_last();
    }

    // Attribute setting functions.
    void fill(agg::rgba8 const& f)
    {
        path_attributes& attr = cur_attr();
        double a = attr.fill_color.opacity();
        attr.fill_color = f;
        attr.fill_color.opacity(a * f.opacity());
        attr.fill_flag = true;
    }

    void add_fill_gradient(mapnik::gradient const& grad)
    {
        path_attributes& attr = cur_attr();
        attr.fill_gradient = grad;
    }

    void add_stroke_gradient(mapnik::gradient const& grad)
    {
        path_attributes& attr = cur_attr();
        attr.stroke_gradient = grad;
    }

    void stroke(agg::rgba8 const& s)
    {
        path_attributes& attr = cur_attr();
        double a = attr.stroke_color.opacity();
        attr.stroke_color = s;
        attr.stroke_color.opacity(a * s.opacity());
        attr.stroke_flag = true;
    }

    void even_odd(bool flag)
    {
        cur_attr().even_odd_flag = flag;
    }

    void visibility(bool flag)
    {
        cur_attr().visibility_flag = flag;
    }

    bool visibility()
    {
        return cur_attr().visibility_flag;
    }

    void display(bool flag)
    {
        cur_attr().display_flag = flag;
    }

    bool display()
    {
        return cur_attr().display_flag;
    }
    
    void stroke_width(double w)
    {
        cur_attr().stroke_width = w;
    }
    void fill_none()
    {
        cur_attr().fill_flag = false;
    }

    void stroke_none()
    {
        cur_attr().stroke_flag = false;
    }

    void fill_opacity(double op)
    {
        cur_attr().fill_opacity = op;
    }

    void stroke_opacity(double op)
    {
        cur_attr().stroke_opacity = op;
    }

    void opacity(double op)
    {
        cur_attr().opacity = op;
    }

    void line_join(agg::line_join_e join)
    {
        cur_attr().line_join = join;
    }

    void line_cap(agg::line_cap_e cap)
    {
        cur_attr().line_cap = cap;
    }
    void miter_limit(double ml)
    {
        cur_attr().miter_limit = ml;
    }

    // Make all polygons CCW-oriented
    void arrange_orientations()
    {
        source_.arrange_orientations_all_paths(agg::path_flags_ccw);
    }

    // FIXME!!!!
    unsigned operator [](unsigned idx)
    {
        transform_ = attributes_[idx].transform;
        return attributes_[idx].index;
    }

    void bounding_rect(double* x1, double* y1, double* x2, double* y2)
    {
        agg::conv_transform<mapnik::svg::svg_path_adapter> trans(source_, transform_);
        agg::bounding_rect(trans, *this, 0, attributes_.size(), x1, y1, x2, y2);
    }

    void set_dimensions(double w, double h)
    {
        svg_width_ = w;
        svg_height_ = h;
    }

    double width()
    {
        return svg_width_;
    }

    double height()
    {
        return svg_height_;
    }

    VertexSource & storage()
    {
        return source_;
    }

    agg::trans_affine& transform()
    {
        return cur_attr().transform;
    }

    path_attributes& cur_attr()
    {
        if(attr_stack_.size() == 0)
        {
            throw std::runtime_error("cur_attr : Attribute stack is empty");
        }
        return attr_stack_[attr_stack_.size() - 1];
    }

private:

    VertexSource & source_;
    AttributeSource & attributes_;
    AttributeSource  attr_stack_;
    agg::trans_affine transform_;
    double svg_width_;
    double svg_height_;
};


typedef svg_converter<svg_path_adapter,agg::pod_bvector<mapnik::svg::path_attributes> > svg_converter_type;

}}

#endif // MAPNIK_SVG_CONVERTER_HPP