kspread

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., 51 Franklin Street, Fifth Floor,
00023  * Boston, MA 02110-1301, 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 using namespace KSpread;
00035 
00036 AppIface::AppIface()
00037     : DCOPObject( "Application" )
00038 {
00039 }
00040 
00041 DCOPRef AppIface::createDoc()
00042 {
00043     Doc* doc = new Doc();
00044     doc->initDoc(KoDocument::InitDocFileNew);
00045 
00046     return DCOPRef( kapp->dcopClient()->appId(), doc->dcopObject()->objId() );
00047 }
00048 
00049 DCOPRef AppIface::createDoc( const QString& name )
00050 {
00051     // ######### Torben: Check for duplicate names here
00052     Doc* doc = new Doc( 0, name.latin1() );
00053     doc->initDoc( KoDocument::InitDocEmpty, 0 );
00054 
00055     return DCOPRef( kapp->dcopClient()->appId(), doc->dcopObject()->objId() );
00056 }
00057 
00058 QMap<QString,DCOPRef> AppIface::documents()
00059 {
00060     QMap<QString,DCOPRef> map;
00061 
00062     QValueList<Doc*> lst = Doc::documents();
00063     QValueListIterator<Doc*> it = lst.begin();
00064     for( ; it != lst.end(); ++it )
00065     {
00066     map[ QString( (*it)->name() ) ] =
00067      DCOPRef( kapp->dcopClient()->appId(), (*it)->dcopObject()->objId() );
00068     }
00069 
00070     return map;
00071 }
00072 
00073 DCOPRef AppIface::document( const QString& name )
00074 {
00075     QValueList<Doc*> lst = Doc::documents();
00076     QValueListIterator<Doc*> it = lst.begin();
00077     for( ; it != lst.end(); ++it )
00078     if ( name == (*it)->name() )
00079         return DCOPRef( kapp->dcopClient()->appId(), (*it)->dcopObject()->objId() );
00080 
00081     return DCOPRef();
00082 }
00083 
KDE Home | KDE Accessibility Home | Description of Access Keys