00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021 #include <dcopclient.h>
00022 #include <kdebug.h>
00023 #include <klocale.h>
00024 #include <kmessagebox.h>
00025
00026 #include "KoApplication.h"
00027 #include "KoApplicationIface.h"
00028 #include "KoDocument.h"
00029 #include "KoDocumentIface.h"
00030 #include "KoMainWindow.h"
00031 #include "KoQueryTrader.h"
00032 #include "KoView.h"
00033
00034 #include <Q3ValueList>
00035 #include <Q3PtrList>
00036
00037 KoApplicationIface::KoApplicationIface()
00038 : DCOPObject( "KoApplicationIface" )
00039 {
00040 }
00041
00042 KoApplicationIface::~KoApplicationIface()
00043 {
00044 }
00045
00046 DCOPRef KoApplicationIface::createDocument( const QString &nativeFormat )
00047 {
00048 KoDocumentEntry entry = KoDocumentEntry::queryByMimeType( nativeFormat );
00049 if ( entry.isEmpty() )
00050 {
00051 KMessageBox::questionYesNo( 0, i18n( "Unknown KOffice MimeType %s. Check your installation.", nativeFormat ) );
00052 return DCOPRef();
00053 }
00054 KoDocument* doc = entry.createDoc( 0 );
00055 return DCOPRef( kapp->dcopClient()->appId(), doc->dcopObject()->objId() );
00056 }
00057
00058 Q3ValueList<DCOPRef> KoApplicationIface::getDocuments()
00059 {
00060 Q3ValueList<DCOPRef> lst;
00061 Q3PtrList<KoDocument> *documents = KoDocument::documentList();
00062 if ( documents )
00063 {
00064 Q3PtrListIterator<KoDocument> it( *documents );
00065 for (; it.current(); ++it )
00066 lst.append( DCOPRef( kapp->dcopClient()->appId(), it.current()->dcopObject()->objId() ) );
00067 }
00068 return lst;
00069 }
00070
00071 Q3ValueList<DCOPRef> KoApplicationIface::getViews()
00072 {
00073 Q3ValueList<DCOPRef> lst;
00074 Q3PtrList<KoDocument> *documents = KoDocument::documentList();
00075 if ( documents )
00076 {
00077 Q3PtrListIterator<KoDocument> it( *documents );
00078 for (; it.current(); ++it )
00079 {
00080 foreach ( KoView* view, it.current()->views() )
00081 lst.append( DCOPRef( kapp->dcopClient()->appId(), view->dcopObject()->objId() ) );
00082 }
00083 }
00084 return lst;
00085 }
00086
00087 Q3ValueList<DCOPRef> KoApplicationIface::getWindows()
00088 {
00089 Q3ValueList<DCOPRef> lst;
00090 QList<KMainWindow*> mainWindows = KMainWindow::memberList();
00091 if ( !mainWindows.isEmpty() )
00092 {
00093 foreach ( KMainWindow* mainWindow, mainWindows )
00094 lst.append( DCOPRef( kapp->dcopClient()->appId(),
00095 static_cast<KoMainWindow*>(mainWindow)->dcopObject()->objId() ) );
00096 }
00097 return lst;
00098 }