Warning, file /office/calligra/libs/main/KoPartAdaptor.cpp was not indexed or was modified since last indexation (in which case cross-reference links may be missing, inaccurate or erroneous).

0001 /* This file is part of the KDE project
0002    Copyright (C) 2000 David Faure <faure@kde.org>
0003    Copyright (C) 2006 Fredrik Edemar <f_edemar@linux.se>
0004 
0005    This library is free software; you can redistribute it and/or
0006    modify it under the terms of the GNU Library General Public
0007    License as published by the Free Software Foundation; either
0008    version 2 of the License.
0009 
0010    This library is distributed in the hope that it will be useful,
0011    but WITHOUT ANY WARRANTY; without even the implied warranty of
0012    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
0013    Library General Public License for more details.
0014 
0015    You should have received a copy of the GNU Library General Public License
0016    along with this library; see the file COPYING.LIB.  If not, write to
0017    the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
0018  * Boston, MA 02110-1301, USA.
0019 */
0020 
0021 #include "KoPartAdaptor.h"
0022 
0023 #include <QList>
0024 
0025 #include "KoDocument.h"
0026 #include "KoPart.h"
0027 #include "KoDocumentInfo.h"
0028 #include "KoView.h"
0029 #include <MainDebug.h>
0030 
0031 
0032 KoPartAdaptor::KoPartAdaptor(KoPart *doc)
0033         : QDBusAbstractAdaptor(doc)
0034 {
0035     setAutoRelaySignals(true);
0036     m_pDoc = doc;
0037 }
0038 
0039 KoPartAdaptor::~KoPartAdaptor()
0040 {
0041 }
0042 
0043 void KoPartAdaptor::openUrl(const QString & url)
0044 {
0045     m_pDoc->document()->openUrl(QUrl(url));
0046 }
0047 
0048 bool KoPartAdaptor::isLoading()
0049 {
0050     return m_pDoc->document()->isLoading();
0051 }
0052 
0053 QString KoPartAdaptor::url()
0054 {
0055     return m_pDoc->document()->url().url();
0056 }
0057 
0058 bool KoPartAdaptor::isModified()
0059 {
0060     return m_pDoc->document()->isModified();
0061 }
0062 
0063 int KoPartAdaptor::viewCount()
0064 {
0065     return m_pDoc->viewCount();
0066 }
0067 
0068 QString KoPartAdaptor::view(int idx)
0069 {
0070     QList<KoView*> views = m_pDoc->views();
0071     KoView *v = views.at(idx);
0072     if (!v)
0073         return QString();
0074 
0075     return v->objectName();
0076 }
0077 
0078 void KoPartAdaptor::save()
0079 {
0080     m_pDoc->document()->save();
0081 }
0082 
0083 void KoPartAdaptor::saveAs(const QString & url)
0084 {
0085     m_pDoc->document()->saveAs(QUrl(url));
0086     m_pDoc->document()->waitSaveComplete(); // see ReadWritePart
0087 }
0088 
0089 void KoPartAdaptor::setOutputMimeType(const QByteArray& mimetype)
0090 {
0091     m_pDoc->document()->setOutputMimeType(mimetype);
0092 }
0093 
0094 QString KoPartAdaptor::documentInfoAuthorName() const
0095 {
0096     return m_pDoc->document()->documentInfo()->authorInfo("creator");
0097 }
0098 
0099 QString KoPartAdaptor::documentInfoEmail() const
0100 {
0101     return m_pDoc->document()->documentInfo()->authorInfo("email");
0102 }
0103 
0104 QString KoPartAdaptor::documentInfoCompanyName() const
0105 {
0106     return m_pDoc->document()->documentInfo()->authorInfo("company");
0107 }
0108 
0109 QString KoPartAdaptor::documentInfoTelephone() const
0110 {
0111     debugMain << " Keep compatibility with calligra <= 1.3 : use documentInfoTelephoneWork";
0112     return documentInfoTelephoneWork();
0113 }
0114 
0115 QString KoPartAdaptor::documentInfoTelephoneWork() const
0116 {
0117     return m_pDoc->document()->documentInfo()->authorInfo("telephone-work");
0118 }
0119 
0120 QString KoPartAdaptor::documentInfoTelephoneHome() const
0121 {
0122     return m_pDoc->document()->documentInfo()->authorInfo("telephone-home");
0123 }
0124 
0125 
0126 QString KoPartAdaptor::documentInfoFax() const
0127 {
0128     return m_pDoc->document()->documentInfo()->authorInfo("fax");
0129 
0130 }
0131 QString KoPartAdaptor::documentInfoCountry() const
0132 {
0133     return m_pDoc->document()->documentInfo()->authorInfo("country");
0134 
0135 }
0136 QString KoPartAdaptor::documentInfoPostalCode() const
0137 {
0138     return m_pDoc->document()->documentInfo()->authorInfo("postal-code");
0139 
0140 }
0141 QString KoPartAdaptor::documentInfoCity() const
0142 {
0143     return m_pDoc->document()->documentInfo()->authorInfo("city");
0144 }
0145 
0146 QString KoPartAdaptor::documentInfoInitial() const
0147 {
0148     return m_pDoc->document()->documentInfo()->authorInfo("initial");
0149 }
0150 
0151 QString KoPartAdaptor::documentInfoAuthorPosition() const
0152 {
0153     return m_pDoc->document()->documentInfo()->authorInfo("position");
0154 }
0155 
0156 QString KoPartAdaptor::documentInfoStreet() const
0157 {
0158     return m_pDoc->document()->documentInfo()->authorInfo("street");
0159 }
0160 
0161 QString KoPartAdaptor::documentInfoTitle() const
0162 {
0163     return m_pDoc->document()->documentInfo()->aboutInfo("title");
0164 }
0165 
0166 QString KoPartAdaptor::documentInfoAbstract() const
0167 {
0168     return m_pDoc->document()->documentInfo()->aboutInfo("comments");
0169 }
0170 
0171 QString KoPartAdaptor::documentInfoKeywords() const
0172 {
0173     return m_pDoc->document()->documentInfo()->aboutInfo("keywords");
0174 }
0175 
0176 QString KoPartAdaptor::documentInfoSubject() const
0177 {
0178     return m_pDoc->document()->documentInfo()->aboutInfo("subject");
0179 }
0180 void KoPartAdaptor::setDocumentInfoKeywords(const QString & text)
0181 {
0182     m_pDoc->document()->documentInfo()->setAboutInfo("keywords", text);
0183 }
0184 
0185 void KoPartAdaptor::setDocumentInfoSubject(const QString & text)
0186 {
0187     m_pDoc->document()->documentInfo()->setAboutInfo("subject", text);
0188 }
0189 
0190 void KoPartAdaptor::setDocumentInfoAuthorName(const QString & text)
0191 {
0192     m_pDoc->document()->documentInfo()->setAuthorInfo("creator", text);
0193 }
0194 
0195 void KoPartAdaptor::setDocumentInfoEmail(const QString &text)
0196 {
0197     m_pDoc->document()->documentInfo()->setAuthorInfo("email", text);
0198 }
0199 
0200 void KoPartAdaptor::setDocumentInfoCompanyName(const QString &text)
0201 {
0202     m_pDoc->document()->documentInfo()->setAuthorInfo("company", text);
0203 }
0204 
0205 void KoPartAdaptor::setDocumentInfoAuthorPosition(const QString &text)
0206 {
0207     m_pDoc->document()->documentInfo()->setAuthorInfo("position", text);
0208 }
0209 
0210 
0211 void KoPartAdaptor::setDocumentInfoTelephone(const QString &text)
0212 {
0213     debugMain << "Keep compatibility with calligra <= 1.3 : use setDocumentInfoTelephoneWork";
0214     setDocumentInfoTelephoneWork(text);
0215 }
0216 
0217 void KoPartAdaptor::setDocumentInfoTelephoneWork(const QString &text)
0218 {
0219     m_pDoc->document()->documentInfo()->setAuthorInfo("telephone-work", text);
0220 }
0221 
0222 void KoPartAdaptor::setDocumentInfoTelephoneHome(const QString &text)
0223 {
0224     m_pDoc->document()->documentInfo()->setAuthorInfo("telephone", text);
0225 }
0226 
0227 void KoPartAdaptor::setDocumentInfoFax(const QString &text)
0228 {
0229     m_pDoc->document()->documentInfo()->setAuthorInfo("fax", text);
0230 }
0231 
0232 void KoPartAdaptor::setDocumentInfoCountry(const QString &text)
0233 {
0234     m_pDoc->document()->documentInfo()->setAuthorInfo("country", text);
0235 }
0236 
0237 void KoPartAdaptor::setDocumentInfoTitle(const QString & text)
0238 {
0239     m_pDoc->document()->documentInfo()->setAboutInfo("title", text);
0240 }
0241 
0242 void KoPartAdaptor::setDocumentInfoPostalCode(const QString &text)
0243 {
0244     m_pDoc->document()->documentInfo()->setAuthorInfo("postal-code", text);
0245 }
0246 
0247 void KoPartAdaptor::setDocumentInfoCity(const QString & text)
0248 {
0249     m_pDoc->document()->documentInfo()->setAuthorInfo("city", text);
0250 }
0251 
0252 void KoPartAdaptor::setDocumentInfoInitial(const QString & text)
0253 {
0254     m_pDoc->document()->documentInfo()->setAuthorInfo("initial", text);
0255 }
0256 
0257 void KoPartAdaptor::setDocumentInfoStreet(const QString &text)
0258 {
0259     m_pDoc->document()->documentInfo()->setAuthorInfo("street", text);
0260 }
0261 
0262 void KoPartAdaptor::setDocumentInfoAbstract(const QString &text)
0263 {
0264     m_pDoc->document()->documentInfo()->setAboutInfo("comments", text);
0265 }