libs/main

KoDocumentAdaptor.cpp

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