19
19
You should have received a copy of the GNU Library General Public License
20
20
along with this library; see the file COPYING.LIB. If not, write to
21
the Free Software Foundation, Inc., 59 Temple Place - Suite 330,
22
Boston, MA 02111-1307, USA.
21
the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
22
* Boston, MA 02110-1301, USA.
25
#include "KSpreadMapIface.h"
27
#include "kspread_map.h"
28
#include "kspread_doc.h"
25
#include <dcopclient.h>
30
26
#include <kapplication.h>
31
#include <dcopclient.h>
32
27
#include <kdebug.h>
34
KSpreadMapIface::KSpreadMapIface( KSpreadMap* map )
29
#include "kspread_doc.h"
30
#include "kspread_map.h"
31
#include "kspread_sheet.h"
33
#include "KSpreadMapIface.h"
35
using namespace KSpread;
37
MapIface::MapIface( Map* map )
35
38
: DCOPObject( map )
40
DCOPRef KSpreadMapIface::sheet( const QString& name )
43
DCOPRef MapIface::sheet( const QString& name )
42
KSpreadSheet* t = m_map->findSheet( name );
45
Sheet* t = m_map->findSheet( name );
46
49
return DCOPRef( kapp->dcopClient()->appId(), t->dcopObject()->objId() );
49
DCOPRef KSpreadMapIface::sheetByIndex( int index )
52
DCOPRef MapIface::sheetByIndex( int index )
51
KSpreadSheet* t = m_map->sheetList().at( index );
54
Sheet* t = m_map->sheetList().at( index );
54
57
kdDebug(36001) << "+++++ No table found at index " << index << endl;
60
63
return DCOPRef( kapp->dcopClient()->appId(), t->dcopObject()->objId() );
63
int KSpreadMapIface::sheetCount() const
66
int MapIface::sheetCount() const
65
68
return m_map->count();
68
QStringList KSpreadMapIface::sheetNames() const
71
QStringList MapIface::sheetNames() const
72
QPtrList<KSpreadSheet>& lst = m_map->sheetList();
73
QPtrListIterator<KSpreadSheet> it( lst );
75
QPtrList<Sheet>& lst = m_map->sheetList();
76
QPtrListIterator<Sheet> it( lst );
74
77
for( ; it.current(); ++it )
75
78
names.append( it.current()->name() );
80
QValueList<DCOPRef> KSpreadMapIface::sheets()
83
QValueList<DCOPRef> MapIface::sheets()
82
85
QValueList<DCOPRef> t;
84
QPtrList<KSpreadSheet>& lst = m_map->sheetList();
85
QPtrListIterator<KSpreadSheet> it( lst );
87
QPtrList<Sheet>& lst = m_map->sheetList();
88
QPtrListIterator<Sheet> it( lst );
86
89
for( ; it.current(); ++it )
87
90
t.append( DCOPRef( kapp->dcopClient()->appId(), it.current()->dcopObject()->objId() ) );
92
DCOPRef KSpreadMapIface::insertSheet( const QString& name )
95
DCOPRef MapIface::insertSheet( const QString& name )
94
97
if ( m_map->findSheet( name ) )
95
98
return sheet( name );
97
KSpreadSheet* t = m_map->addNewSheet ();
100
Sheet* t = m_map->addNewSheet ();
98
101
t->setSheetName( name );
100
103
return sheet( name );
103
bool KSpreadMapIface::processDynamic(const QCString &fun, const QByteArray &/*data*/,
106
bool MapIface::processDynamic(const QCString &fun, const QByteArray &/*data*/,
104
107
QCString& replyType, QByteArray &replyData)
106
109
// Does the name follow the pattern "foobar()" ?
107
110
uint len = fun.length();
111
114
if ( fun[ len - 1 ] != ')' || fun[ len - 2 ] != '(' )
114
KSpreadSheet* t = m_map->findSheet( fun.left( len - 2 ).data() );
117
Sheet* t = m_map->findSheet( fun.left( len - 2 ).data() );
118
121
replyType = "DCOPRef";
119
122
QDataStream out( replyData, IO_WriteOnly );
120
123
out << DCOPRef( kapp->dcopClient()->appId(), t->dcopObject()->objId() );