From 9889ebe49ba2e8132d6e49ac97622e2f5bdb2e78 Mon Sep 17 00:00:00 2001 From: Nicolas Dufour Date: Wed, 29 Jul 2009 19:46:17 +0000 Subject: Fix for bug LP #383244 (patch by Hannes Hochreiner) (bzr r8360) --- src/ui/dialog/document-properties.cpp | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) (limited to 'src/ui/dialog/document-properties.cpp') diff --git a/src/ui/dialog/document-properties.cpp b/src/ui/dialog/document-properties.cpp index bb9ab4d02..423778276 100644 --- a/src/ui/dialog/document-properties.cpp +++ b/src/ui/dialog/document-properties.cpp @@ -653,7 +653,7 @@ void DocumentProperties::removeExternalScript(){ while ( current ) { SPObject* obj = SP_OBJECT(current->data); SPScript* script = (SPScript*) obj; - if (!name.compare(script->xlinkhref)){ + if (name == script->xlinkhref){ sp_repr_unparent(obj->repr); sp_document_done(SP_ACTIVE_DOCUMENT, SP_VERB_EDIT_REMOVE_EXTERNAL_SCRIPT, _("Remove external script")); } @@ -671,8 +671,12 @@ void DocumentProperties::populate_external_scripts_box(){ while ( current ) { SPObject* obj = SP_OBJECT(current->data); SPScript* script = (SPScript*) obj; - Gtk::TreeModel::Row row = *(_ExternalScriptsListStore->append()); - row[_ExternalScriptsListColumns.filenameColumn] = script->xlinkhref; + if (script->xlinkhref) + { + Gtk::TreeModel::Row row = *(_ExternalScriptsListStore->append()); + row[_ExternalScriptsListColumns.filenameColumn] = script->xlinkhref; + } + current = g_slist_next(current); } } -- cgit v1.2.3 From 4cd79453c07adefb912a4dbd0afb2e7c2722bd90 Mon Sep 17 00:00:00 2001 From: johnce Date: Wed, 5 Aug 2009 06:38:07 +0000 Subject: SPDocument->Document (bzr r8408) --- src/ui/dialog/document-properties.cpp | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'src/ui/dialog/document-properties.cpp') diff --git a/src/ui/dialog/document-properties.cpp b/src/ui/dialog/document-properties.cpp index 423778276..0e928a9eb 100644 --- a/src/ui/dialog/document-properties.cpp +++ b/src/ui/dialog/document-properties.cpp @@ -851,7 +851,7 @@ DocumentProperties::on_response (int id) } void -DocumentProperties::_handleDocumentReplaced(SPDesktop* desktop, SPDocument *document) +DocumentProperties::_handleDocumentReplaced(SPDesktop* desktop, Document *document) { Inkscape::XML::Node *repr = SP_OBJECT_REPR(sp_desktop_namedview(desktop)); repr->addListener(&_repr_events, this); @@ -915,7 +915,7 @@ DocumentProperties::onNewGrid() { SPDesktop *dt = getDesktop(); Inkscape::XML::Node *repr = SP_OBJECT_REPR(sp_desktop_namedview(dt)); - SPDocument *doc = sp_desktop_document(dt); + Document *doc = sp_desktop_document(dt); Glib::ustring typestring = _grids_combo_gridtype.get_active_text(); CanvasGrid::writeNewGridToRepr(repr, doc, CanvasGrid::getGridTypeFromName(typestring.c_str())); -- cgit v1.2.3 From 51c2905fd3e99955db2d823b79abb763d8097028 Mon Sep 17 00:00:00 2001 From: Maximilian Albert Date: Thu, 6 Aug 2009 14:17:17 +0000 Subject: Revert recent refactoring changes by johnce because they break the build, which cannot be fixed easily. (bzr r8422) --- src/ui/dialog/document-properties.cpp | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'src/ui/dialog/document-properties.cpp') diff --git a/src/ui/dialog/document-properties.cpp b/src/ui/dialog/document-properties.cpp index 0e928a9eb..423778276 100644 --- a/src/ui/dialog/document-properties.cpp +++ b/src/ui/dialog/document-properties.cpp @@ -851,7 +851,7 @@ DocumentProperties::on_response (int id) } void -DocumentProperties::_handleDocumentReplaced(SPDesktop* desktop, Document *document) +DocumentProperties::_handleDocumentReplaced(SPDesktop* desktop, SPDocument *document) { Inkscape::XML::Node *repr = SP_OBJECT_REPR(sp_desktop_namedview(desktop)); repr->addListener(&_repr_events, this); @@ -915,7 +915,7 @@ DocumentProperties::onNewGrid() { SPDesktop *dt = getDesktop(); Inkscape::XML::Node *repr = SP_OBJECT_REPR(sp_desktop_namedview(dt)); - Document *doc = sp_desktop_document(dt); + SPDocument *doc = sp_desktop_document(dt); Glib::ustring typestring = _grids_combo_gridtype.get_active_text(); CanvasGrid::writeNewGridToRepr(repr, doc, CanvasGrid::getGridTypeFromName(typestring.c_str())); -- cgit v1.2.3 From 7fb43b788ea98a46f3dbf9f431948abb167929fe Mon Sep 17 00:00:00 2001 From: "Jon A. Cruz" Date: Sun, 20 Sep 2009 00:12:39 +0000 Subject: Sanitize profile names for valid XML ids. Modified patch that addresses bug #405143. (bzr r8619) --- src/ui/dialog/document-properties.cpp | 41 ++++++++++++++++++++++++++++++++--- 1 file changed, 38 insertions(+), 3 deletions(-) (limited to 'src/ui/dialog/document-properties.cpp') diff --git a/src/ui/dialog/document-properties.cpp b/src/ui/dialog/document-properties.cpp index 423778276..105d220a9 100644 --- a/src/ui/dialog/document-properties.cpp +++ b/src/ui/dialog/document-properties.cpp @@ -381,8 +381,40 @@ DocumentProperties::populate_available_profiles(){ _menu.show_all(); } -void -DocumentProperties::linkSelectedProfile() +/** + * Cleans up name to remove disallowed characters. + * Some discussion at http://markmail.org/message/bhfvdfptt25kgtmj + * Allowed ASCII first characters: ':', 'A'-'Z', '_', 'a'-'z' + * Allowed ASCII remaining chars add: '-', '.', '0'-'9', + * + * @param str the string to clean up. + */ +static void sanitizeName( Glib::ustring& str ) +{ + if (str.size() > 1) { + char val = str.at(0); + if (((val < 'A') || (val > 'Z')) + && ((val < 'a') || (val > 'z')) + && (val != '_') + && (val != ':')) { + str.replace(0, 1, "_"); + } + for (Glib::ustring::size_type i = 1; i < str.size(); i++) { + char val = str.at(i); + if (((val < 'A') || (val > 'Z')) + && ((val < 'a') || (val > 'z')) + && ((val < '0') || (val > '9')) + && (val != '_') + && (val != ':') + && (val != '-') + && (val != '.')) { + str.replace(i, 1, "_"); + } + } + } +} + +void DocumentProperties::linkSelectedProfile() { //store this profile in the SVG document (create element in the XML) // TODO remove use of 'active' desktop @@ -396,7 +428,10 @@ DocumentProperties::linkSelectedProfile() } Inkscape::XML::Document *xml_doc = sp_document_repr_doc(desktop->doc()); Inkscape::XML::Node *cprofRepr = xml_doc->createElement("svg:color-profile"); - cprofRepr->setAttribute("name", (gchar*) _menu.get_active()->get_data("name")); + gchar* tmp = static_cast(_menu.get_active()->get_data("name")); + Glib::ustring nameStr = tmp ? tmp : "profile"; // TODO add some auto-numbering to avoid collisions + sanitizeName(nameStr); + cprofRepr->setAttribute("name", nameStr.c_str()); cprofRepr->setAttribute("xlink:href", (gchar*) _menu.get_active()->get_data("filepath")); // Checks whether there is a defs element. Creates it when needed -- cgit v1.2.3 From c81c39a0cb321c8d3ac45aa460d77451f5340aea Mon Sep 17 00:00:00 2001 From: "Jon A. Cruz" Date: Sun, 27 Sep 2009 04:19:01 +0000 Subject: Updated allowed icc-profile names to match recent grammars. Follow-up for bug #405143 (bzr r8656) --- src/ui/dialog/document-properties.cpp | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'src/ui/dialog/document-properties.cpp') diff --git a/src/ui/dialog/document-properties.cpp b/src/ui/dialog/document-properties.cpp index 105d220a9..7e31b874a 100644 --- a/src/ui/dialog/document-properties.cpp +++ b/src/ui/dialog/document-properties.cpp @@ -397,7 +397,7 @@ static void sanitizeName( Glib::ustring& str ) && ((val < 'a') || (val > 'z')) && (val != '_') && (val != ':')) { - str.replace(0, 1, "_"); + str.replace(0, 1, "-"); } for (Glib::ustring::size_type i = 1; i < str.size(); i++) { char val = str.at(i); @@ -408,7 +408,7 @@ static void sanitizeName( Glib::ustring& str ) && (val != ':') && (val != '-') && (val != '.')) { - str.replace(i, 1, "_"); + str.replace(i, 1, "-"); } } } -- cgit v1.2.3