summaryrefslogtreecommitdiffstats
path: root/src/file.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'src/file.cpp')
-rw-r--r--src/file.cpp34
1 files changed, 23 insertions, 11 deletions
diff --git a/src/file.cpp b/src/file.cpp
index 86df2ed44..43d1ddaaa 100644
--- a/src/file.cpp
+++ b/src/file.cpp
@@ -53,6 +53,7 @@
#include "path-prefix.h"
#include "preferences.h"
#include "print.h"
+#include "resource-manager.h"
#include "rdf.h"
#include "selection-chemistry.h"
#include "selection.h"
@@ -208,14 +209,14 @@ sp_file_exit()
* \param replace_empty if true, and the current desktop is empty, this document
* will replace the empty one.
*/
-bool
-sp_file_open(const Glib::ustring &uri,
- Inkscape::Extension::Extension *key,
- bool add_to_recent, bool replace_empty)
+bool sp_file_open(const Glib::ustring &uri,
+ Inkscape::Extension::Extension *key,
+ bool add_to_recent, bool replace_empty)
{
SPDesktop *desktop = SP_ACTIVE_DESKTOP;
- if (desktop)
+ if (desktop) {
desktop->setWaitingCursor();
+ }
SPDocument *doc = NULL;
try {
@@ -226,27 +227,30 @@ sp_file_open(const Glib::ustring &uri,
doc = NULL;
}
- if (desktop)
+ if (desktop) {
desktop->clearWaitingCursor();
+ }
if (doc) {
SPDocument *existing = desktop ? sp_desktop_document(desktop) : NULL;
if (existing && existing->virgin && replace_empty) {
// If the current desktop is empty, open the document there
- doc->ensureUpToDate();
+ doc->ensureUpToDate(); // TODO this will trigger broken link warnings, etc.
desktop->change_document(doc);
doc->emitResizedSignal(doc->getWidth(), doc->getHeight());
} else {
// create a whole new desktop and window
- SPViewWidget *dtw = sp_desktop_widget_new(sp_document_namedview(doc, NULL));
+ SPViewWidget *dtw = sp_desktop_widget_new(sp_document_namedview(doc, NULL)); // TODO this will trigger broken link warnings, etc.
sp_create_window(dtw, TRUE);
desktop = static_cast<SPDesktop*>(dtw->view);
}
doc->virgin = FALSE;
+
// everyone who cares now has a reference, get rid of ours
doc->doUnref();
+
// resize the window to match the document properties
sp_namedview_window_from_document(desktop);
sp_namedview_update_layers_from_document(desktop);
@@ -255,6 +259,14 @@ sp_file_open(const Glib::ustring &uri,
sp_file_add_recent( doc->getURI() );
}
+ if ( inkscape_use_gui() ) {
+ // Perform a fixup pass for hrefs.
+ if ( Inkscape::ResourceManager::getManager().fixupBrokenLinks(doc) ) {
+ Glib::ustring msg = _("Broken links have been changed to point to existing files.");
+ desktop->showInfoDialog(msg);
+ }
+ }
+
return TRUE;
} else {
gchar *safeUri = Inkscape::IO::sanitizeString(uri.c_str());
@@ -789,7 +801,7 @@ sp_file_save_dialog(Gtk::Window &parentWindow, SPDocument *doc, Inkscape::Extens
} else {
dialog_title = (char const *) _("Select file to save to");
}
- gchar* doc_title = doc->root->title();
+ gchar* doc_title = doc->getRoot()->title();
Inkscape::UI::Dialog::FileSaveDialog *saveDialog =
Inkscape::UI::Dialog::FileSaveDialog::create(
parentWindow,
@@ -962,7 +974,7 @@ file_import(SPDocument *in_doc, const Glib::ustring &uri,
prevent_id_clashes(doc, in_doc);
- SPObject *in_defs = SP_DOCUMENT_DEFS(in_doc);
+ SPObject *in_defs = in_doc->getDefs();
Inkscape::XML::Node *last_def = in_defs->getRepr()->lastChild();
SPCSSAttr *style = sp_css_attr_from_object(doc->getRoot());
@@ -1038,7 +1050,7 @@ file_import(SPDocument *in_doc, const Glib::ustring &uri,
// preserve parent and viewBox transformations
// c2p is identity matrix at this point unless ensureUpToDate is called
doc->ensureUpToDate();
- Geom::Affine affine = SP_ROOT(doc->getRoot())->c2p * SP_ITEM(place_to_insert)->i2doc_affine().inverse();
+ Geom::Affine affine = doc->getRoot()->c2p * SP_ITEM(place_to_insert)->i2doc_affine().inverse();
sp_selection_apply_affine(selection, desktop->dt2doc() * affine * desktop->doc2dt(), true, false);
// move to mouse pointer