1 /* Copyright (C) 2002-2003, Luca Padovani <luca.padovani@cs.unibo.it>,
2 * 2003, Paolo Marinelli <pmarinel@cs.unibo.it>.
4 * This file is part of EdiTeX, an editor of mathematical
5 * expressions based on TeX syntax
7 * EdiTeX is free software; you can redistribute it and/or
8 * modify it under the terms of the GNU General Public License
9 * as published by the Free Software Foundation; either version 2
10 * of the License, or (at your option) any later version.
12 * EdiTeX 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
15 * GNU General Public License for more details.
17 * You should have received a copy of the GNU General Public License
18 * along with EdiTeX; if not, write to the Free Software
19 * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
21 * For details, see the EdiTeX World-Wide-Web page,
22 * http://helm.cs.unibo.it/editex, or send a mail to
23 * <luca.padovani@cs.unibo.it>
33 DOM::Node p = node.get_nextSibling();
34 while (p && p.get_nodeType() != DOM::Node::ELEMENT_NODE) p = p.get_nextSibling();
43 if (n.isG()) return n.firstL();
52 DOM::Node p = node.get_previousSibling();
53 while (p && p.get_nodeType() != DOM::Node::ELEMENT_NODE) p = p.get_previousSibling();
62 if (n.isG()) return n.lastL();
71 DOM::Node p = node.get_lastChild();
72 while (p && p.get_nodeType() != DOM::Node::ELEMENT_NODE) p = p.get_previousSibling();
81 if (n.isG()) return n.lastL();
91 DOM::Node p = node.get_firstChild();
92 while (p && p.get_nodeType() != DOM::Node::ELEMENT_NODE) p = p.get_nextSibling();
100 if (TNode n = first())
101 if (n.isG()) return n.firstL();
111 // check also if there is a macro embellishment (\not)
112 if (isSb() || isSp()) return first().core();
117 TNode::parent() const
120 DOM::Node p = node.get_parentNode();
121 assert(!p || p.get_nodeType() == DOM::Node::ELEMENT_NODE);
141 TNode::remove() const
144 DOM::Node parent = node.get_parentNode();
145 parent.removeChild(node);
149 TNode::replace(const TNode& newNode) const
152 DOM::Node parent = node.get_parentNode();
153 parent.replaceChild(newNode.node, node);
157 TNode::replace(const TNode& first, const TNode& last) const
165 TNode next = p.next();
173 TNode::insert(const TNode& newNode) const
176 DOM::Node parent = node.get_parentNode();
177 parent.insertBefore(newNode.node, node);
181 TNode::append(const TNode& newNode) const
184 node.appendChild(newNode.node);
188 TNode::append(const TNode& first, const TNode& last) const
197 TNode next = p.next();
204 TNode::prepend(const TNode& newNode) const
207 DOM::Node parent = node.get_parentNode();
208 parent.insertBefore(newNode.node, parent.get_firstChild());
215 TNode::child(unsigned pos) const
219 while (p && pos-- > 0) p = p.next();
224 TNode::get(const std::string& name) const
227 return node.getAttribute(name);
231 TNode::set(const std::string& name, const std::string& value) const
234 node.setAttribute(name, value);