kspread

KSpreadAppIface.cpp
1/* This file is part of the KDE project
2
3 Copyright 2004 Ariya Hidayat <ariya@kde.org>
4 Copyright 2003 David Faure <faure@kde.org>
5 Copyright 2001 Philipp Mueller <philipp.mueller@gmx.de>
6 Copyright 2001 Laurent Montel <montel@kde.org>
7 Copyright 2002 Werner Trobin <trobin@kde.org>
8 Copyright 1999 Torben Weis <weis@kde.org>
9
10 This library is free software; you can redistribute it and/or
11 modify it under the terms of the GNU Library General Public
12 License as published by the Free Software Foundation; either
13 version 2 of the License, or (at your option) any later version.
14
15 This library is distributed in the hope that it will be useful,
16 but WITHOUT ANY WARRANTY; without even the implied warranty of
17 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
18 Library General Public License for more details.
19
20 You should have received a copy of the GNU Library General Public License
21 along with this library; see the file COPYING.LIB. If not, write to
22 the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
23 * Boston, MA 02110-1301, USA.
24
25*/
26
27#include "KSpreadAppIface.h"
28
29#include "kspread_doc.h"
30
31#include <dcopclient.h>
32#include <tdeapplication.h>
33
34using namespace KSpread;
35
36AppIface::AppIface()
37 : DCOPObject( "Application" )
38{
39}
40
41DCOPRef AppIface::createDoc()
42{
43 Doc* doc = new Doc();
44 doc->initDoc(KoDocument::InitDocFileNew);
45
46 return DCOPRef( kapp->dcopClient()->appId(), doc->dcopObject()->objId() );
47}
48
49DCOPRef AppIface::createDoc( const TQString& name )
50{
51 // ######### Torben: Check for duplicate names here
52 Doc* doc = new Doc( 0, name.latin1() );
53 doc->initDoc( KoDocument::InitDocEmpty, 0 );
54
55 return DCOPRef( kapp->dcopClient()->appId(), doc->dcopObject()->objId() );
56}
57
58TQMap<TQString,DCOPRef> AppIface::documents()
59{
60 TQMap<TQString,DCOPRef> map;
61
62 TQValueList<Doc*> lst = Doc::documents();
63 TQValueListIterator<Doc*> it = lst.begin();
64 for( ; it != lst.end(); ++it )
65 {
66 map[ TQString( (*it)->name() ) ] =
67 DCOPRef( kapp->dcopClient()->appId(), (*it)->dcopObject()->objId() );
68 }
69
70 return map;
71}
72
73DCOPRef AppIface::document( const TQString& name )
74{
75 TQValueList<Doc*> lst = Doc::documents();
76 TQValueListIterator<Doc*> it = lst.begin();
77 for( ; it != lst.end(); ++it )
78 if ( name == (*it)->name() )
79 return DCOPRef( kapp->dcopClient()->appId(), (*it)->dcopObject()->objId() );
80
81 return DCOPRef();
82}
83
This class holds the data that makes up a spreadsheet.
Definition kspread_doc.h:98
static TQValueList< Doc * > documents()
Returns list of all documents.
The KSpread namespace.
Definition commands.h:39