lib

KoApplicationIface.cpp
1/* This file is part of the KDE project
2 Copyright (C) 2000 David Faure <faure@kde.org>
3
4 This library is free software; you can redistribute it and/or
5 modify it under the terms of the GNU Library General Public
6 License as published by the Free Software Foundation; either
7 version 2 of the License.
8
9 This library is distributed in the hope that it will be useful,
10 but WITHOUT ANY WARRANTY; without even the implied warranty of
11 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
12 Library General Public License for more details.
13
14 You should have received a copy of the GNU Library General Public License
15 along with this library; see the file COPYING.LIB. If not, write to
16 the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
17 * Boston, MA 02110-1301, USA.
18*/
19
20
21#include <dcopclient.h>
22#include <kdebug.h>
23#include <tdelocale.h>
24#include <tdemessagebox.h>
25
26#include "KoApplication.h"
27#include "KoApplicationIface.h"
28#include "KoDocument.h"
29#include "KoDocumentIface.h"
30#include "KoMainWindow.h"
31#include "KoQueryTrader.h"
32#include "KoView.h"
33
34KoApplicationIface::KoApplicationIface()
35 : DCOPObject( "KoApplicationIface" )
36{
37}
38
39KoApplicationIface::~KoApplicationIface()
40{
41}
42
43DCOPRef KoApplicationIface::createDocument( const TQString &nativeFormat )
44{
46 if ( entry.isEmpty() )
47 {
48 KMessageBox::questionYesNo( 0, i18n( "Unknown KOffice MimeType %s. Check your installation." ).arg( nativeFormat ) );
49 return DCOPRef();
50 }
51 KoDocument* doc = entry.createDoc( 0 );
52 return DCOPRef( kapp->dcopClient()->appId(), doc->dcopObject()->objId() );
53}
54
56{
57 TQValueList<DCOPRef> lst;
58 TQPtrList<KoDocument> *documents = KoDocument::documentList();
59 if ( documents )
60 {
61 TQPtrListIterator<KoDocument> it( *documents );
62 for (; it.current(); ++it )
63 lst.append( DCOPRef( kapp->dcopClient()->appId(), it.current()->dcopObject()->objId() ) );
64 }
65 return lst;
66}
67
68TQValueList<DCOPRef> KoApplicationIface::getViews()
69{
70 TQValueList<DCOPRef> lst;
71 TQPtrList<KoDocument> *documents = KoDocument::documentList();
72 if ( documents )
73 {
74 TQPtrListIterator<KoDocument> it( *documents );
75 for (; it.current(); ++it )
76 {
77 TQPtrListIterator<KoView> itview( it.current()->views() );
78 for ( ; itview.current(); ++itview )
79 lst.append( DCOPRef( kapp->dcopClient()->appId(), itview.current()->dcopObject()->objId() ) );
80 }
81 }
82 return lst;
83}
84
85TQValueList<DCOPRef> KoApplicationIface::getWindows()
86{
87 TQValueList<DCOPRef> lst;
88 TQPtrList<TDEMainWindow> *mainWindows = TDEMainWindow::memberList;
89 if ( mainWindows )
90 {
91 TQPtrListIterator<TDEMainWindow> it( *mainWindows );
92 for (; it.current(); ++it )
93 lst.append( DCOPRef( kapp->dcopClient()->appId(),
94 static_cast<KoMainWindow *>(it.current())->dcopObject()->objId() ) );
95 }
96 return lst;
97}
TQCString objId() const
static int questionYesNo(TQWidget *parent, const TQString &text, const TQString &caption=TQString::null, const KGuiItem &buttonYes=KStdGuiItem::yes(), const KGuiItem &buttonNo=KStdGuiItem::no(), const TQString &dontAskAgainName=TQString::null, int options=Notify)
TQValueList< DCOPRef > getWindows()
TQValueList< DCOPRef > getViews()
TQValueList< DCOPRef > getDocuments()
DCOPRef createDocument(const TQString &nativeFormat)
Creates a new document for the given native mimetype Use it to create a shell and to load an existing...
Represents an available KOffice component that supports the document interface.
static KoDocumentEntry queryByMimeType(const TQString &mimetype)
This is a convenience function.
bool isEmpty() const
KoDocument * createDoc(KoDocument *parent=0, const char *name=0) const
Uses the factory of the component to create a document.
The KOffice document class.
Definition KoDocument.h:61
static TQPtrList< KoDocument > * documentList()
Definition KoDocument.h:712
virtual DCOPObject * dcopObject()
Return a DCOP interface for this document.
Main window for a KOffice application.
static TQPtrList< TDEMainWindow > * memberList