kspread

kspreadcoremodule.cpp
1/*
2 * Copyright (c) 2005 Cyrille Berger <cberger@cberger.net>
3 * Copyright (c) 2006 Isaac Clerencia <isaac@warp.es>
4 *
5 * This program is free software; you can redistribute it and/or modify
6 * it under the terms of the GNU Library General Public License as published by
7 * the Free Software Foundation; either version 2 of the License, or
8 * (at your option) any later version.
9 *
10 * This program is distributed in the hope that it will be useful,
11 * but WITHOUT ANY WARRANTY; without even the implied warranty of
12 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 * GNU Library General Public License for more details.
14 *
15 * You should have received a copy of the GNU Library General Public License
16 * along with this program; if not, write to the Free Software
17 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
18 */
19
20#include "kspreadcoremodule.h"
21
22#include <kdebug.h>
23
24//#include <api/variant.h>
25#include <api/qtobject.h>
26#include <main/manager.h>
27
28#include "krs_doc.h"
29
30extern "C"
31{
36 Kross::Api::Object* init_module(Kross::Api::Manager* manager)
37 {
38 return new Kross::KSpreadCore::KSpreadCoreModule(manager);
39 }
40}
41
42
43using namespace Kross::KSpreadCore;
44
45KSpreadCoreModule::KSpreadCoreModule(Kross::Api::Manager* manager)
46 : Kross::Api::Module("kspreadcore") , m_manager(manager)
47{
48 TQMap<TQString, Object::Ptr> children = manager->getChildren();
49 kdDebug() << " there are " << children.size() << endl;
50 for(TQMap<TQString, Object::Ptr>::const_iterator it = children.begin(); it != children.end(); it++)
51 {
52 kdDebug() << it.key() << " " << it.data() << endl;
53 }
54
55 // Wrap doc
56 Kross::Api::Object::Ptr kspreaddocument = manager->getChild("KSpreadDocument");
57 if(! kspreaddocument) {
58 KSpread::Doc* doc = new KSpread::Doc();
59 addChild( new Kross::KSpreadCore::Doc(doc) );
60 }
61 else {
62 Kross::Api::QtObject* kspreaddocumentqt = dynamic_cast< Kross::Api::QtObject* >( kspreaddocument.data() );
63 if(kspreaddocumentqt) {
64 KSpread::Doc* document = dynamic_cast< ::KSpread::Doc* >( kspreaddocumentqt->getObject() );
65 if(document) {
66 addChild( new Doc(document) );
67 } else {
68 throw Kross::Api::Exception::Ptr( new Kross::Api::Exception("There was no 'KSpreadDocument' published.") );
69 }
70 }
71 }
72}
73
74KSpreadCoreModule::~KSpreadCoreModule()
75{
76}
77
78
79const TQString KSpreadCoreModule::getClassName() const
80{
81 return "Kross::KSpreadCore::KSpreadCoreModule";
82}
This class holds the data that makes up a spreadsheet.
Definition kspread_doc.h:98
The KSpread document.
Definition krs_doc.h:44
The KSpreadCoreModule class implements a Kross::Api::Module to provide access to the KSpread function...