File indexing completed on 2024-04-28 16:21:21
0001 /* This file is part of the KDE project 0002 Copyright 2016 Tomas Mecir <mecirt@gmail.com> 0003 Copyright 2010 Marijn Kruisselbrink <mkruisselbrink@kde.org> 0004 Copyright 2007 Stefan Nikolaus <stefan.nikolaus@kdemail.net> 0005 Copyright 2007 Thorsten Zachmann <zachmann@kde.org> 0006 Copyright 2005-2006 Inge Wallin <inge@lysator.liu.se> 0007 Copyright 2004 Ariya Hidayat <ariya@kde.org> 0008 Copyright 2002-2003 Norbert Andres <nandres@web.de> 0009 Copyright 2000-2002 Laurent Montel <montel@kde.org> 0010 Copyright 2002 John Dailey <dailey@vt.edu> 0011 Copyright 2002 Phillip Mueller <philipp.mueller@gmx.de> 0012 Copyright 2000 Werner Trobin <trobin@kde.org> 0013 Copyright 1999-2000 Simon Hausmann <hausmann@kde.org> 0014 Copyright 1999 David Faure <faure@kde.org> 0015 Copyright 1998-2000 Torben Weis <weis@kde.org> 0016 0017 This library is free software; you can redistribute it and/or 0018 modify it under the terms of the GNU Library General Public 0019 License as published by the Free Software Foundation; either 0020 version 2 of the License, or (at your option) any later version. 0021 0022 This library is distributed in the hope that it will be useful, 0023 but WITHOUT ANY WARRANTY; without even the implied warranty of 0024 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 0025 Library General Public License for more details. 0026 0027 You should have received a copy of the GNU Library General Public License 0028 along with this library; see the file COPYING.LIB. If not, write to 0029 the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, 0030 Boston, MA 02110-1301, USA. 0031 */ 0032 #include "DocBase.h" 0033 #include "DocBase_p.h" 0034 0035 #include <KoDocumentResourceManager.h> 0036 #include <KoShapeRegistry.h> 0037 #include <KoPart.h> 0038 0039 #include "calligra_sheets_limits.h" 0040 #include "CalculationSettings.h" 0041 #include "Map.h" 0042 #include "SheetAccessModel.h" 0043 0044 #include "ElapsedTime_p.h" 0045 #include "odf/SheetsOdf.h" 0046 0047 #include "part/View.h" // TODO: get rid of this dependency 0048 0049 using namespace Calligra::Sheets; 0050 0051 QList<DocBase*> DocBase::Private::s_docs; 0052 int DocBase::Private::s_docId = 0; 0053 0054 Q_DECLARE_METATYPE(QPointer<QAbstractItemModel>) 0055 0056 DocBase::DocBase(KoPart *part) 0057 : KoDocument(part) 0058 , d(new Private) 0059 { 0060 Q_ASSERT(part); 0061 d->resourceManager = new KoDocumentResourceManager(); 0062 d->map = new Map(this, CURRENT_SYNTAX_VERSION); 0063 0064 // Document Url for FILENAME function and page header/footer. 0065 d->map->calculationSettings()->setFileName(url().toDisplayString()); 0066 0067 KoShapeRegistry *registry = KoShapeRegistry::instance(); 0068 foreach (const QString &id, registry->keys()) { 0069 KoShapeFactoryBase *shapeFactory = registry->value(id); 0070 shapeFactory->newDocumentResourceManager(d->resourceManager); 0071 } 0072 0073 d->configLoadFromFile = false; 0074 0075 documents().append(this); 0076 0077 d->sheetAccessModel = new SheetAccessModel(d->map); 0078 } 0079 0080 DocBase::~DocBase() 0081 { 0082 delete d->map; 0083 delete d->sheetAccessModel; 0084 delete d->resourceManager; 0085 delete d; 0086 } 0087 0088 QList<DocBase*> DocBase::documents() 0089 { 0090 return Private::s_docs; 0091 } 0092 0093 void DocBase::setReadWrite(bool readwrite) 0094 { 0095 map()->setReadWrite(readwrite); 0096 KoDocument::setReadWrite(readwrite); 0097 } 0098 0099 Map *DocBase::map() const 0100 { 0101 return d->map; 0102 } 0103 0104 int DocBase::syntaxVersion() const 0105 { 0106 return d->map->syntaxVersion(); 0107 } 0108 0109 KoDocumentResourceManager* DocBase::resourceManager() const 0110 { 0111 return d->resourceManager; 0112 } 0113 0114 SheetAccessModel *DocBase::sheetAccessModel() const 0115 { 0116 return d->sheetAccessModel; 0117 } 0118 0119 void DocBase::initConfig() 0120 { 0121 } 0122 0123 QStringList DocBase::spellListIgnoreAll() const { 0124 return d->spellListIgnoreAll; 0125 } 0126 0127 void DocBase::setSpellListIgnoreAll(const QStringList &list) { 0128 d->spellListIgnoreAll = list; 0129 } 0130 0131 bool DocBase::saveOdf(SavingContext &documentContext) 0132 { 0133 ElapsedTime et("OpenDocument Saving", ElapsedTime::PrintOnlyTime); 0134 return Odf::saveDocument(this, documentContext); 0135 } 0136 0137 bool DocBase::loadOdf(KoOdfReadStore & odfStore) 0138 { 0139 return Odf::loadDocument(this, odfStore); 0140 } 0141 0142 void DocBase::paintContent(QPainter &, const QRect &) 0143 { 0144 } 0145 0146 bool DocBase::loadXML(const KoXmlDocument &, KoStore *) 0147 { 0148 return false; 0149 } 0150