From cca66b9ec4e494c1d919bff0f71a820d8afab1fa Mon Sep 17 00:00:00 2001 From: Daniel Baumann Date: Sun, 7 Apr 2024 20:24:48 +0200 Subject: Adding upstream version 1.2.2. Signed-off-by: Daniel Baumann --- src/xml/log-builder.cpp | 82 +++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 82 insertions(+) create mode 100644 src/xml/log-builder.cpp (limited to 'src/xml/log-builder.cpp') diff --git a/src/xml/log-builder.cpp b/src/xml/log-builder.cpp new file mode 100644 index 0000000..3fd831a --- /dev/null +++ b/src/xml/log-builder.cpp @@ -0,0 +1,82 @@ +// SPDX-License-Identifier: GPL-2.0-or-later +/** @file + * Object building an event log. + *//* + * Authors: see git history + * + * Copyright (C) 2018 Authors + * Copyright 2005 MenTaLguY + * + * Released under GNU GPL v2+, read the file 'COPYING' for more information. + */ + +#include "xml/log-builder.h" +#include "xml/event.h" +#include "xml/event-fns.h" + +namespace Inkscape { +namespace XML { + +void LogBuilder::discard() { + sp_repr_free_log(_log); + _log = nullptr; +} + +Event *LogBuilder::detach() { + Event *log=_log; + _log = nullptr; + return log; +} + +void LogBuilder::addChild(Node &node, Node &child, Node *prev) { + _log = new Inkscape::XML::EventAdd(&node, &child, prev, _log); + _log = _log->optimizeOne(); +} + +void LogBuilder::removeChild(Node &node, Node &child, Node *prev) { + _log = new Inkscape::XML::EventDel(&node, &child, prev, _log); + _log = _log->optimizeOne(); +} + +void LogBuilder::setChildOrder(Node &node, Node &child, + Node *old_prev, Node *new_prev) +{ + _log = new Inkscape::XML::EventChgOrder(&node, &child, old_prev, new_prev, _log); + _log = _log->optimizeOne(); +} + +void LogBuilder::setContent(Node &node, + Util::ptr_shared old_content, + Util::ptr_shared new_content) +{ + _log = new Inkscape::XML::EventChgContent(&node, old_content, new_content, _log); + _log = _log->optimizeOne(); +} + +void LogBuilder::setAttribute(Node &node, GQuark name, + Util::ptr_shared old_value, + Util::ptr_shared new_value) +{ + _log = new Inkscape::XML::EventChgAttr(&node, name, old_value, new_value, _log); + _log = _log->optimizeOne(); +} + +void LogBuilder::setElementName(Node& node, GQuark old_name, GQuark new_name) +{ + _log = new Inkscape::XML::EventChgElementName(&node, old_name, new_name, _log); + _log = _log->optimizeOne(); +} + +} +} + +/* + Local Variables: + mode:c++ + c-file-style:"stroustrup" + c-file-offsets:((innamespace . 0)(inline-open . 0)(case-label . +)) + indent-tabs-mode:nil + fill-column:99 + End: +*/ +// vim: filetype=cpp:expandtab:shiftwidth=4:tabstop=8:softtabstop=4:fileencoding=utf-8:textwidth=99 : -- cgit v1.2.3