lib
KoApplicationIface.cc00001
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 KoApplicationIface::KoApplicationIface()
00035 : DCOPObject( "KoApplicationIface" )
00036 {
00037 }
00038
00039 KoApplicationIface::~KoApplicationIface()
00040 {
00041 }
00042
00043 DCOPRef KoApplicationIface::createDocument( const QString &nativeFormat )
00044 {
00045 KoDocumentEntry entry = KoDocumentEntry::queryByMimeType( nativeFormat );
00046 if ( entry.isEmpty() )
00047 {
00048 KMessageBox::questionYesNo( 0, i18n( "Unknown KOffice MimeType %s. Check your installation." ).arg( nativeFormat ) );
00049 return DCOPRef();
00050 }
00051 KoDocument* doc = entry.createDoc( 0 );
00052 return DCOPRef( kapp->dcopClient()->appId(), doc->dcopObject()->objId() );
00053 }
00054
00055 QValueList<DCOPRef> KoApplicationIface::getDocuments()
00056 {
00057 QValueList<DCOPRef> lst;
00058 QPtrList<KoDocument> *documents = KoDocument::documentList();
00059 if ( documents )
00060 {
00061 QPtrListIterator<KoDocument> it( *documents );
00062 for (; it.current(); ++it )
00063 lst.append( DCOPRef( kapp->dcopClient()->appId(), it.current()->dcopObject()->objId() ) );
00064 }
00065 return lst;
00066 }
00067
00068 QValueList<DCOPRef> KoApplicationIface::getViews()
00069 {
00070 QValueList<DCOPRef> lst;
00071 QPtrList<KoDocument> *documents = KoDocument::documentList();
00072 if ( documents )
00073 {
00074 QPtrListIterator<KoDocument> it( *documents );
00075 for (; it.current(); ++it )
00076 {
00077 QPtrListIterator<KoView> itview( it.current()->views() );
00078 for ( ; itview.current(); ++itview )
00079 lst.append( DCOPRef( kapp->dcopClient()->appId(), itview.current()->dcopObject()->objId() ) );
00080 }
00081 }
00082 return lst;
00083 }
00084
00085 QValueList<DCOPRef> KoApplicationIface::getWindows()
00086 {
00087 QValueList<DCOPRef> lst;
00088 QPtrList<KMainWindow> *mainWindows = KMainWindow::memberList;
00089 if ( mainWindows )
00090 {
00091 QPtrListIterator<KMainWindow> it( *mainWindows );
00092 for (; it.current(); ++it )
00093 lst.append( DCOPRef( kapp->dcopClient()->appId(),
00094 static_cast<KoMainWindow *>(it.current())->dcopObject()->objId() ) );
00095 }
00096 return lst;
00097 }
|