~ubuntu-branches/ubuntu/precise/koffice/precise

« back to all changes in this revision

Viewing changes to kspread/KSpreadMapIface.cc

  • Committer: Bazaar Package Importer
  • Author(s): Jonathan Riddell
  • Date: 2006-04-20 21:38:53 UTC
  • mfrom: (1.1.3 upstream)
  • Revision ID: james.westby@ubuntu.com-20060420213853-j5lxluqvymxt2zny
Tags: 1:1.5.0-0ubuntu2
UbuntuĀ uploadĀ 

Show diffs side-by-side

added added

removed removed

Lines of Context:
18
18
 
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.
23
23
*/
24
24
 
25
 
#include "KSpreadMapIface.h"
26
 
 
27
 
#include "kspread_map.h"
28
 
#include "kspread_doc.h"
29
 
 
 
25
#include <dcopclient.h>
30
26
#include <kapplication.h>
31
 
#include <dcopclient.h>
32
27
#include <kdebug.h>
33
28
 
34
 
KSpreadMapIface::KSpreadMapIface( KSpreadMap* map )
 
29
#include "kspread_doc.h"
 
30
#include "kspread_map.h"
 
31
#include "kspread_sheet.h"
 
32
 
 
33
#include "KSpreadMapIface.h"
 
34
 
 
35
using namespace KSpread;
 
36
 
 
37
MapIface::MapIface( Map* map )
35
38
    : DCOPObject( map )
36
39
{
37
40
    m_map = map;
38
41
}
39
42
 
40
 
DCOPRef KSpreadMapIface::sheet( const QString& name )
 
43
DCOPRef MapIface::sheet( const QString& name )
41
44
{
42
 
    KSpreadSheet* t = m_map->findSheet( name );
 
45
    Sheet* t = m_map->findSheet( name );
43
46
    if ( !t )
44
47
        return DCOPRef();
45
48
 
46
49
    return DCOPRef( kapp->dcopClient()->appId(), t->dcopObject()->objId() );
47
50
}
48
51
 
49
 
DCOPRef KSpreadMapIface::sheetByIndex( int index )
 
52
DCOPRef MapIface::sheetByIndex( int index )
50
53
{
51
 
    KSpreadSheet* t = m_map->sheetList().at( index );
 
54
    Sheet* t = m_map->sheetList().at( index );
52
55
    if ( !t )
53
56
    {
54
57
        kdDebug(36001) << "+++++ No table found at index " << index << endl;
60
63
    return DCOPRef( kapp->dcopClient()->appId(), t->dcopObject()->objId() );
61
64
}
62
65
 
63
 
int KSpreadMapIface::sheetCount() const
 
66
int MapIface::sheetCount() const
64
67
{
65
68
    return m_map->count();
66
69
}
67
70
 
68
 
QStringList KSpreadMapIface::sheetNames() const
 
71
QStringList MapIface::sheetNames() const
69
72
{
70
73
    QStringList names;
71
74
 
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() );
76
79
 
77
80
    return names;
78
81
}
79
82
 
80
 
QValueList<DCOPRef> KSpreadMapIface::sheets()
 
83
QValueList<DCOPRef> MapIface::sheets()
81
84
{
82
85
    QValueList<DCOPRef> t;
83
86
 
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() ) );
88
91
 
89
92
    return t;
90
93
}
91
94
 
92
 
DCOPRef KSpreadMapIface::insertSheet( const QString& name )
 
95
DCOPRef MapIface::insertSheet( const QString& name )
93
96
{
94
97
    if ( m_map->findSheet( name ) )
95
98
        return sheet( name );
96
99
 
97
 
    KSpreadSheet* t = m_map->addNewSheet ();
 
100
    Sheet* t = m_map->addNewSheet ();
98
101
    t->setSheetName( name );
99
102
 
100
103
    return sheet( name );
101
104
}
102
105
 
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)
105
108
{
106
109
    // Does the name follow the pattern "foobar()" ?
107
110
    uint len = fun.length();
108
111
    if ( len < 3 )
109
 
        return FALSE;
 
112
        return false;
110
113
 
111
114
    if ( fun[ len - 1 ] != ')' || fun[ len - 2 ] != '(' )
112
 
        return FALSE;
 
115
        return false;
113
116
 
114
 
    KSpreadSheet* t = m_map->findSheet( fun.left( len - 2 ).data() );
 
117
    Sheet* t = m_map->findSheet( fun.left( len - 2 ).data() );
115
118
    if ( !t )
116
 
        return FALSE;
 
119
        return false;
117
120
 
118
121
    replyType = "DCOPRef";
119
122
    QDataStream out( replyData, IO_WriteOnly );
120
123
    out << DCOPRef( kapp->dcopClient()->appId(), t->dcopObject()->objId() );
121
 
    return TRUE;
 
124
    return true;
122
125
}