kword

KWordTableFrameSetIface.cpp

00001 /* This file is part of the KDE project
00002    Copyright (C) 2002 Laurent MONTEL <lmontel@mandrakesoft.com>
00003 
00004    This library is free software; you can redistribute it and/or
00005    modify it under the terms of the GNU Library General Public
00006    License as published by the Free Software Foundation; either
00007    version 2 of the License, or (at your option) any later version.
00008 
00009    This library is distributed in the hope that it will be useful,
00010    but WITHOUT ANY WARRANTY; without even the implied warranty of
00011    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
00012    Library General Public License for more details.
00013 
00014    You should have received a copy of the GNU Library General Public License
00015    along with this library; see the file COPYING.LIB.  If not, write to
00016    the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
00017  * Boston, MA 02110-1301, USA.
00018 */
00019 
00020 #include "KWordTableFrameSetIface.h"
00021 #include "KWordTextFrameSetIface.h"
00022 #include "KWordTextFrameSetEditIface.h"
00023 
00024 #include "KWFrame.h"
00025 #include "KWTableFrameSet.h"
00026 #include <kapplication.h>
00027 #include <dcopclient.h>
00028 #include "KWView.h"
00029 #include "KWDocument.h"
00030 #include "KWCanvas.h"
00031 
00032 KWordTableFrameSetIface::KWordTableFrameSetIface( KWTableFrameSet *_frame )
00033     : KWordFrameSetIface( _frame)
00034 {
00035    m_table = _frame;
00036 }
00037 
00038 uint KWordTableFrameSetIface::nbRows()
00039 {
00040   return m_table->getRows();
00041 }
00042 
00043 uint KWordTableFrameSetIface::numCols()
00044 {
00045   return m_table->getColumns();
00046 }
00047 uint KWordTableFrameSetIface::numCells()
00048 {
00049   return m_table->getNumCells();
00050 }
00051 
00052 DCOPRef KWordTableFrameSetIface::cell( int pos )
00053 {
00054     // This method now sucks
00055     KWTableFrameSet::TableIter i(m_table);
00056     int p = 0;
00057     for(; i && p <= pos; ++i,++p)
00058     if( ! i.current() )
00059         return DCOPRef();
00060 
00061     return DCOPRef( kapp->dcopClient()->appId(),
00062             i->dcopObject()->objId() );
00063 }
00064 
00065 DCOPRef KWordTableFrameSetIface::cell( uint row, uint col )
00066 {
00067   if( row>=m_table->getRows() || col>= m_table->getColumns())
00068         return DCOPRef();
00069     return DCOPRef( kapp->dcopClient()->appId(),
00070             m_table->cell(row,col)->dcopObject()->objId() );
00071 }
00072 
00073 DCOPRef KWordTableFrameSetIface::startEditingCell(uint row, uint col )
00074 {
00075     if( row>=m_table->getRows() || col>= m_table->getColumns())
00076         return DCOPRef();
00077 
00078     KWDocument *doc=m_table->kWordDocument();
00079     KWView* view = doc->getAllViews().first();
00080     KWCanvas* canvas = view->getGUI()->canvasWidget();
00081     KWTextFrameSet *m_frametext=m_table->cell(row,col);
00082     if( !m_frametext || m_frametext->isDeleted())
00083         return DCOPRef();
00084     canvas->checkCurrentEdit(m_frametext, true);
00085     return DCOPRef( kapp->dcopClient()->appId(),
00086             (static_cast<KWTextFrameSetEdit *>( canvas->currentFrameSetEdit()))->dcopObject()->objId() );
00087 }
KDE Home | KDE Accessibility Home | Description of Access Keys