diff options
Diffstat (limited to 'src/file.cpp')
| -rw-r--r-- | src/file.cpp | 23 |
1 files changed, 22 insertions, 1 deletions
diff --git a/src/file.cpp b/src/file.cpp index 4feb36f9d..189e1d261 100644 --- a/src/file.cpp +++ b/src/file.cpp @@ -10,9 +10,10 @@ * Stephen Silver <sasilver@users.sourceforge.net> * Jon A. Cruz <jon@joncruz.org> * Abhishek Sharma + * David Xiong * * Copyright (C) 2006 Johan Engelen <johan@shouraizou.nl> - * Copyright (C) 1999-2008 Authors + * Copyright (C) 1999-2012 Authors * Copyright (C) 2004 David Turner * Copyright (C) 2001-2002 Ximian, Inc. * @@ -731,6 +732,19 @@ file_save_remote(SPDocument */*doc*/, /** + * Check if a string ends with another string. + * \todo Find a better code file to put this general purpose method + */ +static bool hasEnding (Glib::ustring const &fullString, Glib::ustring const &ending) +{ + if (fullString.length() > ending.length()) { + return (0 == fullString.compare (fullString.length() - ending.length(), ending.length(), ending)); + } else { + return false; + } +} + +/** * Display a SaveAs dialog. Save the document if OK pressed. */ bool @@ -842,6 +856,13 @@ sp_file_save_dialog(Gtk::Window &parentWindow, SPDocument *doc, Inkscape::Extens else g_warning( "Error converting save filename to UTF-8." ); + Inkscape::Extension::Output *omod = dynamic_cast<Inkscape::Extension::Output *>(selectionType); + Glib::ustring save_extension = (std::string)omod->get_extension(); + + if ( !hasEnding(fileName, save_extension.c_str()) ) { + fileName += save_extension.c_str(); + } + // FIXME: does the argument !is_copy really convey the correct meaning here? success = file_save(parentWindow, doc, fileName, selectionType, TRUE, !is_copy, save_method); |
