kspread

kspreadcoremodule.cpp

00001 /*
00002  *  Copyright (c) 2005 Cyrille Berger <cberger@cberger.net>
00003  *  Copyright (c) 2006 Isaac Clerencia <isaac@warp.es>
00004  *
00005  *  This program is free software; you can redistribute it and/or modify
00006  *  it under the terms of the GNU Library General Public License as published by
00007  *  the Free Software Foundation; either version 2 of the License, or
00008  *  (at your option) any later version.
00009  *
00010  *  This program is distributed in the hope that it will be useful,
00011  *  but WITHOUT ANY WARRANTY; without even the implied warranty of
00012  *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
00013  *  GNU Library General Public License for more details.
00014  *
00015  *  You should have received a copy of the GNU Library General Public License
00016  *  along with this program; if not, write to the Free Software
00017  *  Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
00018  */
00019 
00020 #include "kspreadcoremodule.h"
00021 
00022 #include <kdebug.h>
00023 
00024 //#include <api/variant.h>
00025 #include <api/qtobject.h>
00026 #include <main/manager.h>
00027 
00028 #include "krs_doc.h"
00029 
00030 extern "C"
00031 {
00036     Kross::Api::Object* init_module(Kross::Api::Manager* manager)
00037     {
00038         return new Kross::KSpreadCore::KSpreadCoreModule(manager);
00039     }
00040 }
00041 
00042 
00043 using namespace Kross::KSpreadCore;
00044 
00045 KSpreadCoreModule::KSpreadCoreModule(Kross::Api::Manager* manager)
00046     : Kross::Api::Module("kspreadcore") , m_manager(manager)
00047 {
00048     QMap<QString, Object::Ptr> children = manager->getChildren();
00049     kdDebug() << " there are " << children.size() << endl;
00050     for(QMap<QString, Object::Ptr>::const_iterator it = children.begin(); it != children.end(); it++)
00051     {
00052         kdDebug() << it.key() << " " << it.data() << endl;
00053     }
00054 
00055     // Wrap doc
00056     Kross::Api::Object::Ptr kspreaddocument = manager->getChild("KSpreadDocument");
00057     if(! kspreaddocument) {
00058         KSpread::Doc* doc = new KSpread::Doc();
00059         addChild( new Kross::KSpreadCore::Doc(doc) );
00060     }
00061     else {
00062         Kross::Api::QtObject* kspreaddocumentqt = dynamic_cast< Kross::Api::QtObject* >( kspreaddocument.data() );
00063         if(kspreaddocumentqt) {
00064             KSpread::Doc* document = dynamic_cast< ::KSpread::Doc* >( kspreaddocumentqt->getObject() );
00065             if(document) {
00066                 addChild( new Doc(document) );
00067             } else {
00068                 throw Kross::Api::Exception::Ptr( new Kross::Api::Exception("There was no 'KSpreadDocument' published.") );
00069             }
00070          }
00071     }
00072 }
00073 
00074 KSpreadCoreModule::~KSpreadCoreModule()
00075 {
00076 }
00077 
00078 
00079 const QString KSpreadCoreModule::getClassName() const
00080 {
00081     return "Kross::KSpreadCore::KSpreadCoreModule";
00082 }
KDE Home | KDE Accessibility Home | Description of Access Keys