kspread Library API Documentation

KSpreadMapIface.cc

00001 /* This file is part of the KDE project
00002    
00003    Copyright 2002 Ariya Hidayat <ariya@kde.org>
00004    Copyright 2001 Laurent Montel <montel@kde.org>
00005    Copyright 2001 Philipp Mueller <philipp.mueller@gmx.de>
00006    Copyright 2000 Werner Trobin <trobin@kde.org>
00007    Copyright 1999-2000 Torben Weis <weis@kde.org>
00008 
00009    This library is free software; you can redistribute it and/or
00010    modify it under the terms of the GNU Library General Public
00011    License as published by the Free Software Foundation; either
00012    version 2 of the License, or (at your option) any later version.
00013 
00014    This library is distributed in the hope that it will be useful,
00015    but WITHOUT ANY WARRANTY; without even the implied warranty of
00016    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
00017    Library General Public License for more details.
00018 
00019    You should have received a copy of the GNU Library General Public License
00020    along with this library; see the file COPYING.LIB.  If not, write to
00021    the Free Software Foundation, Inc., 59 Temple Place - Suite 330,
00022    Boston, MA 02111-1307, USA.
00023 */
00024 
00025 #include "KSpreadMapIface.h"
00026 
00027 #include "kspread_map.h"
00028 #include "kspread_doc.h"
00029 
00030 #include <kapplication.h>
00031 #include <dcopclient.h>
00032 #include <kdebug.h>
00033 
00034 KSpreadMapIface::KSpreadMapIface( KSpreadMap* map )
00035     : DCOPObject( map )
00036 {
00037     m_map = map;
00038 }
00039 
00040 DCOPRef KSpreadMapIface::sheet( const QString& name )
00041 {
00042     KSpreadSheet* t = m_map->findSheet( name );
00043     if ( !t )
00044         return DCOPRef();
00045 
00046     return DCOPRef( kapp->dcopClient()->appId(), t->dcopObject()->objId() );
00047 }
00048 
00049 DCOPRef KSpreadMapIface::sheetByIndex( int index )
00050 {
00051     KSpreadSheet* t = m_map->sheetList().at( index );
00052     if ( !t )
00053     {
00054         kdDebug(36001) << "+++++ No table found at index " << index << endl;
00055         return DCOPRef();
00056     }
00057 
00058     kdDebug(36001) << "+++++++ Returning table " << t->QObject::name() << endl;
00059 
00060     return DCOPRef( kapp->dcopClient()->appId(), t->dcopObject()->objId() );
00061 }
00062 
00063 int KSpreadMapIface::sheetCount() const
00064 {
00065     return m_map->count();
00066 }
00067 
00068 QStringList KSpreadMapIface::sheetNames() const
00069 {
00070     QStringList names;
00071 
00072     QPtrList<KSpreadSheet>& lst = m_map->sheetList();
00073     QPtrListIterator<KSpreadSheet> it( lst );
00074     for( ; it.current(); ++it )
00075         names.append( it.current()->name() );
00076 
00077     return names;
00078 }
00079 
00080 QValueList<DCOPRef> KSpreadMapIface::sheets()
00081 {
00082     QValueList<DCOPRef> t;
00083 
00084     QPtrList<KSpreadSheet>& lst = m_map->sheetList();
00085     QPtrListIterator<KSpreadSheet> it( lst );
00086     for( ; it.current(); ++it )
00087         t.append( DCOPRef( kapp->dcopClient()->appId(), it.current()->dcopObject()->objId() ) );
00088 
00089     return t;
00090 }
00091 
00092 DCOPRef KSpreadMapIface::insertSheet( const QString& name )
00093 {
00094     if ( m_map->findSheet( name ) )
00095         return sheet( name );
00096 
00097     KSpreadSheet* t = m_map->addNewSheet ();
00098     t->setSheetName( name );
00099 
00100     return sheet( name );
00101 }
00102 
00103 bool KSpreadMapIface::processDynamic(const QCString &fun, const QByteArray &/*data*/,
00104                                      QCString& replyType, QByteArray &replyData)
00105 {
00106     // Does the name follow the pattern "foobar()" ?
00107     uint len = fun.length();
00108     if ( len < 3 )
00109         return FALSE;
00110 
00111     if ( fun[ len - 1 ] != ')' || fun[ len - 2 ] != '(' )
00112         return FALSE;
00113 
00114     KSpreadSheet* t = m_map->findSheet( fun.left( len - 2 ).data() );
00115     if ( !t )
00116         return FALSE;
00117 
00118     replyType = "DCOPRef";
00119     QDataStream out( replyData, IO_WriteOnly );
00120     out << DCOPRef( kapp->dcopClient()->appId(), t->dcopObject()->objId() );
00121     return TRUE;
00122 }
KDE Logo
This file is part of the documentation for kspread Library Version 1.4.2.
Documentation copyright © 1996-2004 the KDE developers.
Generated on Mon Feb 13 09:43:38 2006 by doxygen 1.4.2 written by Dimitri van Heesch, © 1997-2003