1 // Copyright (C) 2007-2014 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, or (at your option) any later version.
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
23 // GEOM GEOMGUI : reading of xml file with list of available plugin actions
24 // File : GEOMGUI_XmlHandler.cxx
25 // Author : Julia DOROVSKIKH, Open CASCADE S.A.S.
27 #include "GEOMGUI_XmlHandler.h"
31 // SALOME KERNEL includes
32 #include <utilities.h>
37 GEOMGUI_XmlHandler::GEOMGUI_XmlHandler()
44 GEOMGUI_XmlHandler::~GEOMGUI_XmlHandler()
49 * Starts parsing of document. Does some initialization
51 * Reimplemented from QXmlDefaultHandler.
53 bool GEOMGUI_XmlHandler::startDocument()
60 * Does different actions depending on the name of the tag and the
61 * state you are in document.
63 * Reimplemented from QXmlDefaultHandler.
65 bool GEOMGUI_XmlHandler::startElement (const QString&, const QString&,
67 const QXmlAttributes& atts)
69 if (qName == "geom-plugins") { // set of plugins
70 //myHypothesesMap.clear();
71 //myAlgorithmsMap.clear();
73 else if (qName == "geom-plugin") { // group of actions
74 myPluginData.myName = atts.value("name");
75 myPluginData.myServerLib = atts.value("server-lib");
76 myPluginData.myClientLib = atts.value("gui-lib");
78 //QString aResName = atts.value("resources");
79 //if (aResName != "") {
80 // SUIT_ResourceMgr* resMgr = GEOMGUI::resourceMgr();
81 // QString lang = resMgr->stringValue( resMgr->langSection(), "language", "en" );
82 // resMgr->loadTranslator( "resources", QString( "%1_msg_%2.qm" ).arg( aResName, lang ) );
83 // resMgr->loadTranslator( "resources", QString( "%1_images.qm" ).arg( aResName, lang ) );
86 else if (qName == "actions") { // group of actions
88 else if (qName == "action") { // an action
89 GEOMGUI_ActionData aData;
90 aData.myLabel = atts.value("label");
91 aData.myIcon = atts.value("icon");
92 aData.myMenu = atts.value("menu");
93 aData.myTooltip = atts.value("tooltip");
94 aData.myStatusBar = atts.value("status-bar");
96 myPluginData.myListOfActions.append(aData);
106 * Reimplemented from QXmlDefaultHandler.
108 bool GEOMGUI_XmlHandler::endElement (const QString&, const QString&, const QString&)
114 * Reimplemented from QXmlDefaultHandler.
116 bool GEOMGUI_XmlHandler::characters (const QString& ch)
118 // we are not interested in whitespaces
119 //QString ch_simplified = ch.simplified();
120 //if ( ch_simplified.isEmpty() )
126 * Returns the default error string.
128 * Reimplemented from QXmlDefaultHandler.
130 QString GEOMGUI_XmlHandler::errorString()
132 return "the document is not in the quote file format";
136 * Returns the error protocol if parsing failed
138 * Reimplemented from QXmlDefaultHandler.
140 QString GEOMGUI_XmlHandler::errorProtocol()
148 * Reimplemented from QXmlDefaultHandler.
150 bool GEOMGUI_XmlHandler::fatalError (const QXmlParseException& exception)
152 myErrorProt += QString("fatal parsing error: %1 in line %2, column %3\n")
153 .arg(exception.message())
154 .arg(exception.lineNumber())
155 .arg(exception.columnNumber());
157 return QXmlDefaultHandler::fatalError( exception );