File indexing completed on 2024-05-12 16:35:35
0001 /* This file is part of the KDE project 0002 0003 Copyright 2002 Ariya Hidayat <ariya@kde.org> 0004 Copyright 2001 Laurent Montel <montel@kde.org> 0005 Copyright 2001 Philipp Mueller <philipp.mueller@gmx.de> 0006 Copyright 2000 Werner Trobin <trobin@kde.org> 0007 Copyright 1999-2000 Torben Weis <weis@kde.org> 0008 0009 This library is free software; you can redistribute it and/or 0010 modify it under the terms of the GNU Library General Public 0011 License as published by the Free Software Foundation; either 0012 version 2 of the License, or (at your option) any later version. 0013 0014 This library is distributed in the hope that it will be useful, 0015 but WITHOUT ANY WARRANTY; without even the implied warranty of 0016 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 0017 Library General Public License for more details. 0018 0019 You should have received a copy of the GNU Library General Public License 0020 along with this library; see the file COPYING.LIB. If not, write to 0021 the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, 0022 Boston, MA 02110-1301, USA. 0023 */ 0024 0025 // Local 0026 #include "MapAdaptor.h" 0027 0028 #include "SheetsDebug.h" 0029 #include "Map.h" 0030 #include "Sheet.h" 0031 0032 using namespace Calligra::Sheets; 0033 0034 MapAdaptor::MapAdaptor(Map* map) 0035 : QDBusAbstractAdaptor(map) 0036 { 0037 setAutoRelaySignals(true); 0038 m_map = map; 0039 } 0040 0041 QString MapAdaptor::sheet(const QString& name) 0042 { 0043 Sheet* t = m_map->findSheet(name); 0044 if (!t) 0045 return QString(); 0046 0047 return t->objectName(); 0048 } 0049 0050 QString MapAdaptor::sheetByIndex(int index) 0051 { 0052 Sheet* t = m_map->sheetList().at(index); 0053 if (!t) { 0054 debugSheets << "+++++ No table found at index" << index; 0055 return QString(); 0056 } 0057 0058 debugSheets << "+++++++ Returning table" << t->QObject::objectName(); 0059 0060 return t->objectName(); 0061 } 0062 0063 int MapAdaptor::sheetCount() const 0064 { 0065 return m_map->count(); 0066 } 0067 0068 QStringList MapAdaptor::sheetNames() const 0069 { 0070 QStringList names; 0071 foreach(Sheet* sheet, m_map->sheetList()) { 0072 names.append(sheet->objectName()); 0073 } 0074 return names; 0075 } 0076 0077 QStringList MapAdaptor::sheets() 0078 { 0079 QStringList t; 0080 foreach(Sheet* sheet, m_map->sheetList()) { 0081 t.append(sheet->objectName()); 0082 } 0083 return t; 0084 } 0085 0086 QString MapAdaptor::insertSheet(const QString& name) 0087 { 0088 if (m_map->findSheet(name)) 0089 return sheet(name); 0090 0091 Sheet* t = m_map->addNewSheet(); 0092 t->setSheetName(name); 0093 0094 return sheet(name); 0095 } 0096 0097 // bool MapAdaptor::processDynamic(const DCOPCString &fun, const QByteArray &/*data*/, 0098 // DCOPCString& replyType, QByteArray &replyData) 0099 // { 0100 // // Does the name follow the pattern "foobar()" ? 0101 // uint len = fun.length(); 0102 // if ( len < 3 ) 0103 // return false; 0104 // 0105 // if ( fun[ len - 1 ] != ')' || fun[ len - 2 ] != '(' ) 0106 // return false; 0107 // 0108 // Sheet* t = m_map->findSheet( fun.left( len - 2 ).data() ); 0109 // if ( !t ) 0110 // return false; 0111 // 0112 // replyType = "DCOPRef"; 0113 // QDataStream out( &replyData,QIODevice::WriteOnly ); 0114 // out.setVersion(QDataStream::Qt_3_1); 0115 // out << DCOPRef( kapp->dcopClient()->appId(), t->dcopObject()->objId() ); 0116 // return true; 0117 // }