summaryrefslogtreecommitdiffstats
path: root/src/file.cpp
diff options
context:
space:
mode:
authorMaximilian Albert <maximilian.albert@gmail.com>2009-08-06 14:17:17 +0000
committercilix42 <cilix42@users.sourceforge.net>2009-08-06 14:17:17 +0000
commit51c2905fd3e99955db2d823b79abb763d8097028 (patch)
tree90128509479f5498e1125d1e4eb9cdc05bf6b6e6 /src/file.cpp
parentAdding one more control to Smart Jelly (diff)
downloadinkscape-51c2905fd3e99955db2d823b79abb763d8097028.tar.gz
inkscape-51c2905fd3e99955db2d823b79abb763d8097028.zip
Revert recent refactoring changes by johnce because they break the build, which cannot be fixed easily.
(bzr r8422)
Diffstat (limited to 'src/file.cpp')
-rw-r--r--src/file.cpp179
1 files changed, 19 insertions, 160 deletions
diff --git a/src/file.cpp b/src/file.cpp
index 22425547e..049c1acb4 100644
--- a/src/file.cpp
+++ b/src/file.cpp
@@ -1,4 +1,3 @@
-
/** @file
* @brief File/Print operations
*/
@@ -66,14 +65,6 @@
#include "uri.h"
#include "xml/rebase-hrefs.h"
-#include "streams-handles.h"
-#include "streams-webdav.h"
-#include "streams-ftp.h"
-#include "streams-http.h"
-
-//#include "buffersystem.h"
-#include <cstring>
-
#ifdef WITH_GNOME_VFS
# include <libgnomevfs/gnome-vfs.h>
#endif
@@ -128,7 +119,7 @@ sp_file_new(const Glib::ustring &templ)
char *templName = NULL;
if (templ.size()>0)
templName = (char *)templ.c_str();
- Document *doc = sp_document_new(templName, TRUE, true);
+ SPDocument *doc = sp_document_new(templName, TRUE, true);
g_return_val_if_fail(doc != NULL, NULL);
SPDesktop *dt;
@@ -210,7 +201,7 @@ sp_file_open(const Glib::ustring &uri,
if (desktop)
desktop->setWaitingCursor();
- Document *doc = NULL;
+ SPDocument *doc = NULL;
try {
doc = Inkscape::Extension::open(key, uri.c_str());
} catch (Inkscape::Extension::Input::no_extension_found &e) {
@@ -223,7 +214,7 @@ sp_file_open(const Glib::ustring &uri,
desktop->clearWaitingCursor();
if (doc) {
- Document *existing = desktop ? sp_desktop_document(desktop) : NULL;
+ SPDocument *existing = desktop ? sp_desktop_document(desktop) : NULL;
if (existing && existing->virgin && replace_empty) {
// If the current desktop is empty, open the document there
@@ -263,137 +254,6 @@ sp_file_open(const Glib::ustring &uri,
}
}
-
-
-
-//NOTE1
-bool
-sp_file_open_uri(const Inkscape::URI &uri,
- Inkscape::Extension::Extension *key,
- bool add_to_recent, bool replace_empty)
-{
- Document *doc = NULL;
- try {
- doc = Inkscape::Extension::open(key, uri.toNativeFilename());
- } catch (Inkscape::Extension::Input::no_extension_found &e) {
- doc = NULL;
- } catch (Inkscape::Extension::Input::open_failed &e) {
- doc = NULL;
- }
-
- //FIXME1 KLUDGE switch
-
- //WebDAV
- /*
- if (std::strstr(uri.toString(), "http") != NULL)
- {
- if (strcmp(uri.toString(), "/http") >= 5//FIXME3 skip begining '/'
- ||
- strcmp(uri.toString(), "http") >= 4
- )
- {
-
- std::cout<<"+++ 'http' uri.toString->"<<uri.toString()<<std::endl;
-
- Inkscape::WebDAVBuffer wbuf;
- Inkscape::iwebdavstream *iws = new Inkscape::iwebdavstream(wbuf);
- Inkscape::BufferSystem bs(iws);
- bs.onInputStream();
- }
-
- } else*/
- std::cout<<"--> FTP , HTTP etc."<<std::endl;
-
- //FTP
- if (std::strstr(uri.toString(), "ftp") != NULL)
- {
- if (strcmp(uri.toString(), "/ftp") >= 4//FIXME3 skip begining '/'
- ||
- strcmp(uri.toString(), "ftp") >= 3
- )
- {
- std::cout<<"+++ 'ftp' uri.toString->"<<uri.toString()<<std::endl;
-
- Inkscape::FTPBuffer wbuf;
- Inkscape::iftpstream *iws = new Inkscape::iftpstream(wbuf);
- char *buf = new char[8192];
- *iws >> buf;
- std::cout<<"buf->"<<buf<<std::endl;
-
- //Inkscape::BufferSystem bs(iws);
- //bs.onInputStream();
- }
- //HTTP
- } else if (std::strstr(uri.toString(), "http") != NULL)
- {
- if (strcmp(uri.toString(), "/http") >= 5//FIXME3 skip begining '/'
- ||
- strcmp(uri.toString(), "http") >= 4
- )
- {
- std::cout<<"+++ 'http' uri.toString->"<<uri.toString()<<std::endl;
-
-/* Inkscape::HTTPBuffer wbuf;
- Inkscape::ihttpstream *iws = new Inkscape::ihttpstream(wbuf);
- char *buf = new char[8192];
- *iws >> buf;
- std::cout<<"buf->"<<buf<<std::endl;
-*/
- //Inkscape::BufferSystem bs(iws);
- //bs.onInputStream();
- }
-
- } /*else if ()
- {
-
- } */
-
-
-
- if (doc) {
- SPDesktop *desktop = SP_ACTIVE_DESKTOP;
- Document *existing = desktop ? sp_desktop_document(desktop) : NULL;
-
- if (existing && existing->virgin && replace_empty) {
- // If the current desktop is empty, open the document there
- sp_document_ensure_up_to_date (doc);
- desktop->change_document(doc);
- sp_document_resized_signal_emit (doc, sp_document_width(doc), sp_document_height(doc));
- } else {
- if (!Inkscape::NSApplication::Application::getNewGui()) {
- // create a whole new desktop and window
- SPViewWidget *dtw = sp_desktop_widget_new(sp_document_namedview(doc, NULL));
- sp_create_window(dtw, TRUE);
- desktop = static_cast<SPDesktop*>(dtw->view);
- } else {
- desktop = Inkscape::NSApplication::Editor::createDesktop (doc);
- }
- }
-
- doc->virgin = FALSE;
- // everyone who cares now has a reference, get rid of ours
- sp_document_unref(doc);
- // resize the window to match the document properties
- sp_namedview_window_from_document(desktop);
- sp_namedview_update_layers_from_document(desktop);
-
- if (add_to_recent) {
-//--tullarisc prefs_set_recent_file(SP_DOCUMENT_URI(doc), SP_DOCUMENT_NAME(doc));
- }
-
- return TRUE;
- } else {
- //FIXME 1
- //gchar *safeUri = Inkscape::IO::sanitizeString(uri.toNativeFilename());
- //gchar *text = g_strdup_printf(_("Failed to load the requested file %s"), safeUri);
- //sp_ui_error_dialog(text);
- //g_free(text);
- //g_free(safeUri);
- return FALSE;
- }
-}
-
-
/**
* Handle prompting user for "do you want to revert"? Revert on "OK"
*/
@@ -403,7 +263,7 @@ sp_file_revert_dialog()
SPDesktop *desktop = SP_ACTIVE_DESKTOP;
g_assert(desktop != NULL);
- Document *doc = sp_desktop_document(desktop);
+ SPDocument *doc = sp_desktop_document(desktop);
g_assert(doc != NULL);
Inkscape::XML::Node *repr = sp_document_repr_root(doc);
@@ -537,7 +397,6 @@ void dump_ustr(Glib::ustring const &ustr)
/**
* Display an file Open selector. Open a document if OK is pressed.
* Can select single or multiple files for opening.
- * NOTE1
*/
void
sp_file_open_dialog(Gtk::Window &parentWindow, gpointer /*object*/, gpointer /*data*/)
@@ -662,7 +521,7 @@ sp_file_open_dialog(Gtk::Window &parentWindow, gpointer /*object*/, gpointer /*d
open_path.append(G_DIR_SEPARATOR_S);
prefs->setString("/dialogs/open/path", open_path);
- sp_file_open_uri(Inkscape::URI(fileName.c_str()), selection);
+ sp_file_open(fileName, selection);
}
return;
@@ -681,7 +540,7 @@ sp_file_open_dialog(Gtk::Window &parentWindow, gpointer /*object*/, gpointer /*d
void
sp_file_vacuum()
{
- Document *doc = SP_ACTIVE_DOCUMENT;
+ SPDocument *doc = SP_ACTIVE_DOCUMENT;
unsigned int diff = vacuum_document (doc);
@@ -713,7 +572,7 @@ sp_file_vacuum()
* document; is true for normal save, false for temporary saves
*/
static bool
-file_save(Gtk::Window &parentWindow, Document *doc, const Glib::ustring &uri,
+file_save(Gtk::Window &parentWindow, SPDocument *doc, const Glib::ustring &uri,
Inkscape::Extension::Extension *key, bool saveas, bool official)
{
if (!doc || uri.size()<1) //Safety check
@@ -755,7 +614,7 @@ file_save(Gtk::Window &parentWindow, Document *doc, const Glib::ustring &uri,
* Used only for remote saving using VFS and a specific uri. Gets the file at the /tmp.
*/
bool
-file_save_remote(Document */*doc*/,
+file_save_remote(SPDocument */*doc*/,
#ifdef WITH_GNOME_VFS
const Glib::ustring &uri,
#else
@@ -843,7 +702,7 @@ file_save_remote(Document */*doc*/,
* \param ascopy (optional) wether to set the documents->uri to the new filename or not
*/
bool
-sp_file_save_dialog(Gtk::Window &parentWindow, Document *doc, bool is_copy)
+sp_file_save_dialog(Gtk::Window &parentWindow, SPDocument *doc, bool is_copy)
{
Inkscape::XML::Node *repr = sp_document_repr_root(doc);
@@ -978,7 +837,7 @@ sp_file_save_dialog(Gtk::Window &parentWindow, Document *doc, bool is_copy)
* Save a document, displaying a SaveAs dialog if necessary.
*/
bool
-sp_file_save_document(Gtk::Window &parentWindow, Document *doc)
+sp_file_save_document(Gtk::Window &parentWindow, SPDocument *doc)
{
bool success = true;
@@ -1054,13 +913,13 @@ sp_file_save_a_copy(Gtk::Window &parentWindow, gpointer /*object*/, gpointer /*d
* Import a resource. Called by sp_file_import()
*/
void
-file_import(Document *in_doc, const Glib::ustring &uri,
+file_import(SPDocument *in_doc, const Glib::ustring &uri,
Inkscape::Extension::Extension *key)
{
SPDesktop *desktop = SP_ACTIVE_DESKTOP;
//DEBUG_MESSAGE( fileImport, "file_import( in_doc:%p uri:[%s], key:%p", in_doc, uri, key );
- Document *doc;
+ SPDocument *doc;
try {
doc = Inkscape::Extension::open(key, uri.c_str());
} catch (Inkscape::Extension::Input::no_extension_found &e) {
@@ -1070,7 +929,7 @@ file_import(Document *in_doc, const Glib::ustring &uri,
}
if (doc != NULL) {
- Inkscape::XML::rebase_hrefs((Inkscape::XML::Document *)doc, in_doc->base, true);
+ Inkscape::XML::rebase_hrefs(doc, in_doc->base, true);
Inkscape::XML::Document *xml_in_doc = sp_document_repr_doc(in_doc);
prevent_id_clashes(doc, in_doc);
@@ -1191,7 +1050,7 @@ sp_file_import(Gtk::Window &parentWindow)
{
static Glib::ustring import_path;
- Document *doc = SP_ACTIVE_DOCUMENT;
+ SPDocument *doc = SP_ACTIVE_DOCUMENT;
if (!doc)
return;
@@ -1274,7 +1133,7 @@ bool
sp_file_export_dialog(void *widget)
{
//# temp hack for 'doc' until we can switch to this dialog
- Document *doc = SP_ACTIVE_DOCUMENT;
+ SPDocument *doc = SP_ACTIVE_DOCUMENT;
Glib::ustring export_path;
Glib::ustring export_loc;
@@ -1410,7 +1269,7 @@ sp_file_export_to_ocal_dialog(Gtk::Window &parentWindow)
if (!SP_ACTIVE_DOCUMENT)
return false;
- Document *doc = SP_ACTIVE_DOCUMENT;
+ SPDocument *doc = SP_ACTIVE_DOCUMENT;
Glib::ustring export_path;
Glib::ustring export_loc;
@@ -1568,7 +1427,7 @@ sp_file_import_from_ocal(Gtk::Window &parentWindow)
{
static Glib::ustring import_path;
- Document *doc = SP_ACTIVE_DOCUMENT;
+ SPDocument *doc = SP_ACTIVE_DOCUMENT;
if (!doc)
return;
@@ -1626,7 +1485,7 @@ sp_file_import_from_ocal(Gtk::Window &parentWindow)
void
sp_file_print(Gtk::Window& parentWindow)
{
- Document *doc = SP_ACTIVE_DOCUMENT;
+ SPDocument *doc = SP_ACTIVE_DOCUMENT;
if (doc)
sp_print_document(parentWindow, doc);
}
@@ -1639,7 +1498,7 @@ void
sp_file_print_preview(gpointer /*object*/, gpointer /*data*/)
{
- Document *doc = SP_ACTIVE_DOCUMENT;
+ SPDocument *doc = SP_ACTIVE_DOCUMENT;
if (doc)
sp_print_preview_document(doc);