F:/KPlato/koffice/libs/kofficecore/KoDocumentIface.cc

Aller à la documentation de ce fichier.
00001 /* This file is part of the KDE project
00002    Copyright (C) 2000 David Faure <faure@kde.org>
00003 
00004    This library is free software; you can redistribute it and/or
00005    modify it under the terms of the GNU Library General Public
00006    License as published by the Free Software Foundation; either
00007    version 2 of the License.
00008 
00009    This library is distributed in the hope that it will be useful,
00010    but WITHOUT ANY WARRANTY; without even the implied warranty of
00011    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
00012    Library General Public License for more details.
00013 
00014    You should have received a copy of the GNU Library General Public License
00015    along with this library; see the file COPYING.LIB.  If not, write to
00016    the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
00017  * Boston, MA 02110-1301, USA.
00018 */
00019 
00020 #include "KoDocument.h"
00021 #include "KoDocumentIface.h"
00022 #include "KoDocumentInfoDlg.h"
00023 #include "KoDocumentInfo.h"
00024 #include "KoView.h"
00025 #include <kapplication.h>
00026 #include <dcopclient.h>
00027 #include <kdcopactionproxy.h>
00028 #include <kaction.h>
00029 #include <kdebug.h>
00030 #include <kdcoppropertyproxy.h>
00031 //Added by qt3to4:
00032 #include <Q3ValueList>
00033 #include <Q3PtrList>
00034 
00035 //static
00036 DCOPCString KoDocumentIface::newIfaceName()
00037 {
00038     static int s_docIFNumber = 0;
00039     DCOPCString name; name.setNum( s_docIFNumber++ ); name.prepend("Document-");
00040     return name;
00041 }
00042 
00043 KoDocumentIface::KoDocumentIface( KoDocument * doc, const char * name )
00044     : DCOPObject( name ? DCOPCString(name) : newIfaceName() )
00045 {
00046   m_pDoc = doc;
00047   m_actionProxy = new KDCOPActionProxy( doc->actionCollection(), this );
00048 }
00049 
00050 KoDocumentIface::~KoDocumentIface()
00051 {
00052     delete m_actionProxy;
00053 }
00054 
00055 void KoDocumentIface::openURL( const QString & url )
00056 {
00057   m_pDoc->openURL( KUrl( url ) );
00058 }
00059 
00060 bool KoDocumentIface::isLoading()
00061 {
00062   return m_pDoc->isLoading();
00063 }
00064 
00065 QString KoDocumentIface::url()
00066 {
00067   return m_pDoc->url().url();
00068 }
00069 
00070 bool KoDocumentIface::isModified()
00071 {
00072   return m_pDoc->isModified();
00073 }
00074 
00075 int KoDocumentIface::viewCount()
00076 {
00077   return m_pDoc->viewCount();
00078 }
00079 
00080 DCOPRef KoDocumentIface::view( int idx )
00081 {
00082   QList<KoView*> views = m_pDoc->views();
00083   KoView *v = views.at( idx );
00084   if ( !v )
00085     return DCOPRef();
00086 
00087   DCOPObject *obj = v->dcopObject();
00088 
00089   if ( !obj )
00090     return DCOPRef();
00091 
00092   return DCOPRef( kapp->dcopClient()->appId(), obj->objId() );
00093 }
00094 
00095 DCOPRef KoDocumentIface::action( const DCOPCString &name )
00096 {
00097     return DCOPRef( kapp->dcopClient()->appId(), m_actionProxy->actionObjectId( name ) );
00098 }
00099 
00100 DCOPCStringList KoDocumentIface::actions()
00101 {
00102     DCOPCStringList res;
00103     Q3ValueList<KAction *> lst = m_actionProxy->actions();
00104     Q3ValueList<KAction *>::ConstIterator it = lst.begin();
00105     Q3ValueList<KAction *>::ConstIterator end = lst.end();
00106     for (; it != end; ++it )
00107         res.append( (*it)->objectName().toUtf8() );
00108 
00109     return res;
00110 }
00111 
00112 QMap<DCOPCString,DCOPRef> KoDocumentIface::actionMap()
00113 {
00114     return m_actionProxy->actionMap();
00115 }
00116 
00117 void KoDocumentIface::save()
00118 {
00119     m_pDoc->save();
00120 }
00121 
00122 void KoDocumentIface::saveAs( const QString & url )
00123 {
00124     m_pDoc->saveAs( KUrl( url ) );
00125     m_pDoc->waitSaveComplete(); // see ReadWritePart
00126 }
00127 
00128 void KoDocumentIface::setOutputMimeType( const QByteArray& mimetype )
00129 {
00130     m_pDoc->setOutputMimeType( mimetype );
00131 }
00132 
00133 QString KoDocumentIface::documentInfoAuthorName() const
00134 {
00135     return m_pDoc->documentInfo()->authorInfo( "creator" );
00136 }
00137 
00138 QString KoDocumentIface::documentInfoEmail() const
00139 {
00140     return m_pDoc->documentInfo()->authorInfo( "email" );
00141 }
00142 
00143 QString KoDocumentIface::documentInfoCompanyName() const
00144 {
00145     return m_pDoc->documentInfo()->authorInfo( "company" );
00146 }
00147 
00148 QString KoDocumentIface::documentInfoTelephone() const
00149 {
00150     kDebug()<<" Keep compatibility with koffice <= 1.3 : use documentInfoTelephoneWork\n";
00151     return documentInfoTelephoneWork();
00152 }
00153 
00154 QString KoDocumentIface::documentInfoTelephoneWork() const
00155 {
00156     return m_pDoc->documentInfo()->authorInfo( "telephone-work" );
00157 }
00158 
00159 QString KoDocumentIface::documentInfoTelephoneHome() const
00160 {
00161     return m_pDoc->documentInfo()->authorInfo( "telephone-home" );
00162 }
00163 
00164 
00165 QString KoDocumentIface::documentInfoFax() const
00166 {
00167     return m_pDoc->documentInfo()->authorInfo( "fax" );
00168 
00169 }
00170 QString KoDocumentIface::documentInfoCountry() const
00171 {
00172     return m_pDoc->documentInfo()->authorInfo( "country" );
00173 
00174 }
00175 QString KoDocumentIface::documentInfoPostalCode() const
00176 {
00177     return m_pDoc->documentInfo()->authorInfo( "postal-code" );
00178 
00179 }
00180 QString KoDocumentIface::documentInfoCity() const
00181 {
00182     return m_pDoc->documentInfo()->authorInfo( "city" );
00183 }
00184 
00185 QString KoDocumentIface::documentInfoInitial() const
00186 {
00187     return m_pDoc->documentInfo()->authorInfo( "initial" );
00188 }
00189 
00190 QString KoDocumentIface::documentInfoAuthorPostion() const
00191 {
00192     return m_pDoc->documentInfo()->authorInfo( "position" );
00193 }
00194 
00195 QString KoDocumentIface::documentInfoStreet() const
00196 {
00197     return m_pDoc->documentInfo()->authorInfo( "street" );
00198 }
00199 
00200 QString KoDocumentIface::documentInfoTitle() const
00201 {
00202     return m_pDoc->documentInfo()->aboutInfo( "title" );
00203 }
00204 
00205 QString KoDocumentIface::documentInfoAbstract() const
00206 {
00207     return m_pDoc->documentInfo()->aboutInfo( "comments" );
00208 }
00209 
00210 QString KoDocumentIface::documentInfoKeywords() const
00211 {
00212     return m_pDoc->documentInfo()->aboutInfo( "keywords" );
00213 }
00214 
00215 QString KoDocumentIface::documentInfoSubject() const
00216 {
00217     return m_pDoc->documentInfo()->aboutInfo( "subject" );
00218 }
00219 void KoDocumentIface::setDocumentInfoKeywords(const QString & text )
00220 {
00221     m_pDoc->documentInfo()->setAboutInfo( "keywords", text );
00222 }
00223 
00224 void KoDocumentIface::setDocumentInfoSubject(const QString & text)
00225 {
00226     m_pDoc->documentInfo()->setAboutInfo( "subject", text );
00227 }
00228 
00229 void KoDocumentIface::setDocumentInfoAuthorName(const QString & text)
00230 {
00231     m_pDoc->documentInfo()->setAuthorInfo( "creator", text );
00232 }
00233 
00234 void KoDocumentIface::setDocumentInfoEmail(const QString &text)
00235 {
00236     m_pDoc->documentInfo()->setAuthorInfo( "email", text );
00237 }
00238 
00239 void KoDocumentIface::setDocumentInfoCompanyName(const QString &text)
00240 {
00241     m_pDoc->documentInfo()->setAuthorInfo( "company", text );
00242 }
00243 
00244 void KoDocumentIface::setDocumentInfoAuthorPosition(const QString &text)
00245 {
00246     m_pDoc->documentInfo()->setAuthorInfo( "position", text );
00247 }
00248 
00249 
00250 void KoDocumentIface::setDocumentInfoTelephone(const QString &text)
00251 {
00252     kDebug()<<"Keep compatibility with koffice <= 1.3 : use setDocumentInfoTelephoneWork\n";
00253     setDocumentInfoTelephoneWork(text);
00254 }
00255 
00256 void KoDocumentIface::setDocumentInfoTelephoneWork(const QString &text)
00257 {
00258     m_pDoc->documentInfo()->setAuthorInfo( "telephone-work", text );
00259 }
00260 
00261 void KoDocumentIface::setDocumentInfoTelephoneHome(const QString &text)
00262 {
00263     m_pDoc->documentInfo()->setAuthorInfo( "telephone", text );
00264 }
00265 
00266 void KoDocumentIface::setDocumentInfoFax(const QString &text)
00267 {
00268     m_pDoc->documentInfo()->setAuthorInfo( "fax", text );
00269 }
00270 
00271 void KoDocumentIface::setDocumentInfoCountry(const QString &text)
00272 {
00273     m_pDoc->documentInfo()->setAuthorInfo( "country", text );
00274 }
00275 
00276 void KoDocumentIface::setDocumentInfoTitle(const QString & text)
00277 {
00278     m_pDoc->documentInfo()->setAboutInfo( "title", text );
00279 }
00280 
00281 void KoDocumentIface::setDocumentInfoPostalCode(const QString &text)
00282 {
00283     m_pDoc->documentInfo()->setAuthorInfo( "postal-code", text );
00284 }
00285 
00286 void KoDocumentIface::setDocumentInfoCity(const QString & text)
00287 {
00288     m_pDoc->documentInfo()->setAuthorInfo( "city", text );
00289 }
00290 
00291 void KoDocumentIface::setDocumentInfoInitial(const QString & text)
00292 {
00293     m_pDoc->documentInfo()->setAuthorInfo( "initial", text );
00294 }
00295 
00296 void KoDocumentIface::setDocumentInfoStreet(const QString &text)
00297 {
00298     m_pDoc->documentInfo()->setAuthorInfo( "street", text );
00299 }
00300 
00301 void KoDocumentIface::setDocumentInfoAbstract(const QString &text)
00302 {
00303     m_pDoc->documentInfo()->setAboutInfo( "comments", text );
00304 }
00305 
00306 DCOPCStringList KoDocumentIface::functionsDynamic()
00307 {
00308     return DCOPObject::functionsDynamic() + KDCOPPropertyProxy::functions( m_pDoc );
00309 }
00310 
00311 bool KoDocumentIface::processDynamic( const DCOPCString &fun, const QByteArray &data,
00312                                       DCOPCString& replyType, QByteArray &replyData )
00313 {
00314     if ( KDCOPPropertyProxy::isPropertyRequest( fun, m_pDoc ) )
00315         return KDCOPPropertyProxy::processPropertyRequest( fun, data, replyType, replyData, m_pDoc );
00316 
00317     return DCOPObject::processDynamic( fun, data, replyType, replyData );
00318 }
00319 

Généré le Wed Nov 22 23:41:02 2006 pour KPlato par  doxygen 1.5.1-p1