1 /**
  2  * Copyright (C) 2013 KO GmbH <copyright@kogmbh.com>
  3  *
  4  * @licstart
  5  * This file is part of WebODF.
  6  *
  7  * WebODF is free software: you can redistribute it and/or modify it
  8  * under the terms of the GNU Affero General Public License (GNU AGPL)
  9  * as published by the Free Software Foundation, either version 3 of
 10  * the License, or (at your option) any later version.
 11  *
 12  * WebODF is distributed in the hope that it will be useful, but
 13  * WITHOUT ANY WARRANTY; without even the implied warranty of
 14  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 15  * GNU Affero General Public License for more details.
 16  *
 17  * You should have received a copy of the GNU Affero General Public License
 18  * along with WebODF.  If not, see <http://www.gnu.org/licenses/>.
 19  * @licend
 20  *
 21  * @source: http://www.webodf.org/
 22  * @source: https://github.com/kogmbh/WebODF/
 23  */
 24 
 25 /*global Node, NodeFilter, odf*/
 26 
 27 /**
 28  * Class that filters runtime specific nodes from the DOM.
 29  * @constructor
 30  * @implements {xmldom.LSSerializerFilter}
 31  */
 32 odf.OdfNodeFilter = function OdfNodeFilter() {
 33     "use strict";
 34 
 35     /**
 36      * @param {!Node} node
 37      * @return {!number}
 38      */
 39     this.acceptNode = function (node) {
 40         var result;
 41         if (node.namespaceURI === "http://www.w3.org/1999/xhtml") {
 42             result = NodeFilter.FILTER_SKIP;
 43         } else if (node.namespaceURI && node.namespaceURI.match(/^urn:webodf:/)) {
 44             // skip all webodf nodes incl. child nodes
 45             result = NodeFilter.FILTER_REJECT;
 46         } else {
 47             result = NodeFilter.FILTER_ACCEPT;
 48         }
 49         return result;
 50     };
 51 };
 52