summaryrefslogtreecommitdiffstats
path: root/src/xml/repr-css.cpp
diff options
context:
space:
mode:
authorsu_v <suv-sf@users.sourceforge.net>2014-06-15 09:08:03 +0000
committer~suv <suv-sf@users.sourceforge.net>2014-06-15 09:08:03 +0000
commitccacefacda584c206625b7759001d3d8c531cfed (patch)
tree8c00cc50f5bb400b62639c06c234d11fa982502b /src/xml/repr-css.cpp
parentupdate to trunk (r13407) (diff)
parentAllow symbol zooming independent of icon screen size. (diff)
downloadinkscape-ccacefacda584c206625b7759001d3d8c531cfed.tar.gz
inkscape-ccacefacda584c206625b7759001d3d8c531cfed.zip
update to trunk (r13425)
(bzr r13398.1.3)
Diffstat (limited to 'src/xml/repr-css.cpp')
-rw-r--r--src/xml/repr-css.cpp32
1 files changed, 17 insertions, 15 deletions
diff --git a/src/xml/repr-css.cpp b/src/xml/repr-css.cpp
index e462f70da..c043904a7 100644
--- a/src/xml/repr-css.cpp
+++ b/src/xml/repr-css.cpp
@@ -283,14 +283,7 @@ void sp_repr_css_write_string(SPCSSAttr *css, Glib::ustring &str)
str.append(g_quark_to_string(iter->key));
str.push_back(':');
- if (!strcmp(g_quark_to_string(iter->key), "font-family")
- || !strcmp(g_quark_to_string(iter->key), "-inkscape-font-specification")) {
- // we only quote font-family/font-specification, as SPStyle does
- Glib::ustring val_quoted = css2_escape_quote (iter->value);
- str.append(val_quoted);
- } else {
- str.append(iter->value); // unquoted
- }
+ str.append(iter->value); // Any necessary quoting to be done by calling routine.
if (rest(iter)) {
str.push_back(';');
@@ -346,13 +339,23 @@ void sp_repr_css_merge(SPCSSAttr *dst, SPCSSAttr *src)
/**
* Merges style properties as parsed by libcroco into an existing SPCSSAttr.
+ * libcroco converts all single quotes to double quotes, which needs to be
+ * undone as we always use single quotes inside our 'style' strings since
+ * double quotes are used outside: e.g.:
+ * style="font-family:'DejaVu Sans'"
*/
static void sp_repr_css_merge_from_decl(SPCSSAttr *css, CRDeclaration const *const decl)
{
guchar *const str_value_unsigned = cr_term_to_string(decl->value);
- Glib::ustring value_unquoted( reinterpret_cast<gchar *>(str_value_unsigned ) );
- css_unquote( value_unquoted ); // libcroco returns strings quoted in "", remove
+ Glib::ustring value( reinterpret_cast<gchar *>(str_value_unsigned ) );
+ g_free(str_value_unsigned);
+
+ Glib::ustring::size_type pos = 0;
+ while( (pos=value.find("\"",pos)) != Glib::ustring::npos) {
+ value.replace(pos,1,"'");
+ ++pos;
+ }
Glib::ustring units;
@@ -363,11 +366,11 @@ static void sp_repr_css_merge_from_decl(SPCSSAttr *css, CRDeclaration const *con
*
* HACK for now is to strip off em and ex units and add them back at the end
*/
- int le = value_unquoted.length();
+ int le = value.length();
if (le > 2) {
- units = value_unquoted.substr(le-2, 2);
+ units = value.substr(le-2, 2);
if ((units == "em") || (units == "ex")) {
- value_unquoted = value_unquoted.substr(0, le-2);
+ value = value.substr(0, le-2);
}
else {
units.clear();
@@ -378,7 +381,7 @@ static void sp_repr_css_merge_from_decl(SPCSSAttr *css, CRDeclaration const *con
// CSSOStringStream is used here to write valid CSS (as in sp_style_write_string). This has
// the additional benefit of respecting the numerical precission set in the SVG Output
// preferences. We assume any numerical part comes first (if not, the whole string is copied).
- std::stringstream ss( value_unquoted );
+ std::stringstream ss( value );
double number = 0;
std::string characters;
std::string temp;
@@ -400,7 +403,6 @@ static void sp_repr_css_merge_from_decl(SPCSSAttr *css, CRDeclaration const *con
//g_message("sp_repr_css_merge_from_decl looks like em or ex units %s --> %s", str_value, os.str().c_str());
}
((Node *) css)->setAttribute(decl->property->stryng->str, os.str().c_str(), false);
- g_free(str_value_unsigned);
}
/**