1 /*
2 * Inkscape::XML::LogBuilder - NodeObserver which builds an event log
3 *
4 * Copyright 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 #include "xml/log-builder.h"
16 #include "xml/event.h"
17 #include "xml/event-fns.h"
19 namespace Inkscape {
20 namespace XML {
22 void LogBuilder::discard() {
23 sp_repr_free_log(_log);
24 _log = NULL;
25 }
27 Event *LogBuilder::detach() {
28 Event *log=_log;
29 _log = NULL;
30 return log;
31 }
33 void LogBuilder::addChild(Node &node, Node &child, Node *prev) {
34 _log = new Inkscape::XML::EventAdd(&node, &child, prev, _log);
35 _log = _log->optimizeOne();
36 }
38 void LogBuilder::removeChild(Node &node, Node &child, Node *prev) {
39 _log = new Inkscape::XML::EventDel(&node, &child, prev, _log);
40 _log = _log->optimizeOne();
41 }
43 void LogBuilder::setChildOrder(Node &node, Node &child,
44 Node *old_prev, Node *new_prev)
45 {
46 _log = new Inkscape::XML::EventChgOrder(&node, &child, old_prev, new_prev, _log);
47 _log = _log->optimizeOne();
48 }
50 void LogBuilder::setContent(Node &node,
51 Util::ptr_shared<char> old_content,
52 Util::ptr_shared<char> new_content)
53 {
54 _log = new Inkscape::XML::EventChgContent(&node, old_content, new_content, _log);
55 _log = _log->optimizeOne();
56 }
58 void LogBuilder::setAttribute(Node &node, GQuark name,
59 Util::ptr_shared<char> old_value,
60 Util::ptr_shared<char> new_value)
61 {
62 _log = new Inkscape::XML::EventChgAttr(&node, name, old_value, new_value, _log);
63 _log = _log->optimizeOne();
64 }
66 }
67 }
69 /*
70 Local Variables:
71 mode:c++
72 c-file-style:"stroustrup"
73 c-file-offsets:((innamespace . 0)(inline-open . 0)(case-label . +))
74 indent-tabs-mode:nil
75 fill-column:99
76 End:
77 */
78 // vim: filetype=cpp:expandtab:shiftwidth=4:tabstop=8:softtabstop=4:encoding=utf-8:textwidth=99 :