X-Git-Url: http://matita.cs.unibo.it/gitweb/?a=blobdiff_plain;f=helm%2FDEVEL%2Fmathml_editor%2Focaml%2Fc_mathml_editor.cc;h=25759823ba05e8351b9d8b6ab6347121bde9a782;hb=4167cea65ca58897d1a3dbb81ff95de5074700cc;hp=88acf9b190d0072dd08852103bb99dc1c3badf44;hpb=8d15b9f68470945a45ce96dbc1c892742c85cb9c;p=helm.git diff --git a/helm/DEVEL/mathml_editor/ocaml/c_mathml_editor.cc b/helm/DEVEL/mathml_editor/ocaml/c_mathml_editor.cc index 88acf9b19..25759823b 100644 --- a/helm/DEVEL/mathml_editor/ocaml/c_mathml_editor.cc +++ b/helm/DEVEL/mathml_editor/ocaml/c_mathml_editor.cc @@ -1,10 +1,36 @@ +/* This file is part of EdiTeX, an editor of mathematical + * expressions based on TeX syntax. + * + * Copyright (C) 2002-2003 Luca Padovani , + * 2003 Paolo Marinelli . + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either + * version 2.1 of the License, or (at your option) any later version. + * + * This library 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 GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with this library; if not, write to the Free Software + * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA + * + * For more information, please visit the project's home page + * http://helm.cs.unibo.it/editex/ + * or send an email to + */ #include +#include #include "ALogger.hh" #include "TDictionary.hh" #include "CMathMLFactoryXSLT.hh" #include "TPushLexer.hh" +#include "LPushLexer.hh" #include "TPushParser.hh" class CCallbackLogger : public ALogger @@ -35,7 +61,7 @@ CCallbackLogger::message(Level l, const std::string& s) struct Editor { - Editor(const DOM::Document&, const DOM::Document&, const DOM::Document&, void (*)(int, const char*, void*), void*); + Editor(const char*, const char*, const char*, void (*)(int, const char*, void*), void*, bool); ~Editor(); ALogger* logger; @@ -47,18 +73,25 @@ struct Editor APushLexer* lexer; }; -Editor::Editor(const DOM::Document& dict, const DOM::Document& mml, const DOM::Document& tex, - void (*cb)(int, const char*, void*), void* data) +Editor::Editor(const char* dict_uri, const char* mml_uri, const char* tex_uri, + void (*cb)(int, const char*, void*), void* data, bool alt) { + assert(dict_uri); + assert(mml_uri); + assert(tex_uri); assert(cb); logger = new CCallbackLogger(cb, data); dictionary = new TDictionary(*logger); - dictionary->load(DOM::Document(dict)); + dictionary->load(dict_uri); + DOM::DOMImplementation di; + DOM::Document mml = di.createDocumentFromURI(mml_uri); + DOM::Document tex = di.createDocumentFromURI(tex_uri); tml_mml = new DOMX::XSLTStylesheet(mml); tml_tex = new DOMX::XSLTStylesheet(tex); factory = new CMathMLFactoryXSLT(*logger, *tml_mml); parser = new TPushParser(*logger, *factory, *dictionary); - lexer = new TPushLexer(*logger, *parser); + if (alt) lexer = new LPushLexer(*logger, *parser); + else lexer = new TPushLexer(*logger, *parser); } Editor::~Editor() @@ -72,16 +105,33 @@ Editor::~Editor() delete logger; } +extern "C" const char* +c_mathml_editor_get_default_dictionary_path() +{ + return TDictionary::getDefaultDictionaryPath().c_str(); +} + +extern "C" const char* +c_mathml_editor_get_default_mathml_stylesheet_path() +{ + return AMathMLFactory::getDefaultMathMLStylesheetPath().c_str(); +} + +extern "C" const char* +c_mathml_editor_get_default_tex_stylesheet_path() +{ + return AMathMLFactory::getDefaultTeXStylesheetPath().c_str(); +} + extern "C" Editor* -c_mathml_editor_new(GdomeDocument* dictionary, - GdomeDocument* tml_mml, - GdomeDocument* tml_tex, +c_mathml_editor_new(bool alt, + const char* dictionary_uri, + const char* tml_mml_uri, + const char* tml_tex_uri, void (*log_message_cb)(int, const char*, void*), void* user_data) { - return new Editor(DOM::Document(dictionary), - DOM::Document(tml_mml), - DOM::Document(tml_tex), log_message_cb, user_data); + return new Editor(dictionary_uri, tml_mml_uri, tml_tex_uri, log_message_cb, user_data, alt); } extern "C" void @@ -148,6 +198,7 @@ extern "C" void c_mathml_editor_reset(Editor* editor) { assert(editor); + editor->lexer->reset(); editor->parser->reset(); }