Code

merge XML::Session into XML::Document
[inkscape.git] / src / xml / simple-document.h
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(int code)
33     : SimpleNode(code), _in_transaction(false)
34     {
35         _initBindings();
36     }
38     NodeType type() const { return Inkscape::XML::DOCUMENT_NODE; }
40     NodeObserver *logger() { return this; }
42     bool inTransaction() { return _in_transaction; }
44     void beginTransaction();
45     void rollback();
46     void commit();
47     Inkscape::XML::Event *commitUndoable();
49     Node *createElementNode(char const *name);
50     Node *createTextNode(char const *content);
51     Node *createCommentNode(char const *content);
53     void notifyChildAdded(Node &parent, Node &child, Node *prev);
55     void notifyChildRemoved(Node &parent, Node &child, Node *prev);
57     void notifyChildOrderChanged(Node &parent, Node &child,
58                                  Node *old_prev, Node *new_prev);
60     void notifyContentChanged(Node &node,
61                               Util::ptr_shared<char> old_content,
62                               Util::ptr_shared<char> new_content);
64     void notifyAttributeChanged(Node &node, GQuark name,
65                                 Util::ptr_shared<char> old_value,
66                                 Util::ptr_shared<char> new_value);
68 protected:
69     SimpleDocument(SimpleDocument const &doc)
70     : Node(), SimpleNode(doc), Document(), NodeObserver(),
71       _in_transaction(false)
72     {
73         _initBindings();
74     }
76     SimpleNode *_duplicate() const { return new SimpleDocument(*this); }
78 private:
79     void _initBindings();
81     bool _in_transaction;
82     LogBuilder _log_builder;
83 };
85 }
87 }
89 #endif
90 /*
91   Local Variables:
92   mode:c++
93   c-file-style:"stroustrup"
94   c-file-offsets:((innamespace . 0)(inline-open . 0)(case-label . +))
95   indent-tabs-mode:nil
96   fill-column:99
97   End:
98 */
99 // vim: filetype=cpp:expandtab:shiftwidth=4:tabstop=8:softtabstop=4:encoding=utf-8:textwidth=99 :