kspread Library API Documentation

KSpreadAppIface.cc

00001 /* This file is part of the KDE project
00002    
00003    Copyright 2004 Ariya Hidayat <ariya@kde.org>
00004    Copyright 2003 David Faure <faure@kde.org>
00005    Copyright 2001 Philipp Mueller <philipp.mueller@gmx.de>
00006    Copyright 2001 Laurent Montel <montel@kde.org>
00007    Copyright 2002 Werner Trobin <trobin@kde.org>
00008    Copyright 1999 Torben Weis <weis@kde.org>
00009 
00010    This library is free software; you can redistribute it and/or
00011    modify it under the terms of the GNU Library General Public
00012    License as published by the Free Software Foundation; either
00013    version 2 of the License, or (at your option) any later version.
00014 
00015    This library is distributed in the hope that it will be useful,
00016    but WITHOUT ANY WARRANTY; without even the implied warranty of
00017    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
00018    Library General Public License for more details.
00019 
00020    You should have received a copy of the GNU Library General Public License
00021    along with this library; see the file COPYING.LIB.  If not, write to
00022    the Free Software Foundation, Inc., 59 Temple Place - Suite 330,
00023    Boston, MA 02111-1307, USA.
00024    
00025 */
00026 
00027 #include "KSpreadAppIface.h"
00028 
00029 #include "kspread_doc.h"
00030 
00031 #include <dcopclient.h>
00032 #include <kapplication.h>
00033 
00034 KSpreadAppIface::KSpreadAppIface()
00035     : DCOPObject( "Application" )
00036 {
00037 }
00038 
00039 DCOPRef KSpreadAppIface::createDoc()
00040 {
00041     KSpreadDoc* doc = new KSpreadDoc();
00042     doc->initDoc(KoDocument::InitDocFileNew);
00043 
00044     return DCOPRef( kapp->dcopClient()->appId(), doc->dcopObject()->objId() );
00045 }
00046 
00047 DCOPRef KSpreadAppIface::createDoc( const QString& name )
00048 {
00049     // ######### Torben: Check for duplicate names here
00050     KSpreadDoc* doc = new KSpreadDoc( 0, name.latin1() );
00051     doc->initDoc( KoDocument::InitDocEmpty, 0 );
00052 
00053     return DCOPRef( kapp->dcopClient()->appId(), doc->dcopObject()->objId() );
00054 }
00055 
00056 QMap<QString,DCOPRef> KSpreadAppIface::documents()
00057 {
00058     QMap<QString,DCOPRef> map;
00059 
00060     QValueList<KSpreadDoc*> lst = KSpreadDoc::documents();
00061     QValueListIterator<KSpreadDoc*> it = lst.begin();
00062     for( ; it != lst.end(); ++it )
00063     {
00064     map[ QString( (*it)->name() ) ] =
00065      DCOPRef( kapp->dcopClient()->appId(), (*it)->dcopObject()->objId() );
00066     }
00067 
00068     return map;
00069 }
00070 
00071 DCOPRef KSpreadAppIface::document( const QString& name )
00072 {
00073     QValueList<KSpreadDoc*> lst = KSpreadDoc::documents();
00074     QValueListIterator<KSpreadDoc*> it = lst.begin();
00075     for( ; it != lst.end(); ++it )
00076     if ( name == (*it)->name() )
00077         return DCOPRef( kapp->dcopClient()->appId(), (*it)->dcopObject()->objId() );
00078 
00079     return DCOPRef();
00080 }
00081 
KDE Logo
This file is part of the documentation for kspread Library Version 1.4.2.
Documentation copyright © 1996-2004 the KDE developers.
Generated on Mon Feb 13 09:43:38 2006 by doxygen 1.4.2 written by Dimitri van Heesch, © 1997-2003