KSpreadMapIface.cc
00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
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 &,
00104 QCString& replyType, QByteArray &replyData)
00105 {
00106
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 }
This file is part of the documentation for kspread Library Version 1.4.2.