diff --git a/src/extension/internal/pdfinput/svg-builder.h b/src/extension/internal/pdfinput/svg-builder.h
index 5004e90f9af2c358bc8798ae6b9baccaa8f73ac4..28f7e1be3200fb736403b821270d855a27458f99 100644 (file)
class GooString;
class Function;
struct GfxState;
+class GfxColor;
+class GfxColorSpace;
+class GfxRGB;
+class GfxPath;
class GfxPattern;
-class GfxShadingPattern;
class GfxTilingPattern;
+class GfxShading;
class GfxFont;
class GfxImageColorMap;
class Stream;
namespace Extension {
namespace Internal {
+struct SvgTransparencyGroup;
+
+/**
+ * \struct SvgGraphicsState
+ * Holds information about the current softmask and group depth.
+ * Could be later used to store other graphics state parameters so that we could
+ * emit only the differences in style settings from the parent state.
+ */
+struct SvgGraphicsState {
+ Inkscape::XML::Node *softmask; // Points to current softmask node
+ int group_depth; // Depth of nesting groups at this level
+};
+
/**
* \struct SvgGlyph
* Holds information about glyphs added by PdfParser which haven't been added
* to the document yet.
*/
struct SvgGlyph {
- NR::Point position; // Absolute glyph coords
- NR::Point text_position; // Absolute glyph coords in text space
+ Geom::Point position; // Absolute glyph coords
+ Geom::Point text_position; // Absolute glyph coords in text space
double dx, dy; // Advance values
double rise; // Text rise parameter
char code[8]; // UTF-8 coded character
public:
SvgBuilder(SPDocument *document, gchar *docname, XRef *xref);
SvgBuilder(SvgBuilder *parent, Inkscape::XML::Node *root);
- ~SvgBuilder();
+ virtual ~SvgBuilder();
// Property setting
void setDocumentSize(double width, double height); // Document size in px
void setAsLayer(char *layer_name=NULL);
+ void setGroupOpacity(double opacity);
+ Inkscape::XML::Node *getPreferences() {
+ return _preferences;
+ }
// Handling the node stack
Inkscape::XML::Node *pushGroup();
// Path adding
void addPath(GfxState *state, bool fill, bool stroke, bool even_odd=false);
+ void addShadedFill(GfxShading *shading, double *matrix, GfxPath *path, bool even_odd=false);
// Image handling
void addImage(GfxState *state, Stream *str, int width, int height,
Stream *mask_str, int mask_width, int mask_height,
GfxImageColorMap *mask_color_map);
+ // Transparency group and soft mask handling
+ void pushTransparencyGroup(GfxState *state, double *bbox,
+ GfxColorSpace *blending_color_space,
+ bool isolated, bool knockout,
+ bool for_softmask);
+ void popTransparencyGroup(GfxState *state);
+ void paintTransparencyGroup(GfxState *state, double *bbox);
+ void setSoftMask(GfxState *state, double *bbox, bool alpha,
+ Function *transfer_func, GfxColor *backdrop_color);
+ void clearSoftMask(GfxState *state);
+
// Text handling
void beginString(GfxState *state, GooString *s);
void endString(GfxState *state);
// Transforming
void setTransform(double c0, double c1, double c2, double c3, double c4,
double c5);
- void setTransform(double *transform);
+ void setTransform(double const *transform);
bool getTransform(double *transform);
private:
- SvgBuilder();
+ void _init();
// Pattern creation
gchar *_createPattern(GfxPattern *pattern, GfxState *state, bool is_stroke=false);
- gchar *_createGradient(GfxShadingPattern *shading_pattern);
- bool _addStopsToGradient(Inkscape::XML::Node *gradient, Function *func, double opacity);
- bool _addSamplesToGradient(Inkscape::XML::Node *gradient, Function *func,
- double offset0, double offset1, double opacity);
+ gchar *_createGradient(GfxShading *shading, double *matrix, bool for_shading=false);
+ void _addStopToGradient(Inkscape::XML::Node *gradient, double offset,
+ GfxRGB *color, double opacity);
+ bool _addGradientStops(Inkscape::XML::Node *gradient, GfxShading *shading,
+ Function *func);
gchar *_createTilingPattern(GfxTilingPattern *tiling_pattern, GfxState *state,
bool is_stroke=false);
// Image/mask creation
void _flushText(); // Write buffered text into doc
+ // Handling of node stack
+ Inkscape::XML::Node *pushNode(const char* name);
+ Inkscape::XML::Node *popNode();
+ std::vector<Inkscape::XML::Node *> _node_stack;
std::vector<int> _group_depth; // Depth of nesting groups
+ SvgTransparencyGroup *_transp_group_stack; // Transparency group stack
+ std::vector<SvgGraphicsState> _state_stack;
SPCSSAttr *_font_style; // Current font style
GfxFont *_current_font;
char *_font_specification;
double _font_scaling;
bool _need_font_update;
- NR::Matrix _text_matrix;
- NR::Point _text_position;
+ Geom::Matrix _text_matrix;
+ Geom::Point _text_position;
std::vector<SvgGlyph> _glyphs; // Added characters
bool _in_text_object; // Whether we are inside a text object
bool _invalidated_style;
Inkscape::XML::Document *_xml_doc;
Inkscape::XML::Node *_root; // Root node from the point of view of this SvgBuilder
Inkscape::XML::Node *_container; // Current container (group/pattern/mask)
+ Inkscape::XML::Node *_preferences; // Preferences container node
double _width, _height; // Document size in px
};