summaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorsu_v <suv-sf@users.sourceforge.net>2014-06-04 12:14:53 +0000
committer~suv <suv-sf@users.sourceforge.net>2014-06-04 12:14:53 +0000
commitec110c32bcb154b3b6b7311a3de58222db329729 (patch)
tree2ebc5cfd5413ab5333f02cd67966413cb320a07c /src
parentPort inkscape to librevenge framework for WPG, CDR and VSD imports (diff)
parentinkscape.pre0 build failures for win32 nsis (diff)
downloadinkscape-ec110c32bcb154b3b6b7311a3de58222db329729.tar.gz
inkscape-ec110c32bcb154b3b6b7311a3de58222db329729.zip
update to trunk (r13407)
(bzr r13398.1.2)
Diffstat (limited to 'src')
-rw-r--r--src/extension/internal/pdfinput/pdf-parser.cpp54
-rw-r--r--src/libnrtype/font-lister.cpp40
-rw-r--r--src/main.cpp1
-rw-r--r--src/style-internal.cpp17
-rw-r--r--src/style.cpp52
-rw-r--r--src/style.h4
-rw-r--r--src/ui/tool/node.h8
-rw-r--r--src/widgets/text-toolbar.cpp1
-rw-r--r--src/xml/repr-css.cpp20
9 files changed, 116 insertions, 81 deletions
diff --git a/src/extension/internal/pdfinput/pdf-parser.cpp b/src/extension/internal/pdfinput/pdf-parser.cpp
index b398486e6..c5f03e5aa 100644
--- a/src/extension/internal/pdfinput/pdf-parser.cpp
+++ b/src/extension/internal/pdfinput/pdf-parser.cpp
@@ -866,7 +866,9 @@ void PdfParser::opSetExtGState(Object args[], int /*numArgs*/)
GBool isolated = gFalse;
GBool knockout = gFalse;
if (!obj4.dictLookup(const_cast<char*>("CS"), &obj5)->isNull()) {
-#if defined(POPPLER_NEW_COLOR_SPACE_API) || defined(POPPLER_NEW_ERRORAPI)
+#if defined(POPPLER_EVEN_NEWER_COLOR_SPACE_API)
+ blendingColorSpace = GfxColorSpace::parse(&obj5, NULL, NULL);
+#elif defined(POPPLER_NEW_COLOR_SPACE_API) || defined(POPPLER_NEW_ERRORAPI)
blendingColorSpace = GfxColorSpace::parse(&obj5, NULL);
#else
blendingColorSpace = GfxColorSpace::parse(&obj5);
@@ -1100,7 +1102,13 @@ void PdfParser::opSetFillColorSpace(Object args[], int /*numArgs*/)
res->lookupColorSpace(args[0].getName(), &obj);
GfxColorSpace *colorSpace = 0;
-#if defined(POPPLER_NEW_COLOR_SPACE_API) || defined(POPPLER_NEW_ERRORAPI)
+#if defined(POPPLER_EVEN_NEWER_COLOR_SPACE_API)
+ if (obj.isNull()) {
+ colorSpace = GfxColorSpace::parse(&args[0], NULL, NULL);
+ } else {
+ colorSpace = GfxColorSpace::parse(&obj, NULL, NULL);
+ }
+#elif defined(POPPLER_NEW_COLOR_SPACE_API) || defined(POPPLER_NEW_ERRORAPI)
if (obj.isNull()) {
colorSpace = GfxColorSpace::parse(&args[0], NULL);
} else {
@@ -1137,7 +1145,13 @@ void PdfParser::opSetStrokeColorSpace(Object args[], int /*numArgs*/)
state->setStrokePattern(NULL);
res->lookupColorSpace(args[0].getName(), &obj);
-#if defined(POPPLER_NEW_COLOR_SPACE_API) || defined(POPPLER_NEW_ERRORAPI)
+#if defined(POPPLER_EVEN_NEWER_COLOR_SPACE_API)
+ if (obj.isNull()) {
+ colorSpace = GfxColorSpace::parse(&args[0], NULL, NULL);
+ } else {
+ colorSpace = GfxColorSpace::parse(&obj, NULL, NULL);
+ }
+#elif defined(POPPLER_NEW_COLOR_SPACE_API) || defined(POPPLER_NEW_ERRORAPI)
if (obj.isNull()) {
colorSpace = GfxColorSpace::parse(&args[0], NULL);
} else {
@@ -1231,7 +1245,13 @@ void PdfParser::opSetFillColorN(Object args[], int numArgs) {
builder->updateStyle(state);
}
GfxPattern *pattern;
-#if defined(POPPLER_NEW_COLOR_SPACE_API) || defined(POPPLER_NEW_ERRORAPI)
+#if defined(POPPLER_EVEN_NEWER_COLOR_SPACE_API)
+ if (args[numArgs-1].isName() &&
+ (pattern = res->lookupPattern(args[numArgs-1].getName(), NULL, NULL))) {
+ state->setFillPattern(pattern);
+ builder->updateStyle(state);
+ }
+#elif defined(POPPLER_NEW_COLOR_SPACE_API) || defined(POPPLER_NEW_ERRORAPI)
if (args[numArgs-1].isName() &&
(pattern = res->lookupPattern(args[numArgs-1].getName(), NULL))) {
state->setFillPattern(pattern);
@@ -1291,7 +1311,13 @@ void PdfParser::opSetStrokeColorN(Object args[], int numArgs) {
builder->updateStyle(state);
}
GfxPattern *pattern;
-#if defined(POPPLER_NEW_COLOR_SPACE_API) || defined(POPPLER_NEW_ERRORAPI)
+#if defined(POPPLER_EVEN_NEWER_COLOR_SPACE_API)
+ if (args[numArgs-1].isName() &&
+ (pattern = res->lookupPattern(args[numArgs-1].getName(), NULL, NULL))) {
+ state->setStrokePattern(pattern);
+ builder->updateStyle(state);
+ }
+#elif defined(POPPLER_NEW_COLOR_SPACE_API) || defined(POPPLER_NEW_ERRORAPI)
if (args[numArgs-1].isName() &&
(pattern = res->lookupPattern(args[numArgs-1].getName(), NULL))) {
state->setStrokePattern(pattern);
@@ -1746,7 +1772,11 @@ void PdfParser::opShFill(Object args[], int /*numArgs*/)
double *matrix = NULL;
GBool savedState = gFalse;
-#if defined(POPPLER_NEW_COLOR_SPACE_API) || defined(POPPLER_NEW_ERRORAPI)
+#if defined(POPPLER_EVEN_NEWER_COLOR_SPACE_API)
+ if (!(shading = res->lookupShading(args[0].getName(), NULL, NULL))) {
+ return;
+ }
+#elif defined(POPPLER_NEW_COLOR_SPACE_API) || defined(POPPLER_NEW_ERRORAPI)
if (!(shading = res->lookupShading(args[0].getName(), NULL))) {
return;
}
@@ -2817,7 +2847,9 @@ void PdfParser::doImage(Object * /*ref*/, Stream *str, GBool inlineImg)
}
}
if (!obj1.isNull()) {
-#if defined(POPPLER_NEW_COLOR_SPACE_API) || defined(POPPLER_NEW_ERRORAPI)
+#if defined(POPPLER_EVEN_NEWER_COLOR_SPACE_API)
+ colorSpace = GfxColorSpace::parse(&obj1, NULL, NULL);
+#elif defined(POPPLER_NEW_COLOR_SPACE_API) || defined(POPPLER_NEW_ERRORAPI)
colorSpace = GfxColorSpace::parse(&obj1, NULL);
#else
colorSpace = GfxColorSpace::parse(&obj1);
@@ -2909,7 +2941,9 @@ void PdfParser::doImage(Object * /*ref*/, Stream *str, GBool inlineImg)
obj2.free();
}
}
-#if defined(POPPLER_NEW_COLOR_SPACE_API) || defined(POPPLER_NEW_ERRORAPI)
+#if defined(POPPLER_EVEN_NEWER_COLOR_SPACE_API)
+ GfxColorSpace *maskColorSpace = GfxColorSpace::parse(&obj1, NULL, NULL);
+#elif defined(POPPLER_NEW_COLOR_SPACE_API) || defined(POPPLER_NEW_ERRORAPI)
GfxColorSpace *maskColorSpace = GfxColorSpace::parse(&obj1, NULL);
#else
GfxColorSpace *maskColorSpace = GfxColorSpace::parse(&obj1);
@@ -3099,7 +3133,9 @@ void PdfParser::doForm(Object *str) {
if (obj1.dictLookup(const_cast<char*>("S"), &obj2)->isName(const_cast<char*>("Transparency"))) {
transpGroup = gTrue;
if (!obj1.dictLookup(const_cast<char*>("CS"), &obj3)->isNull()) {
-#if defined(POPPLER_NEW_COLOR_SPACE_API) || defined(POPPLER_NEW_ERRORAPI)
+#if defined(POPPLER_EVEN_NEWER_COLOR_SPACE_API)
+ blendingColorSpace = GfxColorSpace::parse(&obj3, NULL, NULL);
+#elif defined(POPPLER_NEW_COLOR_SPACE_API) || defined(POPPLER_NEW_ERRORAPI)
blendingColorSpace = GfxColorSpace::parse(&obj3, NULL);
#else
blendingColorSpace = GfxColorSpace::parse(&obj3);
diff --git a/src/libnrtype/font-lister.cpp b/src/libnrtype/font-lister.cpp
index 98589d9d7..333c4ef5b 100644
--- a/src/libnrtype/font-lister.cpp
+++ b/src/libnrtype/font-lister.cpp
@@ -83,6 +83,15 @@ namespace Inkscape
font_list_store->thaw_notify();
style_list_store = Gtk::ListStore::create (FontStyleList);
+
+ // Initialize style store with defaults
+ style_list_store->freeze_notify();
+ style_list_store->clear();
+ for (GList *l=default_styles; l; l = l->next) {
+ Gtk::TreeModel::iterator treeModelIter = style_list_store->append();
+ (*treeModelIter)[FontStyleList.styles] = (char*)l->data;
+ }
+ style_list_store->thaw_notify();
}
// Example of how to use "foreach_iter"
@@ -231,37 +240,12 @@ namespace Inkscape
font_list_store->thaw_notify();
}
- // FIXME: why do we parse the style attribute instead of the object's SPStyle?
void
FontLister::update_font_list_recursive( SPObject *r, std::list<Glib::ustring> *l ) {
- const gchar *style = r->getRepr()->attribute("style");
- if( style != NULL ) {
-
- std::vector<Glib::ustring> tokens = Glib::Regex::split_simple(";", style );
- for( size_t i=0; i < tokens.size(); ++i ) {
-
- Glib::ustring token = tokens[i];
- size_t found = token.find("font-family:");
-
- if( found != Glib::ustring::npos ) {
-
- // Remove "font-family:"
- token.erase(found,12);
-
- // Remove any leading single or double quote
- if( token[0] == '\'' || token[0] == '"' ) {
- token.erase(0,1);
- }
-
- // Remove any trailing single or double quote
- if( token[token.length()-1] == '\'' || token[token.length()-1] == '"' ) {
- token.erase(token.length()-1);
- }
-
- l->push_back( token );
- }
- }
+ const gchar *font_family = r->style->font_family.value;
+ if( font_family ) {
+ l->push_back( Glib::ustring( font_family ) );
}
for (SPObject *child = r->firstChild(); child; child = child->getNext()) {
diff --git a/src/main.cpp b/src/main.cpp
index 6f4add4b1..517ba0506 100644
--- a/src/main.cpp
+++ b/src/main.cpp
@@ -1158,6 +1158,7 @@ static int sp_process_file_list(GSList *fl)
if (sp_export_text_to_path) {
GSList *items = NULL;
SPRoot *root = doc->getRoot();
+ doc->ensureUpToDate();
for ( SPObject *iter = root->firstChild(); iter ; iter = iter->getNext()) {
SPItem* item = (SPItem*) iter;
if (! (SP_IS_TEXT(item) || SP_IS_FLOWTEXT(item) || SP_IS_GROUP(item))) {
diff --git a/src/style-internal.cpp b/src/style-internal.cpp
index b15892128..8b4f3c1cd 100644
--- a/src/style-internal.cpp
+++ b/src/style-internal.cpp
@@ -648,9 +648,6 @@ SPIString::read( gchar const *str ) {
if( !str ) return;
- // libcroco puts quotes around some strings... remove
- gchar *str_unquoted = attribute_unquote(str);
-
if (!strcmp(str, "inherit")) {
set = true;
inherit = true;
@@ -658,10 +655,18 @@ SPIString::read( gchar const *str ) {
} else {
set = true;
inherit = false;
- value = g_strdup(str_unquoted);
- }
- g_free( str_unquoted );
+ // libcroco puts quotes around some strings... remove
+ Glib::ustring str_unquoted(str);
+ css_unquote( str_unquoted );
+
+ // Unquote individual family names, Pango always uses unquoted names.
+ if( name.compare( "font-family" ) == 0 ) {
+ css_font_family_unquote( str_unquoted );
+ }
+
+ value = g_strdup(str_unquoted.c_str());
+ }
}
diff --git a/src/style.cpp b/src/style.cpp
index 11b1dc440..8e4c89839 100644
--- a/src/style.cpp
+++ b/src/style.cpp
@@ -58,6 +58,8 @@
#include <2geom/math-utils.h>
+#include <glibmm/regex.h>
+
using Inkscape::CSSOStringStream;
using std::vector;
@@ -1824,31 +1826,43 @@ sp_css_attr_scale(SPCSSAttr *css, double ex)
}
-// Called in style.cpp, xml/repr-css.cpp
+// Called in style-internal.cpp, xml/repr-css.cpp
/**
- * Remove quotes and escapes from a string. Returned value must be g_free'd.
+ * Remove paired single and double quotes from a string, changing string in place.
* Note: in CSS (in style= and in stylesheets), unquoting and unescaping is done
* by libcroco, our CSS parser, though it adds a new pair of "" quotes for the strings
- * it parsed for us. So this function is only used to remove those quotes and for
- * presentation attributes, without any unescaping. (XML unescaping
- * (&amp; etc) is done by XML parser.)
+ * it parsed for us.
*/
-gchar *
-attribute_unquote(gchar const *val)
+void
+css_unquote(Glib::ustring &val)
{
- if (val) {
- if (*val == '\'' || *val == '"') {
- int l = strlen(val);
- if (l >= 2) {
- if ( ( val[0] == '"' && val[l - 1] == '"' ) ||
- ( val[0] == '\'' && val[l - 1] == '\'' ) ) {
- return (g_strndup (val+1, l-2));
- }
- }
- }
- }
+ if( val.size() > 1 &&
+ ( (val[0] == '"' && val[val.size()-1] == '"' ) ||
+ (val[0] == '\'' && val[val.size()-1] == '\'' ) ) ) {
- return (val? g_strdup (val) : NULL);
+ val.erase( 0, 1 );
+ val.erase( val.size()-1 );
+ }
+}
+
+// Called in style-internal.cpp, text-toolbar.cpp
+/**
+ * Remove paired single and double quotes from font names in font-family lists,
+ * changing string in place.
+ * Pango expects unquoted font family names. We use unquoted names in interface.
+ */
+void
+css_font_family_unquote(Glib::ustring &val)
+{
+ std::vector<Glib::ustring> tokens = Glib::Regex::split_simple("\\s*,\\s*", val );
+
+ val.erase();
+ for( unsigned i=0; i < tokens.size(); ++i ) {
+ css_unquote( tokens[i] );
+ val += tokens[i] + ", ";
+ }
+ if( val.size() > 1 )
+ val.erase( val.size() - 2 ); // Remove trailing ", "
}
// Called in style.cpp, xml/repr-css.cpp
diff --git a/src/style.h b/src/style.h
index 9e592b78f..506b90b44 100644
--- a/src/style.h
+++ b/src/style.h
@@ -292,7 +292,9 @@ void sp_style_unset_property_attrs(SPObject *o);
void sp_style_set_property_url (SPObject *item, gchar const *property, SPObject *linked, bool recursive);
-gchar *attribute_unquote(gchar const *val);
+void css_unquote( Glib::ustring &val ); // Remove quotes from CSS values (style-internal.cpp, xml/repr-css.cpp)
+void css_font_family_unquote( Glib::ustring &val ); // style-internal.cpp, text-toolbar.cpp
+
Glib::ustring css2_escape_quote(gchar const *val);
#endif // SEEN_SP_STYLE_H
diff --git a/src/ui/tool/node.h b/src/ui/tool/node.h
index 4582d998a..b2f338e2c 100644
--- a/src/ui/tool/node.h
+++ b/src/ui/tool/node.h
@@ -41,14 +41,6 @@ template <typename> class NodeIterator;
}
}
-#if HAVE_TR1_UNORDERED_SET
-namespace std {
-namespace tr1 {
-template <typename N> struct hash< Inkscape::UI::NodeIterator<N> >;
-}
-}
-#endif
-
namespace Inkscape {
namespace UI {
diff --git a/src/widgets/text-toolbar.cpp b/src/widgets/text-toolbar.cpp
index 3a4f315da..64a7cd5e7 100644
--- a/src/widgets/text-toolbar.cpp
+++ b/src/widgets/text-toolbar.cpp
@@ -134,6 +134,7 @@ static void sp_text_fontfamily_value_changed( Ink_ComboBoxEntry_Action *act, GOb
g_object_set_data( tbl, "freeze", GINT_TO_POINTER(TRUE) );
Glib::ustring new_family = ink_comboboxentry_action_get_active_text( act );
+ css_font_family_unquote( new_family ); // Remove quotes around font family names.
// TODO: Think about how to handle handle multiple selections. While
// the font-family may be the same for all, the styles might be different.
diff --git a/src/xml/repr-css.cpp b/src/xml/repr-css.cpp
index 32a1e7f5d..e462f70da 100644
--- a/src/xml/repr-css.cpp
+++ b/src/xml/repr-css.cpp
@@ -12,7 +12,7 @@
* changing an item in the List. Utility functions are provided to go back and forth between the
* two ways of representing properties (by a string or by a list).
*
- * Use sp_repr_write_string to go from a property list to a style string.
+ * Use sp_repr_css_write_string to go from a property list to a style string.
*
*/
@@ -350,9 +350,10 @@ void sp_repr_css_merge(SPCSSAttr *dst, SPCSSAttr *src)
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);
- gchar *const str_value = reinterpret_cast<gchar *>(str_value_unsigned);
- gchar *value_unquoted = attribute_unquote (str_value); // libcroco returns strings quoted in ""
- Glib::ustring value_unquoted2 = value_unquoted ? value_unquoted : Glib::ustring();
+
+ Glib::ustring value_unquoted( reinterpret_cast<gchar *>(str_value_unsigned ) );
+ css_unquote( value_unquoted ); // libcroco returns strings quoted in "", remove
+
Glib::ustring units;
/*
@@ -362,11 +363,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_unquoted2.length();
+ int le = value_unquoted.length();
if (le > 2) {
- units = value_unquoted2.substr(le-2, 2);
+ units = value_unquoted.substr(le-2, 2);
if ((units == "em") || (units == "ex")) {
- value_unquoted2 = value_unquoted2.substr(0, le-2);
+ value_unquoted = value_unquoted.substr(0, le-2);
}
else {
units.clear();
@@ -377,7 +378,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_unquoted2 );
+ std::stringstream ss( value_unquoted );
double number = 0;
std::string characters;
std::string temp;
@@ -399,8 +400,7 @@ 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(value_unquoted);
- g_free(str_value);
+ g_free(str_value_unsigned);
}
/**