1 /* This file is part of EdiTeX, an editor of mathematical
2 * expressions based on TeX syntax.
4 * Copyright (C) 2002-2003 Luca Padovani <lpadovan@cs.unibo.it>,
5 * 2003 Paolo Marinelli <pmarinel@cs.unibo.it>.
7 * This library is free software; you can redistribute it and/or
8 * modify it under the terms of the GNU Lesser General Public
9 * License as published by the Free Software Foundation; either
10 * version 2.1 of the License, or (at your option) any later version.
12 * This library is distributed in the hope that it will be useful,
13 * but WITHOUT ANY WARRANTY; without even the implied warranty of
14 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
15 * Lesser General Public License for more details.
17 * You should have received a copy of the GNU Lesser General Public
18 * License along with this library; if not, write to the Free Software
19 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
21 * For more information, please visit the project's home page
22 * http://helm.cs.unibo.it/editex/
23 * or send an email to <lpadovan@cs.unibo.it>
34 DOM::Node p = node.get_nextSibling();
35 while (p && p.get_nodeType() != DOM::Node::ELEMENT_NODE) p = p.get_nextSibling();
44 if (n.isG()) return n.firstL();
53 DOM::Node p = node.get_previousSibling();
54 while (p && p.get_nodeType() != DOM::Node::ELEMENT_NODE) p = p.get_previousSibling();
63 if (n.isG()) return n.lastL();
72 DOM::Node p = node.get_lastChild();
73 while (p && p.get_nodeType() != DOM::Node::ELEMENT_NODE) p = p.get_previousSibling();
82 if (n.isG()) return n.lastL();
92 DOM::Node p = node.get_firstChild();
93 while (p && p.get_nodeType() != DOM::Node::ELEMENT_NODE) p = p.get_nextSibling();
101 if (TNode n = first())
102 if (n.isG()) return n.firstL();
112 // check also if there is a macro embellishment (\not)
113 if (isSb() || isSp()) return first().core();
118 TNode::parent() const
121 DOM::Node p = node.get_parentNode();
122 assert(!p || p.get_nodeType() == DOM::Node::ELEMENT_NODE);
142 TNode::remove() const
145 DOM::Node parent = node.get_parentNode();
146 parent.removeChild(node);
150 TNode::replace(const TNode& newNode) const
153 DOM::Node parent = node.get_parentNode();
154 parent.replaceChild(newNode.node, node);
158 TNode::replace(const TNode& first, const TNode& last) const
166 TNode next = p.next();
174 TNode::insert(const TNode& newNode) const
177 DOM::Node parent = node.get_parentNode();
178 parent.insertBefore(newNode.node, node);
182 TNode::append(const TNode& newNode) const
185 node.appendChild(newNode.node);
189 TNode::append(const TNode& first, const TNode& last) const
198 TNode next = p.next();
205 TNode::prepend(const TNode& newNode) const
208 DOM::Node parent = node.get_parentNode();
209 parent.insertBefore(newNode.node, parent.get_firstChild());
216 TNode::child(unsigned pos) const
220 while (p && pos-- > 0) p = p.next();
225 TNode::get(const std::string& name) const
228 return node.getAttribute(name);
232 TNode::set(const std::string& name, const std::string& value) const
235 node.setAttribute(name, value);