Warning, file /office/calligra/libs/widgets/KoDocumentInfoPropsPage.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) 1998, 1999, 2000 Torben Weis <weis@kde.org> 0003 Copyright (C) 2004, 2010 David Faure <faure@kde.org> 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, or (at your option) any later version. 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 "KoDocumentInfoPropsPage.h" 0022 0023 #include <QIcon> 0024 0025 #include "KoOdfReadStore.h" 0026 #include "KoStore.h" 0027 #include "KoDocumentInfo.h" 0028 #include "KoDocumentInfoDlg.h" 0029 #include <QUrl> 0030 #include <WidgetsDebug.h> 0031 0032 class KoDocumentInfoPropsPage::KoDocumentInfoPropsPagePrivate 0033 { 0034 public: 0035 KoDocumentInfo *m_info; 0036 KoDocumentInfoDlg *m_dlg; 0037 QUrl m_url; 0038 KoStore *m_src; 0039 KoStore *m_dst; 0040 }; 0041 0042 KoDocumentInfoPropsPage::KoDocumentInfoPropsPage(KPropertiesDialog *props, 0043 const QVariantList &) 0044 : KPropertiesDialogPlugin(props) 0045 , d(new KoDocumentInfoPropsPagePrivate) 0046 { 0047 d->m_info = new KoDocumentInfo(this); 0048 d->m_url = props->item().url(); 0049 d->m_dlg = nullptr; 0050 0051 if (!d->m_url.isLocalFile()) 0052 return; 0053 0054 d->m_dst = nullptr; 0055 0056 d->m_src = KoStore::createStore(d->m_url.toLocalFile(), KoStore::Read); 0057 0058 if (d->m_src->bad()) { 0059 return; // the store will be deleted in the dtor 0060 } 0061 0062 // OASIS/OOo file format? 0063 if (d->m_src->hasFile("meta.xml")) { 0064 KoXmlDocument metaDoc; 0065 KoOdfReadStore oasisStore(d->m_src); 0066 QString lastErrorMessage; 0067 if (oasisStore.loadAndParse("meta.xml", metaDoc, lastErrorMessage)) { 0068 d->m_info->loadOasis(metaDoc); 0069 } 0070 } 0071 // Old calligra file format? 0072 else if (d->m_src->hasFile("documentinfo.xml")) { 0073 if (d->m_src->open("documentinfo.xml")) { 0074 KoXmlDocument doc; 0075 if (doc.setContent(d->m_src->device())) 0076 d->m_info->load(doc); 0077 } 0078 } 0079 0080 d->m_dlg = new KoDocumentInfoDlg(props, d->m_info); 0081 d->m_dlg->setReadOnly(true); 0082 // "Steal" the pages from the document info dialog 0083 Q_FOREACH(KPageWidgetItem* page, d->m_dlg->pages()) { 0084 KPageWidgetItem* myPage = new KPageWidgetItem(page->widget(), page->header()); 0085 myPage->setIcon(page->icon()); 0086 props->addPage(myPage); 0087 } 0088 } 0089 0090 KoDocumentInfoPropsPage::~KoDocumentInfoPropsPage() 0091 { 0092 delete d->m_info; 0093 delete d->m_src; 0094 delete d->m_dst; 0095 delete d->m_dlg; 0096 delete d; 0097 } 0098 0099 void KoDocumentInfoPropsPage::applyChanges() 0100 { 0101 // Unused in Calligra 0102 }