KoDocumentIface.cc
00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
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
00032
00033 QCString KoDocumentIface::newIfaceName()
00034 {
00035 static int s_docIFNumber = 0;
00036 QCString name; name.setNum( s_docIFNumber++ ); name.prepend("Document-");
00037 return name;
00038 }
00039
00040 KoDocumentIface::KoDocumentIface( KoDocument * doc, const char * name )
00041 : DCOPObject( name ? QCString(name) : newIfaceName() )
00042 {
00043 m_pDoc = doc;
00044 m_actionProxy = new KDCOPActionProxy( doc->actionCollection(), this );
00045 }
00046
00047 KoDocumentIface::~KoDocumentIface()
00048 {
00049 delete m_actionProxy;
00050 }
00051
00052 void KoDocumentIface::openURL( QString url )
00053 {
00054 m_pDoc->openURL( KURL( url ) );
00055 }
00056
00057 bool KoDocumentIface::isLoading()
00058 {
00059 return m_pDoc->isLoading();
00060 }
00061
00062 QString KoDocumentIface::url()
00063 {
00064 return m_pDoc->url().url();
00065 }
00066
00067 bool KoDocumentIface::isModified()
00068 {
00069 return m_pDoc->isModified();
00070 }
00071
00072 int KoDocumentIface::viewCount()
00073 {
00074 return m_pDoc->viewCount();
00075 }
00076
00077 DCOPRef KoDocumentIface::view( int idx )
00078 {
00079 QPtrList<KoView> views = m_pDoc->views();
00080 KoView *v = views.at( idx );
00081 if ( !v )
00082 return DCOPRef();
00083
00084 DCOPObject *obj = v->dcopObject();
00085
00086 if ( !obj )
00087 return DCOPRef();
00088
00089 return DCOPRef( kapp->dcopClient()->appId(), obj->objId() );
00090 }
00091
00092 DCOPRef KoDocumentIface::action( const QCString &name )
00093 {
00094 return DCOPRef( kapp->dcopClient()->appId(), m_actionProxy->actionObjectId( name ) );
00095 }
00096
00097 QCStringList KoDocumentIface::actions()
00098 {
00099 QCStringList res;
00100 QValueList<KAction *> lst = m_actionProxy->actions();
00101 QValueList<KAction *>::ConstIterator it = lst.begin();
00102 QValueList<KAction *>::ConstIterator end = lst.end();
00103 for (; it != end; ++it )
00104 res.append( (*it)->name() );
00105
00106 return res;
00107 }
00108
00109 QMap<QCString,DCOPRef> KoDocumentIface::actionMap()
00110 {
00111 return m_actionProxy->actionMap();
00112 }
00113
00114 void KoDocumentIface::save()
00115 {
00116 m_pDoc->save();
00117 }
00118
00119 void KoDocumentIface::saveAs( const QString & url )
00120 {
00121 m_pDoc->saveAs( KURL( url ) );
00122 m_pDoc->waitSaveComplete();
00123 }
00124
00125 void KoDocumentIface::setOutputMimeType( const QCString & mimetype )
00126 {
00127 m_pDoc->setOutputMimeType( mimetype );
00128 }
00129
00130 QString KoDocumentIface::documentInfoAuthorName() const
00131 {
00132 KoDocumentInfo * info = m_pDoc->documentInfo();
00133 KoDocumentInfoAuthor * authorPage = static_cast<KoDocumentInfoAuthor *>(info->page( "author" ));
00134 if ( !authorPage )
00135 {
00136 kdWarning() << "Author information not found in documentInfo !" << endl;
00137 return QString::null;
00138 }
00139 else
00140 return authorPage->fullName();
00141 }
00142
00143 QString KoDocumentIface::documentInfoEmail() const
00144 {
00145 KoDocumentInfo * info = m_pDoc->documentInfo();
00146 KoDocumentInfoAuthor * authorPage = static_cast<KoDocumentInfoAuthor *>(info->page( "author" ));
00147 if ( !authorPage )
00148 {
00149 kdWarning() << "Author information not found in documentInfo !" << endl;
00150 return QString::null;
00151 }
00152 else
00153 return authorPage->email();
00154 }
00155
00156 QString KoDocumentIface::documentInfoCompanyName() const
00157 {
00158 KoDocumentInfo * info = m_pDoc->documentInfo();
00159 KoDocumentInfoAuthor * authorPage = static_cast<KoDocumentInfoAuthor *>(info->page( "author" ));
00160 if ( !authorPage )
00161 {
00162 kdWarning() << "Author information not found in documentInfo !" << endl;
00163 return QString::null;
00164 }
00165 else
00166 return authorPage->company();
00167 }
00168
00169 QString KoDocumentIface::documentInfoTelephone() const
00170 {
00171 kdDebug()<<" Keep compatibility with koffice <= 1.3 : use documentInfoTelephoneWork\n";
00172 return documentInfoTelephoneWork();
00173 }
00174
00175 QString KoDocumentIface::documentInfoTelephoneWork() const
00176 {
00177 KoDocumentInfo * info = m_pDoc->documentInfo();
00178 KoDocumentInfoAuthor * authorPage = static_cast<KoDocumentInfoAuthor *>(info->page( "author" ));
00179 if ( !authorPage )
00180 {
00181 kdWarning() << "Author information not found in documentInfo !" << endl;
00182 return QString::null;
00183 }
00184 else
00185 return authorPage->telephoneWork();
00186 }
00187
00188 QString KoDocumentIface::documentInfoTelephoneHome() const
00189 {
00190 KoDocumentInfo * info = m_pDoc->documentInfo();
00191 KoDocumentInfoAuthor * authorPage = static_cast<KoDocumentInfoAuthor *>(info->page( "author" ));
00192 if ( !authorPage )
00193 {
00194 kdWarning() << "Author information not found in documentInfo !" << endl;
00195 return QString::null;
00196 }
00197 else
00198 return authorPage->telephoneHome();
00199 }
00200
00201
00202 QString KoDocumentIface::documentInfoFax() const
00203 {
00204 KoDocumentInfo * info = m_pDoc->documentInfo();
00205 KoDocumentInfoAuthor * authorPage = static_cast<KoDocumentInfoAuthor *>(info->page( "author" ));
00206 if ( !authorPage )
00207 {
00208 kdWarning() << "Author information not found in documentInfo !" << endl;
00209 return QString::null;
00210 }
00211 else
00212 return authorPage->fax();
00213
00214 }
00215 QString KoDocumentIface::documentInfoCountry() const
00216 {
00217 KoDocumentInfo * info = m_pDoc->documentInfo();
00218 KoDocumentInfoAuthor * authorPage = static_cast<KoDocumentInfoAuthor *>(info->page( "author" ));
00219 if ( !authorPage )
00220 {
00221 kdWarning() << "Author information not found in documentInfo !" << endl;
00222 return QString::null;
00223 }
00224 else
00225 return authorPage->country();
00226
00227 }
00228 QString KoDocumentIface::documentInfoPostalCode() const
00229 {
00230 KoDocumentInfo * info = m_pDoc->documentInfo();
00231 KoDocumentInfoAuthor * authorPage = static_cast<KoDocumentInfoAuthor *>(info->page( "author" ));
00232 if ( !authorPage )
00233 {
00234 kdWarning() << "Author information not found in documentInfo !" << endl;
00235 return QString::null;
00236 }
00237 else
00238 return authorPage->postalCode();
00239
00240 }
00241 QString KoDocumentIface::documentInfoCity() const
00242 {
00243 KoDocumentInfo * info = m_pDoc->documentInfo();
00244 KoDocumentInfoAuthor * authorPage = static_cast<KoDocumentInfoAuthor *>(info->page( "author" ));
00245 if ( !authorPage )
00246 {
00247 kdWarning() << "Author information not found in documentInfo !" << endl;
00248 return QString::null;
00249 }
00250 else
00251 return authorPage->city();
00252
00253 }
00254
00255 QString KoDocumentIface::documentInfoInitial() const
00256 {
00257 KoDocumentInfo * info = m_pDoc->documentInfo();
00258 KoDocumentInfoAuthor * authorPage = static_cast<KoDocumentInfoAuthor *>(info->page( "author" ));
00259 if ( !authorPage )
00260 {
00261 kdWarning() << "Author information not found in documentInfo !" << endl;
00262 return QString::null;
00263 }
00264 else
00265 return authorPage->initial();
00266 }
00267
00268 QString KoDocumentIface::documentInfoAuthorPostion() const
00269 {
00270 KoDocumentInfo * info = m_pDoc->documentInfo();
00271 KoDocumentInfoAuthor * authorPage = static_cast<KoDocumentInfoAuthor *>(info->page( "author" ));
00272 if ( !authorPage )
00273 {
00274 kdWarning() << "Author information not found in documentInfo !" << endl;
00275 return QString::null;
00276 }
00277 else
00278 return authorPage->position();
00279 }
00280
00281
00282 QString KoDocumentIface::documentInfoStreet() const
00283 {
00284 KoDocumentInfo * info = m_pDoc->documentInfo();
00285 KoDocumentInfoAuthor * authorPage = static_cast<KoDocumentInfoAuthor *>(info->page( "author" ));
00286 if ( !authorPage )
00287 {
00288 kdWarning() << "Author information not found in documentInfo !" << endl;
00289 return QString::null;
00290 }
00291 else
00292 return authorPage->street();
00293
00294 }
00295
00296 QString KoDocumentIface::documentInfoTitle() const
00297 {
00298 KoDocumentInfo * info = m_pDoc->documentInfo();
00299 KoDocumentInfoAbout * aboutPage = static_cast<KoDocumentInfoAbout *>(info->page( "about" ));
00300 if ( !aboutPage )
00301 {
00302 kdWarning() << "'About' page not found in documentInfo !" << endl;
00303 return QString::null;
00304 }
00305 else
00306 return aboutPage->title();
00307
00308 }
00309
00310 QString KoDocumentIface::documentInfoAbstract() const
00311 {
00312 KoDocumentInfo * info = m_pDoc->documentInfo();
00313 KoDocumentInfoAbout * aboutPage = static_cast<KoDocumentInfoAbout *>(info->page( "about" ));
00314 if ( !aboutPage )
00315 {
00316 kdWarning() << "'About' page not found in documentInfo !" << endl;
00317 return QString::null;
00318 }
00319 else
00320 return aboutPage->abstract();
00321 }
00322
00323 QString KoDocumentIface::documentInfoKeywords() const
00324 {
00325 KoDocumentInfo * info = m_pDoc->documentInfo();
00326 KoDocumentInfoAbout * aboutPage = static_cast<KoDocumentInfoAbout *>(info->page( "about" ));
00327 if ( !aboutPage )
00328 {
00329 kdWarning() << "'About' page not found in documentInfo !" << endl;
00330 return QString::null;
00331 }
00332 else
00333 return aboutPage->keywords();
00334 }
00335
00336 QString KoDocumentIface::documentInfoSubject() const
00337 {
00338 KoDocumentInfo * info = m_pDoc->documentInfo();
00339 KoDocumentInfoAbout * aboutPage = static_cast<KoDocumentInfoAbout *>(info->page( "about" ));
00340 if ( !aboutPage )
00341 {
00342 kdWarning() << "'About' page not found in documentInfo !" << endl;
00343 return QString::null;
00344 }
00345 else
00346 return aboutPage->subject();
00347 }
00348 void KoDocumentIface::setDocumentInfoKeywords(const QString & text )
00349 {
00350 KoDocumentInfo * info = m_pDoc->documentInfo();
00351 KoDocumentInfoAbout * aboutPage = static_cast<KoDocumentInfoAbout *>(info->page( "about" ));
00352 if ( !aboutPage )
00353 {
00354 kdWarning() << "'About' page not found in documentInfo !" << endl;
00355 }
00356 else
00357 aboutPage->setKeywords(text);
00358 }
00359
00360 void KoDocumentIface::setDocumentInfoSubject(const QString & text)
00361 {
00362 KoDocumentInfo * info = m_pDoc->documentInfo();
00363 KoDocumentInfoAbout * aboutPage = static_cast<KoDocumentInfoAbout *>(info->page( "about" ));
00364 if ( !aboutPage )
00365 {
00366 kdWarning() << "'About' page not found in documentInfo !" << endl;
00367 }
00368 else
00369 aboutPage->setSubject(text);
00370 }
00371
00372 void KoDocumentIface::setDocumentInfoAuthorName(const QString & text)
00373 {
00374 KoDocumentInfo * info = m_pDoc->documentInfo();
00375 KoDocumentInfoAuthor * authorPage = static_cast<KoDocumentInfoAuthor *>(info->page( "author" ));
00376 if ( !authorPage )
00377 {
00378 kdWarning() << "Author information not found in documentInfo !" << endl;
00379 }
00380 else
00381 authorPage->setFullName(text);
00382
00383 }
00384
00385 void KoDocumentIface::setDocumentInfoEmail(const QString &text)
00386 {
00387 KoDocumentInfo * info = m_pDoc->documentInfo();
00388 KoDocumentInfoAuthor * authorPage = static_cast<KoDocumentInfoAuthor *>(info->page( "author" ));
00389 if ( !authorPage )
00390 {
00391 kdWarning() << "Author information not found in documentInfo !" << endl;
00392 }
00393 else
00394 authorPage->setEmail(text);
00395 }
00396
00397 void KoDocumentIface::setDocumentInfoCompanyName(const QString &text)
00398 {
00399 KoDocumentInfo * info = m_pDoc->documentInfo();
00400 KoDocumentInfoAuthor * authorPage = static_cast<KoDocumentInfoAuthor *>(info->page( "author" ));
00401 if ( !authorPage )
00402 {
00403 kdWarning() << "Author information not found in documentInfo !" << endl;
00404 }
00405 else
00406 authorPage->setCompany(text);
00407 }
00408
00409 void KoDocumentIface::setDocumentInfoAuthorPosition(const QString &text)
00410 {
00411 KoDocumentInfo * info = m_pDoc->documentInfo();
00412 KoDocumentInfoAuthor * authorPage = static_cast<KoDocumentInfoAuthor *>(info->page( "author" ));
00413 if ( !authorPage )
00414 {
00415 kdWarning() << "Author information not found in documentInfo !" << endl;
00416 }
00417 else
00418 authorPage->setPosition(text);
00419 }
00420
00421
00422 void KoDocumentIface::setDocumentInfoTelephone(const QString &text)
00423 {
00424 kdDebug()<<"Keep compatibility with koffice <= 1.3 : use setDocumentInfoTelephoneWork\n";
00425 setDocumentInfoTelephoneWork(text);
00426 }
00427
00428 void KoDocumentIface::setDocumentInfoTelephoneWork(const QString &text)
00429 {
00430 KoDocumentInfo * info = m_pDoc->documentInfo();
00431 KoDocumentInfoAuthor * authorPage = static_cast<KoDocumentInfoAuthor *>(info->page( "author" ));
00432 if ( !authorPage )
00433 {
00434 kdWarning() << "Author information not found in documentInfo !" << endl;
00435 }
00436 else
00437 authorPage->setTelephoneWork(text);
00438 }
00439
00440 void KoDocumentIface::setDocumentInfoTelephoneHome(const QString &text)
00441 {
00442 KoDocumentInfo * info = m_pDoc->documentInfo();
00443 KoDocumentInfoAuthor * authorPage = static_cast<KoDocumentInfoAuthor *>(info->page( "author" ));
00444 if ( !authorPage )
00445 {
00446 kdWarning() << "Author information not found in documentInfo !" << endl;
00447 }
00448 else
00449 authorPage->setTelephoneHome(text);
00450 }
00451
00452
00453 void KoDocumentIface::setDocumentInfoFax(const QString &text)
00454 {
00455 KoDocumentInfo * info = m_pDoc->documentInfo();
00456 KoDocumentInfoAuthor * authorPage = static_cast<KoDocumentInfoAuthor *>(info->page( "author" ));
00457 if ( !authorPage )
00458 {
00459 kdWarning() << "Author information not found in documentInfo !" << endl;
00460 }
00461 else
00462 authorPage->setFax(text);
00463 }
00464
00465 void KoDocumentIface::setDocumentInfoCountry(const QString &text)
00466 {
00467 KoDocumentInfo * info = m_pDoc->documentInfo();
00468 KoDocumentInfoAuthor * authorPage = static_cast<KoDocumentInfoAuthor *>(info->page( "author" ));
00469 if ( !authorPage )
00470 {
00471 kdWarning() << "Author information not found in documentInfo !" << endl;
00472 }
00473 else
00474 authorPage->setCountry(text);
00475
00476 }
00477
00478 void KoDocumentIface::setDocumentInfoTitle(const QString & text)
00479 {
00480 KoDocumentInfo * info = m_pDoc->documentInfo();
00481 KoDocumentInfoAbout * aboutPage = static_cast<KoDocumentInfoAbout *>(info->page( "about" ));
00482 if ( !aboutPage )
00483 {
00484 kdWarning() << "'About' page not found in documentInfo !" << endl;
00485 }
00486 else
00487 aboutPage->setTitle(text);
00488 }
00489
00490 void KoDocumentIface::setDocumentInfoPostalCode(const QString &text)
00491 {
00492 KoDocumentInfo * info = m_pDoc->documentInfo();
00493 KoDocumentInfoAuthor * authorPage = static_cast<KoDocumentInfoAuthor *>(info->page( "author" ));
00494 if ( !authorPage )
00495 {
00496 kdWarning() << "Author information not found in documentInfo !" << endl;
00497 }
00498 else
00499 authorPage->setPostalCode(text);
00500
00501 }
00502
00503
00504 void KoDocumentIface::setDocumentInfoCity(const QString & text)
00505 {
00506 KoDocumentInfo * info = m_pDoc->documentInfo();
00507 KoDocumentInfoAuthor * authorPage = static_cast<KoDocumentInfoAuthor *>(info->page( "author" ));
00508 if ( !authorPage )
00509 {
00510 kdWarning() << "Author information not found in documentInfo !" << endl;
00511 }
00512 else
00513 authorPage->setCity(text);
00514 }
00515
00516 void KoDocumentIface::setDocumentInfoInitial(const QString & text)
00517 {
00518 KoDocumentInfo * info = m_pDoc->documentInfo();
00519 KoDocumentInfoAuthor * authorPage = static_cast<KoDocumentInfoAuthor *>(info->page( "author" ));
00520 if ( !authorPage )
00521 {
00522 kdWarning() << "Author information not found in documentInfo !" << endl;
00523 }
00524 else
00525 authorPage->setInitial(text);
00526 }
00527
00528
00529 void KoDocumentIface::setDocumentInfoStreet(const QString &text)
00530 {
00531 KoDocumentInfo * info = m_pDoc->documentInfo();
00532 KoDocumentInfoAuthor * authorPage = static_cast<KoDocumentInfoAuthor *>(info->page( "author" ));
00533 if ( !authorPage )
00534 {
00535 kdWarning() << "Author information not found in documentInfo !" << endl;
00536 }
00537 else
00538 authorPage->setStreet(text);
00539
00540 }
00541
00542
00543 void KoDocumentIface::setDocumentInfoAbstract(const QString &text)
00544 {
00545 KoDocumentInfo * info = m_pDoc->documentInfo();
00546 KoDocumentInfoAbout * aboutPage = static_cast<KoDocumentInfoAbout *>(info->page( "about" ));
00547 if ( !aboutPage )
00548 {
00549 kdWarning() << "'About' page not found in documentInfo !" << endl;
00550 }
00551 else
00552 aboutPage->setAbstract(text);
00553 }
00554
00555 QCStringList KoDocumentIface::functionsDynamic()
00556 {
00557 return DCOPObject::functionsDynamic() + KDCOPPropertyProxy::functions( m_pDoc );
00558 }
00559
00560 bool KoDocumentIface::processDynamic( const QCString &fun, const QByteArray &data,
00561 QCString& replyType, QByteArray &replyData )
00562 {
00563 if ( KDCOPPropertyProxy::isPropertyRequest( fun, m_pDoc ) )
00564 return KDCOPPropertyProxy::processPropertyRequest( fun, data, replyType, replyData, m_pDoc );
00565
00566 return DCOPObject::processDynamic( fun, data, replyType, replyData );
00567 }
00568
This file is part of the documentation for lib Library Version 1.4.2.