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 QString KoDocumentIface::url()
00058 {
00059 return m_pDoc->url().url();
00060 }
00061
00062 bool KoDocumentIface::isModified()
00063 {
00064 return m_pDoc->isModified();
00065 }
00066
00067 int KoDocumentIface::viewCount()
00068 {
00069 return m_pDoc->viewCount();
00070 }
00071
00072 DCOPRef KoDocumentIface::view( int idx )
00073 {
00074 QPtrList<KoView> views = m_pDoc->views();
00075 KoView *v = views.at( idx );
00076 if ( !v )
00077 return DCOPRef();
00078
00079 DCOPObject *obj = v->dcopObject();
00080
00081 if ( !obj )
00082 return DCOPRef();
00083
00084 return DCOPRef( kapp->dcopClient()->appId(), obj->objId() );
00085 }
00086
00087 DCOPRef KoDocumentIface::action( const QCString &name )
00088 {
00089 return DCOPRef( kapp->dcopClient()->appId(), m_actionProxy->actionObjectId( name ) );
00090 }
00091
00092 QCStringList KoDocumentIface::actions()
00093 {
00094 QCStringList res;
00095 QValueList<KAction *> lst = m_actionProxy->actions();
00096 QValueList<KAction *>::ConstIterator it = lst.begin();
00097 QValueList<KAction *>::ConstIterator end = lst.end();
00098 for (; it != end; ++it )
00099 res.append( (*it)->name() );
00100
00101 return res;
00102 }
00103
00104 QMap<QCString,DCOPRef> KoDocumentIface::actionMap()
00105 {
00106 return m_actionProxy->actionMap();
00107 }
00108
00109 void KoDocumentIface::saveAs( const QString & url )
00110 {
00111 m_pDoc->saveAs( KURL( url ) );
00112 }
00113
00114 void KoDocumentIface::setOutputMimeType( const QCString & mimetype )
00115 {
00116 m_pDoc->setOutputMimeType( mimetype );
00117 }
00118
00119 QString KoDocumentIface::documentInfoAuthorName() const
00120 {
00121 KoDocumentInfo * info = m_pDoc->documentInfo();
00122 KoDocumentInfoAuthor * authorPage = static_cast<KoDocumentInfoAuthor *>(info->page( "author" ));
00123 if ( !authorPage )
00124 {
00125 kdWarning() << "Author information not found in documentInfo !" << endl;
00126 return QString::null;
00127 }
00128 else
00129 return authorPage->fullName();
00130 }
00131
00132 QString KoDocumentIface::documentInfoEmail() const
00133 {
00134 KoDocumentInfo * info = m_pDoc->documentInfo();
00135 KoDocumentInfoAuthor * authorPage = static_cast<KoDocumentInfoAuthor *>(info->page( "author" ));
00136 if ( !authorPage )
00137 {
00138 kdWarning() << "Author information not found in documentInfo !" << endl;
00139 return QString::null;
00140 }
00141 else
00142 return authorPage->email();
00143 }
00144
00145 QString KoDocumentIface::documentInfoCompanyName() const
00146 {
00147 KoDocumentInfo * info = m_pDoc->documentInfo();
00148 KoDocumentInfoAuthor * authorPage = static_cast<KoDocumentInfoAuthor *>(info->page( "author" ));
00149 if ( !authorPage )
00150 {
00151 kdWarning() << "Author information not found in documentInfo !" << endl;
00152 return QString::null;
00153 }
00154 else
00155 return authorPage->company();
00156 }
00157
00158 QString KoDocumentIface::documentInfoTelephone() const
00159 {
00160 KoDocumentInfo * info = m_pDoc->documentInfo();
00161 KoDocumentInfoAuthor * authorPage = static_cast<KoDocumentInfoAuthor *>(info->page( "author" ));
00162 if ( !authorPage )
00163 {
00164 kdWarning() << "Author information not found in documentInfo !" << endl;
00165 return QString::null;
00166 }
00167 else
00168 return authorPage->telephone();
00169
00170 }
00171 QString KoDocumentIface::documentInfoFax() const
00172 {
00173 KoDocumentInfo * info = m_pDoc->documentInfo();
00174 KoDocumentInfoAuthor * authorPage = static_cast<KoDocumentInfoAuthor *>(info->page( "author" ));
00175 if ( !authorPage )
00176 {
00177 kdWarning() << "Author information not found in documentInfo !" << endl;
00178 return QString::null;
00179 }
00180 else
00181 return authorPage->fax();
00182
00183 }
00184 QString KoDocumentIface::documentInfoCountry() const
00185 {
00186 KoDocumentInfo * info = m_pDoc->documentInfo();
00187 KoDocumentInfoAuthor * authorPage = static_cast<KoDocumentInfoAuthor *>(info->page( "author" ));
00188 if ( !authorPage )
00189 {
00190 kdWarning() << "Author information not found in documentInfo !" << endl;
00191 return QString::null;
00192 }
00193 else
00194 return authorPage->country();
00195
00196 }
00197 QString KoDocumentIface::documentInfoPostalCode() const
00198 {
00199 KoDocumentInfo * info = m_pDoc->documentInfo();
00200 KoDocumentInfoAuthor * authorPage = static_cast<KoDocumentInfoAuthor *>(info->page( "author" ));
00201 if ( !authorPage )
00202 {
00203 kdWarning() << "Author information not found in documentInfo !" << endl;
00204 return QString::null;
00205 }
00206 else
00207 return authorPage->postalCode();
00208
00209 }
00210 QString KoDocumentIface::documentInfoCity() const
00211 {
00212 KoDocumentInfo * info = m_pDoc->documentInfo();
00213 KoDocumentInfoAuthor * authorPage = static_cast<KoDocumentInfoAuthor *>(info->page( "author" ));
00214 if ( !authorPage )
00215 {
00216 kdWarning() << "Author information not found in documentInfo !" << endl;
00217 return QString::null;
00218 }
00219 else
00220 return authorPage->city();
00221
00222 }
00223
00224 QString KoDocumentIface::documentInfoInitial() const
00225 {
00226 KoDocumentInfo * info = m_pDoc->documentInfo();
00227 KoDocumentInfoAuthor * authorPage = static_cast<KoDocumentInfoAuthor *>(info->page( "author" ));
00228 if ( !authorPage )
00229 {
00230 kdWarning() << "Author information not found in documentInfo !" << endl;
00231 return QString::null;
00232 }
00233 else
00234 return authorPage->initial();
00235 }
00236
00237 QString KoDocumentIface::documentInfoStreet() const
00238 {
00239 KoDocumentInfo * info = m_pDoc->documentInfo();
00240 KoDocumentInfoAuthor * authorPage = static_cast<KoDocumentInfoAuthor *>(info->page( "author" ));
00241 if ( !authorPage )
00242 {
00243 kdWarning() << "Author information not found in documentInfo !" << endl;
00244 return QString::null;
00245 }
00246 else
00247 return authorPage->street();
00248
00249 }
00250
00251 QString KoDocumentIface::documentInfoTitle() const
00252 {
00253 KoDocumentInfo * info = m_pDoc->documentInfo();
00254 KoDocumentInfoAbout * aboutPage = static_cast<KoDocumentInfoAbout *>(info->page( "about" ));
00255 if ( !aboutPage )
00256 {
00257 kdWarning() << "'About' page not found in documentInfo !" << endl;
00258 return QString::null;
00259 }
00260 else
00261 return aboutPage->title();
00262
00263 }
00264
00265 QString KoDocumentIface::documentInfoAbstract() const
00266 {
00267 KoDocumentInfo * info = m_pDoc->documentInfo();
00268 KoDocumentInfoAbout * aboutPage = static_cast<KoDocumentInfoAbout *>(info->page( "about" ));
00269 if ( !aboutPage )
00270 {
00271 kdWarning() << "'About' page not found in documentInfo !" << endl;
00272 return QString::null;
00273 }
00274 else
00275 return aboutPage->abstract();
00276 }
00277
00278 void KoDocumentIface::setDocumentInfoAuthorName(const QString & text)
00279 {
00280 KoDocumentInfo * info = m_pDoc->documentInfo();
00281 KoDocumentInfoAuthor * authorPage = static_cast<KoDocumentInfoAuthor *>(info->page( "author" ));
00282 if ( !authorPage )
00283 {
00284 kdWarning() << "Author information not found in documentInfo !" << endl;
00285 }
00286 else
00287 authorPage->setFullName(text);
00288
00289 }
00290
00291 void KoDocumentIface::setDocumentInfoEmail(const QString &text)
00292 {
00293 KoDocumentInfo * info = m_pDoc->documentInfo();
00294 KoDocumentInfoAuthor * authorPage = static_cast<KoDocumentInfoAuthor *>(info->page( "author" ));
00295 if ( !authorPage )
00296 {
00297 kdWarning() << "Author information not found in documentInfo !" << endl;
00298 }
00299 else
00300 authorPage->setEmail(text);
00301 }
00302
00303 void KoDocumentIface::setDocumentInfoCompanyName(const QString &text)
00304 {
00305 KoDocumentInfo * info = m_pDoc->documentInfo();
00306 KoDocumentInfoAuthor * authorPage = static_cast<KoDocumentInfoAuthor *>(info->page( "author" ));
00307 if ( !authorPage )
00308 {
00309 kdWarning() << "Author information not found in documentInfo !" << endl;
00310 }
00311 else
00312 authorPage->setCompany(text);
00313 }
00314
00315 void KoDocumentIface::setDocumentInfoTelephone(const QString &text)
00316 {
00317 KoDocumentInfo * info = m_pDoc->documentInfo();
00318 KoDocumentInfoAuthor * authorPage = static_cast<KoDocumentInfoAuthor *>(info->page( "author" ));
00319 if ( !authorPage )
00320 {
00321 kdWarning() << "Author information not found in documentInfo !" << endl;
00322 }
00323 else
00324 authorPage->setTelephone(text);
00325
00326 }
00327
00328 void KoDocumentIface::setDocumentInfoFax(const QString &text)
00329 {
00330 KoDocumentInfo * info = m_pDoc->documentInfo();
00331 KoDocumentInfoAuthor * authorPage = static_cast<KoDocumentInfoAuthor *>(info->page( "author" ));
00332 if ( !authorPage )
00333 {
00334 kdWarning() << "Author information not found in documentInfo !" << endl;
00335 }
00336 else
00337 authorPage->setFax(text);
00338 }
00339
00340 void KoDocumentIface::setDocumentInfoCountry(const QString &text)
00341 {
00342 KoDocumentInfo * info = m_pDoc->documentInfo();
00343 KoDocumentInfoAuthor * authorPage = static_cast<KoDocumentInfoAuthor *>(info->page( "author" ));
00344 if ( !authorPage )
00345 {
00346 kdWarning() << "Author information not found in documentInfo !" << endl;
00347 }
00348 else
00349 authorPage->setCountry(text);
00350
00351 }
00352
00353 void KoDocumentIface::setDocumentInfoTitle(const QString & text)
00354 {
00355 KoDocumentInfo * info = m_pDoc->documentInfo();
00356 KoDocumentInfoAbout * aboutPage = static_cast<KoDocumentInfoAbout *>(info->page( "about" ));
00357 if ( !aboutPage )
00358 {
00359 kdWarning() << "'About' page not found in documentInfo !" << endl;
00360 }
00361 else
00362 aboutPage->setTitle(text);
00363 }
00364
00365 void KoDocumentIface::setDocumentInfoPostalCode(const QString &text)
00366 {
00367 KoDocumentInfo * info = m_pDoc->documentInfo();
00368 KoDocumentInfoAuthor * authorPage = static_cast<KoDocumentInfoAuthor *>(info->page( "author" ));
00369 if ( !authorPage )
00370 {
00371 kdWarning() << "Author information not found in documentInfo !" << endl;
00372 }
00373 else
00374 authorPage->setPostalCode(text);
00375
00376 }
00377
00378
00379 void KoDocumentIface::setDocumentInfoCity(const QString & text)
00380 {
00381 KoDocumentInfo * info = m_pDoc->documentInfo();
00382 KoDocumentInfoAuthor * authorPage = static_cast<KoDocumentInfoAuthor *>(info->page( "author" ));
00383 if ( !authorPage )
00384 {
00385 kdWarning() << "Author information not found in documentInfo !" << endl;
00386 }
00387 else
00388 authorPage->setCity(text);
00389 }
00390
00391 void KoDocumentIface::setDocumentInfoInitial(const QString & text)
00392 {
00393 KoDocumentInfo * info = m_pDoc->documentInfo();
00394 KoDocumentInfoAuthor * authorPage = static_cast<KoDocumentInfoAuthor *>(info->page( "author" ));
00395 if ( !authorPage )
00396 {
00397 kdWarning() << "Author information not found in documentInfo !" << endl;
00398 }
00399 else
00400 authorPage->setInitial(text);
00401 }
00402
00403
00404 void KoDocumentIface::setDocumentInfoStreet(const QString &text)
00405 {
00406 KoDocumentInfo * info = m_pDoc->documentInfo();
00407 KoDocumentInfoAuthor * authorPage = static_cast<KoDocumentInfoAuthor *>(info->page( "author" ));
00408 if ( !authorPage )
00409 {
00410 kdWarning() << "Author information not found in documentInfo !" << endl;
00411 }
00412 else
00413 authorPage->setStreet(text);
00414
00415 }
00416
00417
00418 void KoDocumentIface::setDocumentInfoAbstract(const QString &text)
00419 {
00420 KoDocumentInfo * info = m_pDoc->documentInfo();
00421 KoDocumentInfoAbout * aboutPage = static_cast<KoDocumentInfoAbout *>(info->page( "about" ));
00422 if ( !aboutPage )
00423 {
00424 kdWarning() << "'About' page not found in documentInfo !" << endl;
00425 }
00426 else
00427 aboutPage->setAbstract(text);
00428 }
00429
00430 QCStringList KoDocumentIface::functionsDynamic()
00431 {
00432 return DCOPObject::functionsDynamic() + KDCOPPropertyProxy::functions( m_pDoc );
00433 }
00434
00435 bool KoDocumentIface::processDynamic( const QCString &fun, const QByteArray &data,
00436 QCString& replyType, QByteArray &replyData )
00437 {
00438 if ( KDCOPPropertyProxy::isPropertyRequest( fun, m_pDoc ) )
00439 return KDCOPPropertyProxy::processPropertyRequest( fun, data, replyType, replyData, m_pDoc );
00440
00441 return DCOPObject::processDynamic( fun, data, replyType, replyData );
00442 }
00443
This file is part of the documentation for lib Library Version 1.3.5.