1 #ifndef __EXTENSION_INTERNAL_PDFINPUT_SVGBUILDER_H__
2 #define __EXTENSION_INTERNAL_PDFINPUT_SVGBUILDER_H__
4 /** \file
5 * SVG representation creator using libpoppler.
6 *
7 * Authors:
8 * miklos erdelyi
9 *
10 * Copyright (C) 2007 Authors
11 *
12 * Released under GNU GPL, read the file 'COPYING' for more information
13 */
15 #ifdef HAVE_CONFIG_H
16 # include <config.h>
17 #endif
19 #ifdef HAVE_POPPLER
21 class SPDocument;
22 namespace Inkscape {
23 namespace XML {
24 class Document;
25 class Node;
26 }
27 }
29 class Function;
30 class SampledFunction;
31 struct GfxState;
32 class GfxPattern;
33 class GfxShadingPattern;
34 class GfxTilingPattern;
36 class SPCSSAttr;
38 #include <vector>
39 #include <glib/gtypes.h>
41 namespace Inkscape {
42 namespace Extension {
43 namespace Internal {
45 /**
46 * \class SvgBuilder
47 *
48 * Builds the inner SVG representation from the calls of PdfParser
49 *
50 */
51 class SvgBuilder {
52 public:
53 SvgBuilder(SPDocument *document);
54 SvgBuilder(SvgBuilder *parent, Inkscape::XML::Node *root);
55 ~SvgBuilder();
57 // Property setting
58 void setDocumentSize(double width, double height); // Document size in px
60 // Handling the node stack
61 Inkscape::XML::Node *pushGroup();
62 Inkscape::XML::Node *popGroup();
63 Inkscape::XML::Node *getContainer(); // Returns current group node
65 // Path adding
66 void addPath(GfxState *state, bool fill, bool stroke, bool even_odd=false);
68 bool isPatternTypeSupported(GfxPattern *pattern);
70 // State manipulation
71 void saveState();
72 void restoreState();
74 // Clipping
75 void clip(GfxState *state, bool even_odd=false);
76 void setClipPath(GfxState *state, bool even_odd=false);
78 // Transforming
79 void setTransform(double c0, double c1, double c2, double c3, double c4,
80 double c5);
81 void setTransform(double *transform);
82 bool getTransform(double *transform);
84 private:
85 // Pattern creation
86 gchar *createPattern(GfxPattern *pattern);
87 gchar *createGradient(GfxShadingPattern *shading_pattern);
88 bool addStopsToGradient(Inkscape::XML::Node *gradient, Function *func, double opacity);
89 bool addSamplesToGradient(Inkscape::XML::Node *gradient, SampledFunction *func,
90 double offset0, double offset1, double opacity);
91 gchar *createTilingPattern(GfxTilingPattern *tiling_pattern);
92 // Style setting
93 SPCSSAttr *setStyle(GfxState *state, bool fill, bool stroke, bool even_odd);
94 void setStrokeStyle(SPCSSAttr *css, GfxState *state);
95 void setFillStyle(SPCSSAttr *css, GfxState *state, bool even_odd);
97 std::vector<int> groupDepth; // Depth of nesting groups
99 SPDocument *doc;
100 Inkscape::XML::Document *xml_doc;
101 Inkscape::XML::Node *root; // Root node from the point of view of this SvgBuilder
102 Inkscape::XML::Node *container; // Current container (group/pattern/mask)
103 double width, height; // Document size in px
104 };
107 } } } /* namespace Inkscape, Extension, Internal, PdfInput */
109 #endif /* HAVE_POPPLER */
111 #endif /* __EXTENSION_INTERNAL_PDFINPUT_SVGBUILDER_H__ */
113 /*
114 Local Variables:
115 mode:c++
116 c-file-style:"stroustrup"
117 c-file-offsets:((innamespace . 0)(inline-open . 0))
118 indent-tabs-mode:nil
119 fill-column:99
120 End:
121 */
122 // vim: filetype=cpp:expandtab:shiftwidth=4:tabstop=8:softtabstop=4 :