Logo Search packages:      
Sourcecode: inkscape version File versions

enum CRStatus cr_style_to_string ( CRStyle *  a_this,
GString **  a_str,
guint  a_nb_indent 
)

Serializes in instance of CRStyle into a string

Parameters:
a_this the instance of CRStyle to serialize
a_str the string to serialise the style into. if *a_str is NULL, a new GString is instanciated, otherwise the style serialisation is appended to the existed *a_str
the number of white space char to use for indentation.
Returns:
CR_OK upon successful completion, an error code otherwise.

Definition at line 2653 of file cr-style.c.

{
        const gint INTERNAL_INDENT = 2;
        gint indent = a_nb_indent + INTERNAL_INDENT;
        gchar *tmp_str = NULL;
        GString *str = NULL;
        gint i = 0;

        g_return_val_if_fail (a_this && a_str, CR_BAD_PARAM_ERROR);

        if (!*a_str) {
                str = g_string_new (NULL);
        } else {
                str = *a_str;
        }
        cr_utils_dump_n_chars2 (' ', str, a_nb_indent);
        g_string_append (str, "style {\n");

        /*loop over the num_props and to_string() them */
        for (i = NUM_PROP_TOP; i < NB_NUM_PROPS; i++) {
                /*
                 *to_string() the name of the num_prop
                 *(using num_prop_code_to_string)
                 *before outputing it value
                 */
                cr_utils_dump_n_chars2 (' ', str, indent);
                tmp_str = (gchar *) num_prop_code_to_string ((enum CRNumProp)i);
                if (tmp_str) {
                        g_string_append_printf (str, "%s: ", tmp_str);
                } else {
                        g_string_append (str, "NULL");
                }
                tmp_str = NULL;
                cr_style_num_prop_val_to_string (&a_this->num_props[i], str,
                                                 a_nb_indent +
                                                 INTERNAL_INDENT);
                g_string_append (str, "\n");
        }
        /*loop over the rgb_props and to_string() them all */
        for (i = RGB_PROP_BORDER_TOP_COLOR; i < NB_RGB_PROPS; i++) {
                tmp_str = (gchar *) rgb_prop_code_to_string ((enum CRRgbProp)i);
                cr_utils_dump_n_chars2 (' ', str, indent);
                if (tmp_str) {
                        g_string_append_printf (str, "%s: ", tmp_str);
                } else {
                        g_string_append (str, "NULL: ");
                }
                tmp_str = NULL;
                cr_style_rgb_prop_val_to_string (&a_this->rgb_props[i], str,
                                                 a_nb_indent +
                                                 INTERNAL_INDENT);
                g_string_append (str, "\n");
        }
        /*loop over the border_style_props and to_string() them */
        for (i = BORDER_STYLE_PROP_TOP; i < NB_BORDER_STYLE_PROPS; i++) {
                tmp_str = (gchar *) 
                            border_style_prop_code_to_string ((enum CRBorderStyleProp)i);
                cr_utils_dump_n_chars2 (' ', str, indent);
                if (tmp_str) {
                        g_string_append_printf (str, "%s: ", tmp_str);
                } else {
                        g_string_append (str, "NULL: ");
                }
                tmp_str = NULL;
                cr_style_border_style_to_string (a_this->
                                                 border_style_props[i], str,
                                                 0);
                g_string_append (str, "\n");
        }
        cr_utils_dump_n_chars2 (' ', str, indent);
        g_string_append (str, "display: ");
        cr_style_display_type_to_string (a_this->display, str, 0);
        g_string_append (str, "\n");

        cr_utils_dump_n_chars2 (' ', str, indent);
        g_string_append (str, "position: ");
        cr_style_position_type_to_string (a_this->position, str, 0);
        g_string_append (str, "\n");

        cr_utils_dump_n_chars2 (' ', str, indent);
        g_string_append (str, "float-type: ");
        cr_style_float_type_to_string (a_this->float_type, str, 0);
        g_string_append (str, "\n");

      cr_utils_dump_n_chars2 (' ', str, indent);
      g_string_append (str, "white-space: ");
      cr_style_white_space_type_to_string (a_this->white_space, str, 0);
      g_string_append (str, "\n");

        cr_utils_dump_n_chars2 (' ', str, indent);
        g_string_append (str, "font-family: ");
        tmp_str = (gchar *)cr_font_family_to_string (a_this->font_family, TRUE);
        if (tmp_str) {
                g_string_append (str, tmp_str);
                g_free (tmp_str);
                tmp_str = NULL;
        } else {
                g_string_append (str, "NULL");
        }
        g_string_append (str, "\n");

        cr_utils_dump_n_chars2 (' ', str, indent);
        tmp_str = cr_font_size_to_string (&a_this->font_size.sv);
        if (tmp_str) {
                g_string_append_printf (str, "font-size {sv:%s, ",
                                        tmp_str) ;
        } else {
                g_string_append (str, "font-size {sv:NULL, ");
        }
        tmp_str = cr_font_size_to_string (&a_this->font_size.cv);
        if (tmp_str) {
                g_string_append_printf (str, "cv:%s, ", tmp_str);
        } else {
                g_string_append (str, "cv:NULL, ");
        }
        tmp_str = cr_font_size_to_string (&a_this->font_size.av);
        if (tmp_str) {
                g_string_append_printf (str, "av:%s}", tmp_str);
        } else {
                g_string_append (str, "av:NULL}");
        }

        tmp_str = NULL;
        g_string_append (str, "\n");

        cr_utils_dump_n_chars2 (' ', str, indent);
        tmp_str = cr_font_size_adjust_to_string (a_this->font_size_adjust);
        if (tmp_str) {
                g_string_append_printf (str, "font-size-adjust: %s", tmp_str);
        } else {
                g_string_append (str, "font-size-adjust: NULL");
        }
        tmp_str = NULL;
        g_string_append (str, "\n");

        cr_utils_dump_n_chars2 (' ', str, indent);
        tmp_str = (gchar *) cr_font_style_to_string (a_this->font_style);
        if (tmp_str) {
                g_string_append_printf (str, "font-style: %s", tmp_str);
        } else {
                g_string_append (str, "font-style: NULL");
        }
        tmp_str = NULL;
        g_string_append (str, "\n");

        cr_utils_dump_n_chars2 (' ', str, indent);
        tmp_str = (gchar *) cr_font_variant_to_string (a_this->font_variant);
        if (tmp_str) {
                g_string_append_printf (str, "font-variant: %s", tmp_str);
        } else {
                g_string_append (str, "font-variant: NULL");
        }
        tmp_str = NULL;
        g_string_append (str, "\n");

        cr_utils_dump_n_chars2 (' ', str, indent);
        tmp_str = (gchar *) cr_font_weight_to_string (a_this->font_weight);
        if (tmp_str) {
                g_string_append_printf (str, "font-weight: %s", tmp_str);
        } else {
                g_string_append (str, "font-weight: NULL");
        }
        tmp_str = NULL;
        g_string_append (str, "\n");

        cr_utils_dump_n_chars2 (' ', str, indent);
        tmp_str = (gchar *) cr_font_stretch_to_string (a_this->font_stretch);
        if (tmp_str) {
                g_string_append_printf (str, "font-stretch: %s", tmp_str);
        } else {
                g_string_append (str, "font-stretch: NULL");
        }
        tmp_str = NULL;
        g_string_append (str, "\n");


        cr_utils_dump_n_chars2 (' ', str, a_nb_indent);
        g_string_append (str, "}");

        return CR_OK;
}


Generated by  Doxygen 1.6.0   Back to index