diff options
| -rw-r--r-- | src/CMakeLists.txt | 1 | ||||
| -rw-r--r-- | src/document-private.h | 81 | ||||
| -rw-r--r-- | src/document-undo.cpp | 130 | ||||
| -rw-r--r-- | src/document.cpp | 182 | ||||
| -rw-r--r-- | src/document.h | 71 | ||||
| -rw-r--r-- | src/extension/internal/filter/filter.cpp | 3 | ||||
| -rw-r--r-- | src/ui/widget/entity-entry.cpp | 3 | ||||
| -rw-r--r-- | src/ui/widget/licensor.cpp | 3 |
8 files changed, 204 insertions, 270 deletions
diff --git a/src/CMakeLists.txt b/src/CMakeLists.txt index 1e7d78bcb..920674a93 100644 --- a/src/CMakeLists.txt +++ b/src/CMakeLists.txt @@ -122,7 +122,6 @@ set(inkscape_SRC desktop-style.h desktop.h device-manager.h - document-private.h document-subset.h document-undo.h document.h diff --git a/src/document-private.h b/src/document-private.h deleted file mode 100644 index a9b70714f..000000000 --- a/src/document-private.h +++ /dev/null @@ -1,81 +0,0 @@ -#ifndef SEEN_SP_DOCUMENT_PRIVATE_H -#define SEEN_SP_DOCUMENT_PRIVATE_H - -/* - * Seldom needed document data - * - * Authors: - * Lauris Kaplinski <lauris@kaplinski.com> - * Jon A. Cruz <jon@joncruz.org> - * - * Copyright (C) 1999-2002 Lauris Kaplinski - * Copyright (C) 2001-2002 Ximian, Inc. - * - * Released under GNU GPL, read the file 'COPYING' for more information - */ - -#include <map> -#include <set> -#include <string> -#include <cstddef> -#include <sigc++/sigc++.h> -#include "xml/event-fns.h" -#include "document.h" - -#include "composite-undo-stack-observer.h" - - -// XXX only for testing! -#include "console-output-undo-observer.h" - -class SPObject; - -namespace Inkscape { -namespace XML { -class Event; -} -} - -struct SPDocumentPrivate { - typedef std::map<GQuark, SPDocument::IDChangedSignal> IDChangedSignalMap; - typedef std::map<GQuark, SPDocument::ResourcesChangedSignal> ResourcesChangedSignalMap; - - std::map<std::string, SPObject *> iddef; - std::map<Inkscape::XML::Node *, SPObject *> reprdef; - - unsigned long serial; - - /** Dictionary of signals for id changes */ - IDChangedSignalMap id_changed_signals; - - /* Resources */ - std::map<std::string, std::vector<SPObject *> > resources; - ResourcesChangedSignalMap resources_changed_signals; - - sigc::signal<void> destroySignal; - SPDocument::ModifiedSignal modified_signal; - SPDocument::URISetSignal uri_set_signal; - SPDocument::ResizedSignal resized_signal; - SPDocument::ReconstructionStart _reconstruction_start_signal; - SPDocument::ReconstructionFinish _reconstruction_finish_signal; - SPDocument::CommitSignal commit_signal; - - /* Undo/Redo state */ - bool sensitive; /* If we save actions to undo stack */ - Inkscape::XML::Event * partial; /* partial undo log when interrupted */ - int history_size; - std::vector<Inkscape::Event *> undo; /* Undo stack of reprs */ - std::vector<Inkscape::Event *> redo; /* Redo stack of reprs */ - - /* Undo listener */ - Inkscape::CompositeUndoStackObserver undoStackObservers; - - // XXX only for testing! - Inkscape::ConsoleOutputUndoObserver console_output_undo_observer; - - bool seeking; - sigc::connection selChangeConnection; - sigc::connection desktopActivatedConnection; -}; - -#endif // SEEN_SP_DOCUMENT_PRIVATE_H diff --git a/src/document-undo.cpp b/src/document-undo.cpp index 50ae286df..b64e75dd0 100644 --- a/src/document-undo.cpp +++ b/src/document-undo.cpp @@ -46,7 +46,6 @@ #include <string> #include "xml/repr.h" -#include "document-private.h" #include "inkscape.h" #include "document-undo.h" #include "debug/event-tracker.h" @@ -62,21 +61,20 @@ void Inkscape::DocumentUndo::setUndoSensitive(SPDocument *doc, bool sensitive) { g_assert (doc != nullptr); - g_assert (doc->priv != nullptr); - if ( sensitive == doc->priv->sensitive ) + if ( sensitive == doc->sensitive ) return; if (sensitive) { sp_repr_begin_transaction (doc->rdoc); } else { - doc->priv->partial = sp_repr_coalesce_log ( - doc->priv->partial, + doc->partial = sp_repr_coalesce_log ( + doc->partial, sp_repr_commit_undoable (doc->rdoc) ); } - doc->priv->sensitive = sensitive; + doc->sensitive = sensitive; } /*TODO: Throughout the inkscape code tree set/get_undo_sensitive are used for @@ -88,9 +86,8 @@ void Inkscape::DocumentUndo::setUndoSensitive(SPDocument *doc, bool sensitive) bool Inkscape::DocumentUndo::getUndoSensitive(SPDocument const *document) { g_assert(document != nullptr); - g_assert(document->priv != nullptr); - return document->priv->sensitive; + return document->sensitive; } void Inkscape::DocumentUndo::done(SPDocument *doc, const unsigned int event_type, Glib::ustring const &event_description) @@ -139,8 +136,7 @@ void Inkscape::DocumentUndo::maybeDone(SPDocument *doc, const gchar *key, const Glib::ustring const &event_description) { g_assert (doc != nullptr); - g_assert (doc->priv != nullptr); - g_assert (doc->priv->sensitive); + g_assert (doc->sensitive); if ( key && !*key ) { g_warning("Blank undo key specified."); } @@ -153,22 +149,22 @@ void Inkscape::DocumentUndo::maybeDone(SPDocument *doc, const gchar *key, const DocumentUndo::clearRedo(doc); - Inkscape::XML::Event *log = sp_repr_coalesce_log (doc->priv->partial, sp_repr_commit_undoable (doc->rdoc)); - doc->priv->partial = nullptr; + Inkscape::XML::Event *log = sp_repr_coalesce_log (doc->partial, sp_repr_commit_undoable (doc->rdoc)); + doc->partial = nullptr; if (!log) { sp_repr_begin_transaction (doc->rdoc); return; } - if (key && !doc->actionkey.empty() && (doc->actionkey == key) && !doc->priv->undo.empty()) { - (doc->priv->undo.back())->event = - sp_repr_coalesce_log ((doc->priv->undo.back())->event, log); + if (key && !doc->actionkey.empty() && (doc->actionkey == key) && !doc->undo.empty()) { + (doc->undo.back())->event = + sp_repr_coalesce_log ((doc->undo.back())->event, log); } else { Inkscape::Event *event = new Inkscape::Event(log, event_type, event_description); - doc->priv->undo.push_back(event); - doc->priv->history_size++; - doc->priv->undoStackObservers.notifyUndoCommitEvent(event); + doc->undo.push_back(event); + doc->history_size++; + doc->undoStackObservers.notifyUndoCommitEvent(event); } if ( key ) { @@ -182,38 +178,36 @@ void Inkscape::DocumentUndo::maybeDone(SPDocument *doc, const gchar *key, const sp_repr_begin_transaction (doc->rdoc); - doc->priv->commit_signal.emit(); + doc->commit_signal.emit(); } void Inkscape::DocumentUndo::cancel(SPDocument *doc) { g_assert (doc != nullptr); - g_assert (doc->priv != nullptr); - g_assert (doc->priv->sensitive); + g_assert (doc->sensitive); sp_repr_rollback (doc->rdoc); - if (doc->priv->partial) { - sp_repr_undo_log (doc->priv->partial); + if (doc->partial) { + sp_repr_undo_log (doc->partial); doc->emitReconstructionFinish(); - sp_repr_free_log (doc->priv->partial); - doc->priv->partial = nullptr; + sp_repr_free_log (doc->partial); + doc->partial = nullptr; } sp_repr_begin_transaction (doc->rdoc); } static void finish_incomplete_transaction(SPDocument &doc) { - SPDocumentPrivate &priv=*doc.priv; Inkscape::XML::Event *log=sp_repr_commit_undoable(doc.rdoc); - if (log || priv.partial) { + if (log || doc.partial) { g_warning ("Incomplete undo transaction:"); - priv.partial = sp_repr_coalesce_log(priv.partial, log); - sp_repr_debug_print_log(priv.partial); - Inkscape::Event *event = new Inkscape::Event(priv.partial); - priv.undo.push_back(event); - priv.undoStackObservers.notifyUndoCommitEvent(event); - priv.partial = nullptr; + doc.partial = sp_repr_coalesce_log(doc.partial, log); + sp_repr_debug_print_log(doc.partial); + Inkscape::Event *event = new Inkscape::Event(doc.partial); + doc.undo.push_back(event); + doc.undoStackObservers.notifyUndoCommitEvent(event); + doc.partial = nullptr; } } @@ -229,8 +223,8 @@ static void perform_document_update(SPDocument &doc) { sp_repr_debug_print_log(update_log); //Coalesce the update changes with the last action performed by user - if (!doc.priv->undo.empty()) { - Inkscape::Event* undo_stack_top = doc.priv->undo.back(); + if (!doc.undo.empty()) { + Inkscape::Event* undo_stack_top = doc.undo.back(); undo_stack_top->event = sp_repr_coalesce_log(undo_stack_top->event, update_log); } else { sp_repr_free_log(update_log); @@ -248,26 +242,25 @@ gboolean Inkscape::DocumentUndo::undo(SPDocument *doc) EventTracker<SimpleEvent<Inkscape::Debug::Event::DOCUMENT> > tracker("undo"); g_assert (doc != nullptr); - g_assert (doc->priv != nullptr); - g_assert (doc->priv->sensitive); + g_assert (doc->sensitive); - doc->priv->sensitive = FALSE; - doc->priv->seeking = true; + doc->sensitive = FALSE; + doc->seeking = true; doc->actionkey.clear(); finish_incomplete_transaction(*doc); - if (! doc->priv->undo.empty()) { - Inkscape::Event *log = doc->priv->undo.back(); - doc->priv->undo.pop_back(); + if (! doc->undo.empty()) { + Inkscape::Event *log = doc->undo.back(); + doc->undo.pop_back(); sp_repr_undo_log (log->event); perform_document_update(*doc); - doc->priv->redo.push_back(log); + doc->redo.push_back(log); doc->setModifiedSinceSave(); - doc->priv->undoStackObservers.notifyUndoEvent(log); + doc->undoStackObservers.notifyUndoEvent(log); ret = TRUE; } else { @@ -276,8 +269,8 @@ gboolean Inkscape::DocumentUndo::undo(SPDocument *doc) sp_repr_begin_transaction (doc->rdoc); - doc->priv->sensitive = TRUE; - doc->priv->seeking = false; + doc->sensitive = TRUE; + doc->seeking = false; if (ret) INKSCAPE.external_change(); @@ -294,24 +287,23 @@ gboolean Inkscape::DocumentUndo::redo(SPDocument *doc) EventTracker<SimpleEvent<Inkscape::Debug::Event::DOCUMENT> > tracker("redo"); g_assert (doc != nullptr); - g_assert (doc->priv != nullptr); - g_assert (doc->priv->sensitive); + g_assert (doc->sensitive); - doc->priv->sensitive = FALSE; - doc->priv->seeking = true; + doc->sensitive = FALSE; + doc->seeking = true; doc->actionkey.clear(); finish_incomplete_transaction(*doc); - if (! doc->priv->redo.empty()) { - Inkscape::Event *log = doc->priv->redo.back(); - doc->priv->redo.pop_back(); + if (! doc->redo.empty()) { + Inkscape::Event *log = doc->redo.back(); + doc->redo.pop_back(); sp_repr_replay_log (log->event); - doc->priv->undo.push_back(log); + doc->undo.push_back(log); doc->setModifiedSinceSave(); - doc->priv->undoStackObservers.notifyRedoEvent(log); + doc->undoStackObservers.notifyRedoEvent(log); ret = TRUE; } else { @@ -320,8 +312,8 @@ gboolean Inkscape::DocumentUndo::redo(SPDocument *doc) sp_repr_begin_transaction (doc->rdoc); - doc->priv->sensitive = TRUE; - doc->priv->seeking = false; + doc->sensitive = TRUE; + doc->seeking = false; if (ret) { INKSCAPE.external_change(); @@ -333,26 +325,26 @@ gboolean Inkscape::DocumentUndo::redo(SPDocument *doc) void Inkscape::DocumentUndo::clearUndo(SPDocument *doc) { - if (! doc->priv->undo.empty()) - doc->priv->undoStackObservers.notifyClearUndoEvent(); - while (! doc->priv->undo.empty()) { - Inkscape::Event *e = doc->priv->undo.back(); - doc->priv->undo.pop_back(); + if (! doc->undo.empty()) + doc->undoStackObservers.notifyClearUndoEvent(); + while (! doc->undo.empty()) { + Inkscape::Event *e = doc->undo.back(); + doc->undo.pop_back(); delete e; - doc->priv->history_size--; + doc->history_size--; } } void Inkscape::DocumentUndo::clearRedo(SPDocument *doc) { - if (!doc->priv->redo.empty()) - doc->priv->undoStackObservers.notifyClearRedoEvent(); + if (!doc->redo.empty()) + doc->undoStackObservers.notifyClearRedoEvent(); - while (! doc->priv->redo.empty()) { - Inkscape::Event *e = doc->priv->redo.back(); - doc->priv->redo.pop_back(); + while (! doc->redo.empty()) { + Inkscape::Event *e = doc->redo.back(); + doc->redo.pop_back(); delete e; - doc->priv->history_size--; + doc->history_size--; } } diff --git a/src/document.cpp b/src/document.cpp index 5b8fe305c..35e57871f 100644 --- a/src/document.cpp +++ b/src/document.cpp @@ -43,7 +43,6 @@ #include "desktop.h" #include "io/dir-util.h" -#include "document-private.h" #include "document-undo.h" #include "file.h" #include "id-clash.h" @@ -105,7 +104,6 @@ SPDocument::SPDocument() : uri(nullptr), base(nullptr), name(nullptr), - priv(nullptr), // reset in ctor actionkey(), modified_id(0), rerouting_handler_id(0), @@ -121,27 +119,23 @@ SPDocument::SPDocument() : // This results in much better looking orthogonal connector paths. router->setRoutingPenalty(Avoid::segmentPenalty); - SPDocumentPrivate *p = new SPDocumentPrivate(); + _serial = next_serial++; - p->serial = next_serial++; - - p->sensitive = false; - p->partial = nullptr; - p->history_size = 0; - p->seeking = false; - - priv = p; + sensitive = false; + partial = nullptr; + history_size = 0; + seeking = false; // Once things are set, hook in the manager profileManager = new Inkscape::ProfileManager(this); // XXX only for testing! - priv->undoStackObservers.add(p->console_output_undo_observer); + undoStackObservers.add(console_output_undo_observer); _node_cache = std::deque<SPItem*>(); } SPDocument::~SPDocument() { - priv->destroySignal.emit(); + destroySignal.emit(); // kill/unhook this first if ( profileManager ) { @@ -155,33 +149,31 @@ SPDocument::~SPDocument() { } if (oldSignalsConnected) { - priv->selChangeConnection.disconnect(); - priv->desktopActivatedConnection.disconnect(); + selChangeConnection.disconnect(); + desktopActivatedConnection.disconnect(); } else { _selection_changed_connection.disconnect(); _desktop_activated_connection.disconnect(); } - if (priv) { - if (priv->partial) { - sp_repr_free_log(priv->partial); - priv->partial = nullptr; - } + if (partial) { + sp_repr_free_log(partial); + partial = nullptr; + } - DocumentUndo::clearRedo(this); - DocumentUndo::clearUndo(this); + DocumentUndo::clearRedo(this); + DocumentUndo::clearUndo(this); - if (root) { - root->releaseReferences(); - sp_object_unref(root); - root = nullptr; - } + if (root) { + root->releaseReferences(); + sp_object_unref(root); + root = nullptr; + } - if (rdoc) Inkscape::GC::release(rdoc); + if (rdoc) Inkscape::GC::release(rdoc); - /* Free resources */ - priv->resources.clear(); - } + /* Free resources */ + resources.clear(); // This also destroys all attached stylesheets cr_cascade_unref(style_cascade); @@ -226,7 +218,7 @@ SPDocument::~SPDocument() { sigc::connection SPDocument::connectDestroy(sigc::signal<void>::slot_type slot) { - return priv->destroySignal.connect(slot); + return destroySignal.connect(slot); } SPDefs *SPDocument::getDefs() @@ -281,7 +273,7 @@ void SPDocument::initialize_current_persp3d() **/ unsigned long SPDocument::serial() const { - return priv->serial; + return _serial; } void SPDocument::queueForOrphanCollection(SPObject *object) { @@ -455,11 +447,11 @@ SPDocument *SPDocument::createDoc(Inkscape::XML::Document *rdoc, DocumentUndo::setUndoSensitive(document, true); // reset undo key when selection changes, so that same-key actions on different objects are not coalesced - document->priv->selChangeConnection = INKSCAPE.signal_selection_changed.connect( + document->selChangeConnection = INKSCAPE.signal_selection_changed.connect( sigc::hide(sigc::bind( sigc::ptr_fun(&DocumentUndo::resetKey), document) )); - document->priv->desktopActivatedConnection = INKSCAPE.signal_activate_desktop.connect( + document->desktopActivatedConnection = INKSCAPE.signal_activate_desktop.connect( sigc::hide(sigc::bind( sigc::ptr_fun(&DocumentUndo::resetKey), document) )); @@ -696,7 +688,6 @@ void SPDocument::setWidthAndHeight(const Inkscape::Util::Quantity &width, const Inkscape::Util::Quantity SPDocument::getWidth() const { - g_return_val_if_fail(this->priv != nullptr, Inkscape::Util::Quantity(0.0, unit_table.getUnit(""))); g_return_val_if_fail(this->root != nullptr, Inkscape::Util::Quantity(0.0, unit_table.getUnit(""))); gdouble result = root->width.value; @@ -735,7 +726,6 @@ void SPDocument::setWidth(const Inkscape::Util::Quantity &width, bool changeSize Inkscape::Util::Quantity SPDocument::getHeight() const { - g_return_val_if_fail(this->priv != nullptr, Inkscape::Util::Quantity(0.0, unit_table.getUnit(""))); g_return_val_if_fail(this->root != nullptr, Inkscape::Util::Quantity(0.0, unit_table.getUnit(""))); gdouble result = root->height.value; @@ -924,7 +914,7 @@ void SPDocument::do_change_uri(gchar const *const filename, bool const rebase) this->base = new_base; this->uri = new_uri; - this->priv->uri_set_signal.emit(this->uri); + this->uri_set_signal.emit(this->uri); } /** @@ -952,52 +942,52 @@ void SPDocument::changeUriAndHrefs(gchar const *filename) void SPDocument::emitResizedSignal(gdouble width, gdouble height) { - this->priv->resized_signal.emit(width, height); + this->resized_signal.emit(width, height); } sigc::connection SPDocument::connectModified(SPDocument::ModifiedSignal::slot_type slot) { - return priv->modified_signal.connect(slot); + return modified_signal.connect(slot); } sigc::connection SPDocument::connectURISet(SPDocument::URISetSignal::slot_type slot) { - return priv->uri_set_signal.connect(slot); + return uri_set_signal.connect(slot); } sigc::connection SPDocument::connectResized(SPDocument::ResizedSignal::slot_type slot) { - return priv->resized_signal.connect(slot); + return resized_signal.connect(slot); } sigc::connection SPDocument::connectReconstructionStart(SPDocument::ReconstructionStart::slot_type slot) { - return priv->_reconstruction_start_signal.connect(slot); + return _reconstruction_start_signal.connect(slot); } void SPDocument::emitReconstructionStart() { // printf("Starting Reconstruction\n"); - priv->_reconstruction_start_signal.emit(); + _reconstruction_start_signal.emit(); return; } sigc::connection SPDocument::connectReconstructionFinish(SPDocument::ReconstructionFinish::slot_type slot) { - return priv->_reconstruction_finish_signal.connect(slot); + return _reconstruction_finish_signal.connect(slot); } void SPDocument::emitReconstructionFinish() { // printf("Finishing Reconstruction\n"); - priv->_reconstruction_finish_signal.emit(); + _reconstruction_finish_signal.emit(); // indicates that gradients are reloaded (to rebuild the Auto palette) - priv->resources_changed_signals[g_quark_from_string("gradient")].emit(); - priv->resources_changed_signals[g_quark_from_string("filter")].emit(); + resources_changed_signals[g_quark_from_string("gradient")].emit(); + resources_changed_signals[g_quark_from_string("filter")].emit(); /** @@ -1010,7 +1000,7 @@ SPDocument::emitReconstructionFinish() sigc::connection SPDocument::connectCommit(SPDocument::CommitSignal::slot_type slot) { - return priv->commit_signal.connect(slot); + return commit_signal.connect(slot); } @@ -1018,7 +1008,7 @@ sigc::connection SPDocument::connectCommit(SPDocument::CommitSignal::slot_type s void SPDocument::_emitModified() { static guint const flags = SP_OBJECT_MODIFIED_FLAG | SP_OBJECT_CHILD_MODIFIED_FLAG | SP_OBJECT_PARENT_MODIFIED_FLAG; root->emitModified(0); - priv->modified_signal.emit(flags); + modified_signal.emit(flags); _node_cache_valid=false; } @@ -1027,26 +1017,22 @@ void SPDocument::bindObjectToId(gchar const *id, SPObject *object) { if (object) { if(object->getId()) - priv->iddef.erase(object->getId()); - g_assert(priv->iddef.find(id)==priv->iddef.end()); - priv->iddef[id] = object; - //g_assert(g_hash_table_lookup(priv->iddef, GINT_TO_POINTER(idq)) == NULL); - //g_hash_table_insert(priv->iddef, GINT_TO_POINTER(idq), object); + iddef.erase(object->getId()); + g_assert(iddef.find(id)==iddef.end()); + iddef[id] = object; } else { - g_assert(priv->iddef.find(id)!=priv->iddef.end()); - priv->iddef.erase(id); - //g_assert(g_hash_table_lookup(priv->iddef, GINT_TO_POINTER(idq)) != NULL); - //g_hash_table_remove(priv->iddef, GINT_TO_POINTER(idq)); + g_assert(iddef.find(id)!=iddef.end()); + iddef.erase(id); } - SPDocumentPrivate::IDChangedSignalMap::iterator pos; + SPDocument::IDChangedSignalMap::iterator pos; - pos = priv->id_changed_signals.find(idq); - if ( pos != priv->id_changed_signals.end() ) { + pos = id_changed_signals.find(idq); + if ( pos != id_changed_signals.end() ) { if (!(*pos).second.empty()) { (*pos).second.emit(object); } else { // discard unused signal - priv->id_changed_signals.erase(pos); + id_changed_signals.erase(pos); } } } @@ -1054,31 +1040,23 @@ void SPDocument::bindObjectToId(gchar const *id, SPObject *object) { void SPDocument::addUndoObserver(Inkscape::UndoStackObserver& observer) { - this->priv->undoStackObservers.add(observer); + this->undoStackObservers.add(observer); } void SPDocument::removeUndoObserver(Inkscape::UndoStackObserver& observer) { - this->priv->undoStackObservers.remove(observer); + this->undoStackObservers.remove(observer); } SPObject *SPDocument::getObjectById(Glib::ustring const &id) const { - return getObjectById( id.c_str() ); -} - -SPObject *SPDocument::getObjectById(gchar const *id) const -{ - g_return_val_if_fail(id != nullptr, NULL); - if (!priv || priv->iddef.empty()) { + if (id.empty() || iddef.empty()) { return nullptr; } - // GQuark idq = g_quark_from_string(id); - std::map<std::string, SPObject *>::iterator rv = priv->iddef.find(id); - //gpointer rv = g_hash_table_lookup(priv->iddef, GINT_TO_POINTER(idq)); - if(rv != priv->iddef.end()) + std::map<std::string, SPObject *>::const_iterator rv = iddef.find(id); + if(rv != iddef.end()) { return (rv->second); } @@ -1086,12 +1064,22 @@ SPObject *SPDocument::getObjectById(gchar const *id) const { return nullptr; } + return getObjectById( id ); +} + +SPObject *SPDocument::getObjectById(gchar const *id) const +{ + if (id == nullptr) { + return nullptr; + } + + return getObjectById(Glib::ustring(id)); } sigc::connection SPDocument::connectIdChanged(gchar const *id, SPDocument::IDChangedSignal::slot_type slot) { - return priv->id_changed_signals[g_quark_from_string(id)].connect(slot); + return id_changed_signals[g_quark_from_string(id)].connect(slot); } void _getObjectsByClassRecursive(Glib::ustring const &klass, SPObject *parent, std::vector<SPObject *> &objects) @@ -1195,19 +1183,19 @@ std::vector<SPObject *> SPDocument::getObjectsBySelector(Glib::ustring const &se void SPDocument::bindObjectToRepr(Inkscape::XML::Node *repr, SPObject *object) { if (object) { - g_assert(priv->reprdef.find(repr)==priv->reprdef.end()); - priv->reprdef[repr] = object; + g_assert(reprdef.find(repr)==reprdef.end()); + reprdef[repr] = object; } else { - g_assert(priv->reprdef.find(repr)!=priv->reprdef.end()); - priv->reprdef.erase(repr); + g_assert(reprdef.find(repr)!=reprdef.end()); + reprdef.erase(repr); } } SPObject *SPDocument::getObjectByRepr(Inkscape::XML::Node *repr) const { g_return_val_if_fail(repr != nullptr, NULL); - std::map<Inkscape::XML::Node *, SPObject *>::iterator rv = priv->reprdef.find(repr); - if(rv != priv->reprdef.end()) + std::map<Inkscape::XML::Node *, SPObject *>::const_iterator rv = reprdef.find(repr); + if(rv != reprdef.end()) return (rv->second); else return nullptr; @@ -1569,7 +1557,6 @@ static SPItem *find_group_at_point(unsigned int dkey, SPGroup *group, Geom::Poin std::vector<SPItem*> SPDocument::getItemsInBox(unsigned int dkey, Geom::Rect const &box, bool take_insensitive, bool into_groups) const { std::vector<SPItem*> x; - g_return_val_if_fail(this->priv != nullptr, x); return find_items_in_area(x, SP_GROUP(this->root), dkey, box, is_within, take_insensitive, into_groups); } @@ -1583,7 +1570,6 @@ std::vector<SPItem*> SPDocument::getItemsInBox(unsigned int dkey, Geom::Rect con std::vector<SPItem*> SPDocument::getItemsPartiallyInBox(unsigned int dkey, Geom::Rect const &box, bool take_insensitive, bool into_groups) const { std::vector<SPItem*> x; - g_return_val_if_fail(this->priv != nullptr, x); return find_items_in_area(x, SP_GROUP(this->root), dkey, box, overlaps, take_insensitive, into_groups); } @@ -1635,8 +1621,6 @@ std::vector<SPItem*> SPDocument::getItemsAtPoints(unsigned const key, std::vecto SPItem *SPDocument::getItemAtPoint( unsigned const key, Geom::Point const &p, bool const into_groups, SPItem *upto) const { - g_return_val_if_fail(this->priv != nullptr, NULL); - // Build a flattened SVG DOM for find_item_at_point. std::deque<SPItem*> bak(_node_cache); if(!into_groups){ @@ -1657,8 +1641,6 @@ SPItem *SPDocument::getItemAtPoint( unsigned const key, Geom::Point const &p, SPItem *SPDocument::getGroupAtPoint(unsigned int key, Geom::Point const &p) const { - g_return_val_if_fail(this->priv != nullptr, NULL); - return find_group_at_point(key, SP_GROUP(this->root), p); } @@ -1674,9 +1656,9 @@ bool SPDocument::addResource(gchar const *key, SPObject *object) bool result = false; if ( !object->cloned ) { - std::vector<SPObject *> rlist = priv->resources[key]; + std::vector<SPObject *> rlist = resources[key]; g_return_val_if_fail(std::find(rlist.begin(),rlist.end(),object) == rlist.end(), false); - priv->resources[key].insert(priv->resources[key].begin(),object); + resources[key].insert(resources[key].begin(),object); GQuark q = g_quark_from_string(key); @@ -1687,7 +1669,7 @@ bool SPDocument::addResource(gchar const *key, SPObject *object) the backtrace is unusable with crashed from this cause] */ if(object->getId() || dynamic_cast<SPGroup*>(object) ) - priv->resources_changed_signals[q].emit(); + resources_changed_signals[q].emit(); result = true; } @@ -1705,14 +1687,14 @@ bool SPDocument::removeResource(gchar const *key, SPObject *object) bool result = false; if ( !object->cloned ) { - std::vector<SPObject *> rlist = priv->resources[key]; + std::vector<SPObject *> rlist = resources[key]; g_return_val_if_fail(!rlist.empty(), false); - std::vector<SPObject*>::iterator it = std::find(priv->resources[key].begin(),priv->resources[key].end(),object); + std::vector<SPObject*>::iterator it = std::find(resources[key].begin(),resources[key].end(),object); g_return_val_if_fail(it != rlist.end(), false); - priv->resources[key].erase(it); + resources[key].erase(it); GQuark q = g_quark_from_string(key); - priv->resources_changed_signals[q].emit(); + resources_changed_signals[q].emit(); result = true; } @@ -1720,20 +1702,20 @@ bool SPDocument::removeResource(gchar const *key, SPObject *object) return result; } -std::vector<SPObject *> const SPDocument::getResourceList(gchar const *key) const +std::vector<SPObject *> const SPDocument::getResourceList(gchar const *key) { std::vector<SPObject *> emptyset; g_return_val_if_fail(key != nullptr, emptyset); g_return_val_if_fail(*key != '\0', emptyset); - return this->priv->resources[key]; + return resources[key]; } sigc::connection SPDocument::connectResourcesChanged(gchar const *key, SPDocument::ResourcesChangedSignal::slot_type slot) { GQuark q = g_quark_from_string(key); - return this->priv->resources_changed_signals[q].connect(slot); + return resources_changed_signals[q].connect(slot); } /* Helpers */ @@ -1808,7 +1790,7 @@ unsigned int SPDocument::vacuumDocument() } bool SPDocument::isSeeking() const { - return priv->seeking; + return seeking; } /** diff --git a/src/document.h b/src/document.h index 142f6a2e3..5b93261de 100644 --- a/src/document.h +++ b/src/document.h @@ -18,17 +18,24 @@ */ #include <cstddef> +#include <deque> +#include <set> +#include <vector> + +#include <boost/ptr_container/ptr_list.hpp> #include <sigc++/sigc++.h> -#include "3rdparty/libcroco/cr-cascade.h" +#include <glibmm/ustring.h> #include <2geom/forward.h> -#include "inkgc/gc-managed.h" -#include "gc-finalized.h" + +#include "3rdparty/libcroco/cr-cascade.h" +#include "event.h" #include "gc-anchored.h" -#include <glibmm/ustring.h> -#include <boost/ptr_container/ptr_list.hpp> -#include <vector> -#include <set> -#include <deque> +#include "gc-finalized.h" +#include "inkgc/gc-managed.h" + +#include "composite-undo-stack-observer.h" +// XXX only for testing! +#include "console-output-undo-observer.h" // This variable is introduced with 0.92.1 // with the introduction of automatic fix @@ -82,8 +89,6 @@ namespace Proj { class TransfMat3x4; } -struct SPDocumentPrivate; - /// Typed SVG document implementation. class SPDocument : public Inkscape::GC::Managed<>, public Inkscape::GC::Finalized, @@ -128,8 +133,6 @@ protected: public: - SPDocumentPrivate *priv; - /// Last action key Glib::ustring actionkey; @@ -284,7 +287,7 @@ public: int ensureUpToDate(); bool addResource(char const *key, SPObject *object); bool removeResource(char const *key, SPObject *object); - const std::vector<SPObject *> getResourceList(char const *key) const; + std::vector<SPObject *> const getResourceList(char const *key); std::vector<SPItem*> getItemsInBox(unsigned int dkey, Geom::Rect const &box, bool take_insensitive = false, bool into_groups = false) const; std::vector<SPItem*> getItemsPartiallyInBox(unsigned int dkey, Geom::Rect const &box, bool take_insensitive = false, bool into_groups = false) const; SPItem *getItemAtPoint(unsigned int key, Geom::Point const &p, bool into_groups, SPItem *upto = nullptr) const; @@ -305,6 +308,48 @@ private: void build_flat_item_list(unsigned int dkey, SPGroup *group, gboolean into_groups) const; mutable std::deque<SPItem*> _node_cache; mutable bool _node_cache_valid; + + // The following were in document-private.h and despite being called "private", they weren't. +public: + typedef std::map<GQuark, SPDocument::IDChangedSignal> IDChangedSignalMap; + typedef std::map<GQuark, SPDocument::ResourcesChangedSignal> ResourcesChangedSignalMap; + + std::map<std::string, SPObject *> iddef; + std::map<Inkscape::XML::Node *, SPObject *> reprdef; + + unsigned long _serial; + + /** Dictionary of signals for id changes */ + IDChangedSignalMap id_changed_signals; + + /* Resources */ + std::map<std::string, std::vector<SPObject *> > resources; + ResourcesChangedSignalMap resources_changed_signals; + + sigc::signal<void> destroySignal; + SPDocument::ModifiedSignal modified_signal; + SPDocument::URISetSignal uri_set_signal; + SPDocument::ResizedSignal resized_signal; + SPDocument::ReconstructionStart _reconstruction_start_signal; + SPDocument::ReconstructionFinish _reconstruction_finish_signal; + SPDocument::CommitSignal commit_signal; + + /* Undo/Redo state */ + bool sensitive; /* If we save actions to undo stack */ + Inkscape::XML::Event * partial; /* partial undo log when interrupted */ + int history_size; + std::vector<Inkscape::Event *> undo; /* Undo stack of reprs */ + std::vector<Inkscape::Event *> redo; /* Redo stack of reprs */ + + /* Undo listener */ + Inkscape::CompositeUndoStackObserver undoStackObservers; + + // XXX only for testing! + Inkscape::ConsoleOutputUndoObserver console_output_undo_observer; + + bool seeking; + sigc::connection selChangeConnection; + sigc::connection desktopActivatedConnection; }; /* diff --git a/src/extension/internal/filter/filter.cpp b/src/extension/internal/filter/filter.cpp index b869561cd..ab1025ffa 100644 --- a/src/extension/internal/filter/filter.cpp +++ b/src/extension/internal/filter/filter.cpp @@ -9,7 +9,6 @@ #include "desktop.h" #include "selection.h" -#include "document-private.h" #include "extension/extension.h" #include "extension/effect.h" #include "extension/system.h" @@ -143,7 +142,7 @@ void Filter::effect(Inkscape::Extension::Effect *module, Inkscape::UI::View::Vie Inkscape::XML::Node * newfilterroot = xmldoc->createElement("svg:filter"); merge_filters(newfilterroot, filterdoc->root(), xmldoc); defsrepr->appendChild(newfilterroot); - document->doc()->priv->resources_changed_signals[g_quark_from_string("filter")].emit(); + document->doc()->resources_changed_signals[g_quark_from_string("filter")].emit(); Glib::ustring url = "url(#"; url += newfilterroot->attribute("id"); url += ")"; diff --git a/src/ui/widget/entity-entry.cpp b/src/ui/widget/entity-entry.cpp index 5bd0a7700..d16ee6e6a 100644 --- a/src/ui/widget/entity-entry.cpp +++ b/src/ui/widget/entity-entry.cpp @@ -18,7 +18,6 @@ #include <gtkmm/scrolledwindow.h> #include <gtkmm/entry.h> -#include "document-private.h" #include "document-undo.h" #include "inkscape.h" #include "preferences.h" @@ -122,7 +121,7 @@ EntityLineEntry::on_changed() SPDocument *doc = SP_ACTIVE_DOCUMENT; Glib::ustring text = static_cast<Gtk::Entry*>(_packable)->get_text(); if (rdf_set_work_entity (doc, _entity, text.c_str())) { - if (doc->priv->sensitive) { + if (doc->sensitive) { DocumentUndo::done(doc, SP_VERB_NONE, "Document metadata updated"); } } diff --git a/src/ui/widget/licensor.cpp b/src/ui/widget/licensor.cpp index 63c95cc3a..de6817266 100644 --- a/src/ui/widget/licensor.cpp +++ b/src/ui/widget/licensor.cpp @@ -22,7 +22,6 @@ #include "rdf.h" #include "inkscape.h" #include "document-undo.h" -#include "document-private.h" #include "verbs.h" @@ -64,7 +63,7 @@ void LicenseItem::on_toggled() _wr.setUpdating (true); SPDocument *doc = SP_ACTIVE_DOCUMENT; rdf_set_license (doc, _lic->details ? _lic : nullptr); - if (doc->priv->sensitive) { + if (doc->sensitive) { DocumentUndo::done(doc, SP_VERB_NONE, _("Document license updated")); } _wr.setUpdating (false); |
