kspread
KSpreadMapIface.cc00001
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 <dcopclient.h>
00026 #include <kapplication.h>
00027 #include <kdebug.h>
00028
00029 #include "kspread_doc.h"
00030 #include "kspread_map.h"
00031 #include "kspread_sheet.h"
00032
00033 #include "KSpreadMapIface.h"
00034
00035 using namespace KSpread;
00036
00037 MapIface::MapIface( Map* map )
00038 : DCOPObject( map )
00039 {
00040 m_map = map;
00041 }
00042
00043 DCOPRef MapIface::sheet( const QString& name )
00044 {
00045 Sheet* t = m_map->findSheet( name );
00046 if ( !t )
00047 return DCOPRef();
00048
00049 return DCOPRef( kapp->dcopClient()->appId(), t->dcopObject()->objId() );
00050 }
00051
00052 DCOPRef MapIface::sheetByIndex( int index )
00053 {
00054 Sheet* t = m_map->sheetList().at( index );
00055 if ( !t )
00056 {
00057 kdDebug(36001) << "+++++ No table found at index " << index << endl;
00058 return DCOPRef();
00059 }
00060
00061 kdDebug(36001) << "+++++++ Returning table " << t->QObject::name() << endl;
00062
00063 return DCOPRef( kapp->dcopClient()->appId(), t->dcopObject()->objId() );
00064 }
00065
00066 int MapIface::sheetCount() const
00067 {
00068 return m_map->count();
00069 }
00070
00071 QStringList MapIface::sheetNames() const
00072 {
00073 QStringList names;
00074
00075 QPtrList<Sheet>& lst = m_map->sheetList();
00076 QPtrListIterator<Sheet> it( lst );
00077 for( ; it.current(); ++it )
00078 names.append( it.current()->name() );
00079
00080 return names;
00081 }
00082
00083 QValueList<DCOPRef> MapIface::sheets()
00084 {
00085 QValueList<DCOPRef> t;
00086
00087 QPtrList<Sheet>& lst = m_map->sheetList();
00088 QPtrListIterator<Sheet> it( lst );
00089 for( ; it.current(); ++it )
00090 t.append( DCOPRef( kapp->dcopClient()->appId(), it.current()->dcopObject()->objId() ) );
00091
00092 return t;
00093 }
00094
00095 DCOPRef MapIface::insertSheet( const QString& name )
00096 {
00097 if ( m_map->findSheet( name ) )
00098 return sheet( name );
00099
00100 Sheet* t = m_map->addNewSheet ();
00101 t->setSheetName( name );
00102
00103 return sheet( name );
00104 }
00105
00106 bool MapIface::processDynamic(const QCString &fun, const QByteArray &,
00107 QCString& replyType, QByteArray &replyData)
00108 {
00109
00110 uint len = fun.length();
00111 if ( len < 3 )
00112 return false;
00113
00114 if ( fun[ len - 1 ] != ')' || fun[ len - 2 ] != '(' )
00115 return false;
00116
00117 Sheet* t = m_map->findSheet( fun.left( len - 2 ).data() );
00118 if ( !t )
00119 return false;
00120
00121 replyType = "DCOPRef";
00122 QDataStream out( replyData, IO_WriteOnly );
00123 out << DCOPRef( kapp->dcopClient()->appId(), t->dcopObject()->objId() );
00124 return true;
00125 }
|