1 /*
2 * Inkscape::XML::SimpleDocument - generic XML document implementation
3 *
4 * Copyright 2004-2005 MenTaLguY <mental@rydia.net>
5 *
6 * This program is free software; you can redistribute it and/or
7 * modify it under the terms of the GNU General Public License
8 * as published by the Free Software Foundation; either version 2
9 * of the License, or (at your option) any later version.
10 *
11 * See the file COPYING for details.
12 *
13 */
15 #ifndef SEEN_INKSCAPE_XML_SIMPLE_DOCUMENT_H
16 #define SEEN_INKSCAPE_XML_SIMPLE_DOCUMENT_H
18 #include "xml/document.h"
19 #include "xml/simple-node.h"
20 #include "xml/node-observer.h"
21 #include "xml/log-builder.h"
23 namespace Inkscape {
25 namespace XML {
27 class SimpleDocument : public SimpleNode,
28 public Document,
29 public NodeObserver
30 {
31 public:
32 explicit SimpleDocument()
33 : SimpleNode(g_quark_from_static_string("xml"), this),
34 _in_transaction(false) {}
36 NodeType type() const { return Inkscape::XML::DOCUMENT_NODE; }
38 NodeObserver *logger() { return this; }
40 bool inTransaction() { return _in_transaction; }
42 void beginTransaction();
43 void rollback();
44 void commit();
45 Inkscape::XML::Event *commitUndoable();
47 Node *createElement(char const *name);
48 Node *createTextNode(char const *content);
49 Node *createComment(char const *content);
50 Node *createPI(char const *target, char const *content);
52 void notifyChildAdded(Node &parent, Node &child, Node *prev);
54 void notifyChildRemoved(Node &parent, Node &child, Node *prev);
56 void notifyChildOrderChanged(Node &parent, Node &child,
57 Node *old_prev, Node *new_prev);
59 void notifyContentChanged(Node &node,
60 Util::ptr_shared<char> old_content,
61 Util::ptr_shared<char> new_content);
63 void notifyAttributeChanged(Node &node, GQuark name,
64 Util::ptr_shared<char> old_value,
65 Util::ptr_shared<char> new_value);
67 protected:
68 SimpleDocument(SimpleDocument const &doc)
69 : Node(), SimpleNode(doc), Document(), NodeObserver(),
70 _in_transaction(false) {}
72 SimpleNode *_duplicate(Document* /*doc*/) const
73 {
74 return new SimpleDocument(*this);
75 }
77 private:
78 bool _in_transaction;
79 LogBuilder _log_builder;
80 };
82 }
84 }
86 #endif
87 /*
88 Local Variables:
89 mode:c++
90 c-file-style:"stroustrup"
91 c-file-offsets:((innamespace . 0)(inline-open . 0)(case-label . +))
92 indent-tabs-mode:nil
93 fill-column:99
94 End:
95 */
96 // vim: filetype=cpp:expandtab:shiftwidth=4:tabstop=8:softtabstop=4:encoding=utf-8:textwidth=99 :