1 // Copyright (C) 2007-2013 CEA/DEN, EDF R&D, OPEN CASCADE
3 // Copyright (C) 2003-2007 OPEN CASCADE, EADS/CCR, LIP6, CEA/DEN,
4 // CEDRAT, EDF R&D, LEG, PRINCIPIA R&D, BUREAU VERITAS
6 // This library is free software; you can redistribute it and/or
7 // modify it under the terms of the GNU Lesser General Public
8 // License as published by the Free Software Foundation; either
9 // version 2.1 of the License.
11 // This library is distributed in the hope that it will be useful,
12 // but WITHOUT ANY WARRANTY; without even the implied warranty of
13 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
14 // Lesser General Public License for more details.
16 // You should have received a copy of the GNU Lesser General Public
17 // License along with this library; if not, write to the Free Software
18 // Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
20 // See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com
22 // GEOM GEOMGUI : reading of xml file with list of available plugin actions
23 // File : GEOMGUI_XmlHandler.cxx
24 // Author : Julia DOROVSKIKH, Open CASCADE S.A.S.
26 #include "GEOMGUI_XmlHandler.h"
30 // SALOME KERNEL includes
31 #include <utilities.h>
36 GEOMGUI_XmlHandler::GEOMGUI_XmlHandler()
43 GEOMGUI_XmlHandler::~GEOMGUI_XmlHandler()
48 * Starts parsing of document. Does some initialization
50 * Reimplemented from QXmlDefaultHandler.
52 bool GEOMGUI_XmlHandler::startDocument()
59 * Does different actions depending on the name of the tag and the
60 * state you are in document.
62 * Reimplemented from QXmlDefaultHandler.
64 bool GEOMGUI_XmlHandler::startElement (const QString&, const QString&,
66 const QXmlAttributes& atts)
68 if (qName == "geom-plugins") { // set of plugins
69 //myHypothesesMap.clear();
70 //myAlgorithmsMap.clear();
72 else if (qName == "geom-plugin") { // group of actions
73 myPluginData.myName = atts.value("name");
74 myPluginData.myServerLib = atts.value("server-lib");
75 myPluginData.myClientLib = atts.value("gui-lib");
77 //QString aResName = atts.value("resources");
78 //if (aResName != "") {
79 // SUIT_ResourceMgr* resMgr = GEOMGUI::resourceMgr();
80 // QString lang = resMgr->stringValue( resMgr->langSection(), "language", "en" );
81 // resMgr->loadTranslator( "resources", QString( "%1_msg_%2.qm" ).arg( aResName, lang ) );
82 // resMgr->loadTranslator( "resources", QString( "%1_images.qm" ).arg( aResName, lang ) );
85 else if (qName == "actions") { // group of actions
87 else if (qName == "action") { // an action
88 GEOMGUI_ActionData aData;
89 aData.myLabel = atts.value("label");
90 aData.myIcon = atts.value("icon");
91 aData.myMenu = atts.value("menu");
92 aData.myTooltip = atts.value("tooltip");
93 aData.myStatusBar = atts.value("status-bar");
95 myPluginData.myListOfActions.append(aData);
105 * Reimplemented from QXmlDefaultHandler.
107 bool GEOMGUI_XmlHandler::endElement (const QString&, const QString&, const QString&)
113 * Reimplemented from QXmlDefaultHandler.
115 bool GEOMGUI_XmlHandler::characters (const QString& ch)
117 // we are not interested in whitespaces
118 //QString ch_simplified = ch.simplified();
119 //if ( ch_simplified.isEmpty() )
125 * Returns the default error string.
127 * Reimplemented from QXmlDefaultHandler.
129 QString GEOMGUI_XmlHandler::errorString()
131 return "the document is not in the quote file format";
135 * Returns the error protocol if parsing failed
137 * Reimplemented from QXmlDefaultHandler.
139 QString GEOMGUI_XmlHandler::errorProtocol()
147 * Reimplemented from QXmlDefaultHandler.
149 bool GEOMGUI_XmlHandler::fatalError (const QXmlParseException& exception)
151 myErrorProt += QString("fatal parsing error: %1 in line %2, column %3\n")
152 .arg(exception.message())
153 .arg(exception.lineNumber())
154 .arg(exception.columnNumber());
156 return QXmlDefaultHandler::fatalError( exception );