From 8b78a8791bc539bcffe7159f9d9714d577cb3d7d Mon Sep 17 00:00:00 2001 From: Michele Calgaro Date: Sun, 23 May 2021 20:48:35 +0900 Subject: Renaming of files in preparation for code style tools. Signed-off-by: Michele Calgaro --- kspread/KSpreadMapIface.cpp | 125 ++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 125 insertions(+) create mode 100644 kspread/KSpreadMapIface.cpp (limited to 'kspread/KSpreadMapIface.cpp') diff --git a/kspread/KSpreadMapIface.cpp b/kspread/KSpreadMapIface.cpp new file mode 100644 index 000000000..ba8071f9c --- /dev/null +++ b/kspread/KSpreadMapIface.cpp @@ -0,0 +1,125 @@ +/* This file is part of the KDE project + + Copyright 2002 Ariya Hidayat + Copyright 2001 Laurent Montel + Copyright 2001 Philipp Mueller + Copyright 2000 Werner Trobin + Copyright 1999-2000 Torben Weis + + This library is free software; you can redistribute it and/or + modify it under the terms of the GNU Library General Public + License as published by the Free Software Foundation; either + version 2 of the License, or (at your option) any later version. + + This library is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + Library General Public License for more details. + + You should have received a copy of the GNU Library General Public License + along with this library; see the file COPYING.LIB. If not, write to + the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, + * Boston, MA 02110-1301, USA. +*/ + +#include +#include +#include + +#include "kspread_doc.h" +#include "kspread_map.h" +#include "kspread_sheet.h" + +#include "KSpreadMapIface.h" + +using namespace KSpread; + +MapIface::MapIface( Map* map ) + : DCOPObject( map ) +{ + m_map = map; +} + +DCOPRef MapIface::sheet( const TQString& name ) +{ + Sheet* t = m_map->findSheet( name ); + if ( !t ) + return DCOPRef(); + + return DCOPRef( kapp->dcopClient()->appId(), t->dcopObject()->objId() ); +} + +DCOPRef MapIface::sheetByIndex( int index ) +{ + Sheet* t = m_map->sheetList().at( index ); + if ( !t ) + { + kdDebug(36001) << "+++++ No table found at index " << index << endl; + return DCOPRef(); + } + + kdDebug(36001) << "+++++++ Returning table " << t->TQObject::name() << endl; + + return DCOPRef( kapp->dcopClient()->appId(), t->dcopObject()->objId() ); +} + +int MapIface::sheetCount() const +{ + return m_map->count(); +} + +TQStringList MapIface::sheetNames() const +{ + TQStringList names; + + TQPtrList& lst = m_map->sheetList(); + TQPtrListIterator it( lst ); + for( ; it.current(); ++it ) + names.append( it.current()->name() ); + + return names; +} + +TQValueList MapIface::sheets() +{ + TQValueList t; + + TQPtrList& lst = m_map->sheetList(); + TQPtrListIterator it( lst ); + for( ; it.current(); ++it ) + t.append( DCOPRef( kapp->dcopClient()->appId(), it.current()->dcopObject()->objId() ) ); + + return t; +} + +DCOPRef MapIface::insertSheet( const TQString& name ) +{ + if ( m_map->findSheet( name ) ) + return sheet( name ); + + Sheet* t = m_map->addNewSheet (); + t->setSheetName( name ); + + return sheet( name ); +} + +bool MapIface::processDynamic(const TQCString &fun, const TQByteArray &/*data*/, + TQCString& replyType, TQByteArray &replyData) +{ + // Does the name follow the pattern "foobar()" ? + uint len = fun.length(); + if ( len < 3 ) + return false; + + if ( fun[ len - 1 ] != ')' || fun[ len - 2 ] != '(' ) + return false; + + Sheet* t = m_map->findSheet( fun.left( len - 2 ).data() ); + if ( !t ) + return false; + + replyType = "DCOPRef"; + TQDataStream out( replyData, IO_WriteOnly ); + out << DCOPRef( kapp->dcopClient()->appId(), t->dcopObject()->objId() ); + return true; +} -- cgit v1.2.3