/* -*-c++-*- Present3D - Copyright (C) 1999-2006 Robert Osfield * * This software is open source and may be redistributed and/or modified under * the terms of the GNU General Public License (GPL) version 2.0. * The full license is in LICENSE.txt file included with this distribution,. * * This software is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * include LICENSE.txt for more details. */ #include #include #include #include "SpellChecker.h" using namespace p3d; SpellChecker::SpellChecker() { } void SpellChecker::checkP3dXml(const std::string& filename) const { std::string foundFileName = osgDB::findDataFile( filename ); if (foundFileName.empty()) return; std::ifstream fin(foundFileName.c_str()); osgDB::XmlNode::Input input; input.attach(fin); input.readAllDataIntoBuffer(); osg::ref_ptr doc = new osgDB::XmlNode; doc->read(input); if (!doc) return; checkXml(doc.get()); } void SpellChecker::checkXml(osgDB::XmlNode* node) const { if (node->name=="page") checkWords(node->contents); else if (node->name=="paragraph") checkWords(node->contents); else if (node->name=="bullet") checkWords(node->contents); for(osgDB::XmlNode::Children::iterator itr = node->children.begin(); itr != node->children.end(); ++itr) { checkXml(itr->get()); } } void SpellChecker::checkWords(const std::string& words) const { OSG_NOTICE<<"--"<